rock5b使用AX210網(wǎng)卡進行無線連接
rock5b 使用 AX210 網(wǎng)卡進行無線連接?
插入 WIFI 網(wǎng)卡,網(wǎng)卡螺絲在 rock5b 背面,取下來然后固定網(wǎng)卡。

1?查看網(wǎng)卡信息
ssh 進入板子后,執(zhí)行下面命令看網(wǎng)卡信息
rock@rock-5b:~$ lspci
...
0002:21:00.0 Network controller: Intel Corporation Device 2725 (rev 1a)
...
執(zhí)行下面命令看設(shè)備信息:
rock@rock-5b:~$ iw dev
phy#0
Interface wlP2p33s0
ifindex 34
wdev 0x1
addr f4:c8:xx:xx:xx:b6
ssid abcd
type managed
channel 48 (5240 MHz), width: 160 MHz, center1: 5250 MHz
txpower 22.00 dBm
multicast TXQ:
qsz-byt qsz-pkt flows drops marks overlmt hashcol tx-bytes tx-packets
0 0 0 0 0 0 0 0 0
rock@rock-5b:~$ ip link show wlP2p33s0
34: wlP2p33s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
? ?link/ether f4:c8:8a:e8:56:b6 brd ff:ff:ff:ff:ff:ff
可知接口為wlP2p33s0。
注意:接下來的命令中出現(xiàn)的 wlP2p33s0,需要更換為自己本機顯示的接口名。
2?啟用網(wǎng)卡
執(zhí)行下面任意一條命令讓網(wǎng)卡工作。
rock@rock-5b:~$ sudo ip link set wlP2p33s0 up
rock@rock-5b:~$ sudo ifconfig wlP2p33s0 up
3?獲取要連接的 SSID 信息
使用iw掃描附近 wifi,如下:
rock@rock-5b:~$ sudo iw wlP2p33s0 scan | grep SSID
SSID: abcd
?* SSID List
SSID: abcd
?* SSID List
或者使用iwlist掃描附近 wifi,如下:
rock@rock-5b:~$ sudo iwlist wlP2p33s0 scanning | grep ESSID
? ? ? ? ? ? ? ? ? ?ESSID:"abcd"
? ? ? ? ? ? ? ? ? ?ESSID:"abcd"
4?連接 WIFI
接下來就是連接部分了。這里,我們要連接的 SSID 為abcd,密碼自己知道,為12345678。
wpa_passphrase默認使用WPA連接,確定你的 WIFI 設(shè)置為WPA/WPA2-Personal,反正就是要兼容WPA,單純的WPA2使用下面的命令連接握手失敗,而WPA/WPA2-Personal的配置,則可以連接成功:
sudo wpa_passphrase abcd 12345678 | sudo tee /etc/wpa_supplicant.conf
sudo wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlP2p33s0
iwconfig wlP2p33s0
5?分配 IP
上面的步驟沒有問題,就可以執(zhí)行下面的命令配置 IP:
sudo dhclient wlP2p33s0
rock@rock-5b:~$ ifconfig wlP2p33s0
wlP2p33s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> ?mtu 1500
? ? ? ?inet 192.168.0.31 ?netmask 255.255.255.0 ?broadcast 192.168.0.255
? ? ? ?ether f4:c8:8a:e8:56:b6 ?txqueuelen 1000 ?(Ethernet)
? ? ? ?RX packets 832 ?bytes 73982 (73.9 KB)
? ? ? ?RX errors 0 ?dropped 0 ?overruns 0 ?frame 0
? ? ? ?TX packets 791 ?bytes 170239 (170.2 KB)
? ? ? ?TX errors 0 ?dropped 0 overruns 0 ?carrier 0 ?collisions 0
6?配置自啟動(成功)
執(zhí)行下面的命令,完成 WIFI 的開機自動配置:
rock@rock-5b:~$ echo "
auto wlP2p33s0
iface wlP2p33s0 inet static
address 192.168.0.31
netmask 255.255.255.0
gateway 192.168.0.1
wpa-essid abcd
wpa-psk dc100fd053f3a8d06335a107b3df0b2feea707e2ce5158c4789c46a6c95ced27
" | sudo tee -a /etc/network/interfaces
執(zhí)行下面的命令重啟,拔掉網(wǎng)線,看效果:
rock@rock-5b:~$ sudo reboot
7?配置啟動服務(wù)(失?。?/span>
下面的步驟參考網(wǎng)絡(luò),但操作后沒有成功完成 WIFI 的 IP 自動設(shè)置,僅做參考。
接下來,配置自啟動:
rock@rock-5b:~$ echo "[Unit]
Description=WPA supplicant
Before=network.target
After=dbus.service
Wants=network.target
IgnoreOnIsolate=true
[Service]
Type=dbus
BusName=fi.w1.wpa_supplicant1
ExecStart=/sbin/wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlP2p33s0
[Install]
WantedBy=multi-user.target
# Alias=dbus-fi.w1.wpa_supplicant1.service
" | sudo tee /etc/systemd/system/wpa_supplicant.service
啟用服務(wù):
rock@rock-5b:~$ sudo systemctl enable wpa_supplicant.service
Removed /etc/systemd/system/multi-user.target.wants/wpa_supplicant.service.
Created symlink /etc/systemd/system/multi-user.target.wants/wpa_supplicant.service → /etc/systemd/system/wpa_supplicant.service.
# 沒效果執(zhí)行下面的命令禁止
rock@rock-5b:~$ sudo systemctl disable wpa_supplicant.service
Removed /etc/systemd/system/dbus-fi.w1.wpa_supplicant1.service.
Removed /etc/systemd/system/multi-user.target.wants/wpa_supplicant.service.
配置 dhcp:
rock@rock-5b:~$ echo "[Unit]
Description= DHCP Client
Before=network.target
[Service]
Type=simple
ExecStart=/sbin/dhclient wlP2p33s0 -v
ExecStop=/sbin/dhclient wlP2p33s0 -r
[Install]
WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/dhclient.service
啟用服務(wù):
rock@rock-5b:~$ sudo systemctl enable dhclient.service
Created symlink /etc/systemd/system/multi-user.target.wants/dhclient.service → /etc/systemd/system/dhclient.service.
# 沒效果執(zhí)行下面的命令禁止
rock@rock-5b:~$ sudo systemctl disable dhclient.service
Removed /etc/systemd/system/multi-user.target.wants/dhclient.service.
8?參考
https://wireless.wiki.kernel.org/en/users/Drivers/iwlwifi ( https://wireless.wiki.kernel.org/en/users/Drivers/iwlwifi )
https://askubuntu.com/questions/412325/automatically-connect-to-a-wireless-network-using-cli ( https://askubuntu.com/questions/412325/automatically-connect-to-a-wireless-network-using-cli )
https://www.heelpbook.net/2020/linux-managing-wifi-with-wpa_supplicant/ ( https://www.heelpbook.net/2020/linux-managing-wifi-with-wpa_supplicant/ )