咱們能夠使用ifconfig命令查看當前的網卡狀態信息。vim
root@raspberrypi:~# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.31.159 netmask 255.255.255.0 broadcast 192.168.31.255 inet6 fe80::a579:e25:d60e:838a prefixlen 64 scopeid 0x20<link> ether b8:27:eb:08:b2:02 txqueuelen 1000 (Ethernet) RX packets 42954 bytes 2101217 (2.0 MiB) RX errors 0 dropped 27 overruns 0 frame 0 TX packets 292 bytes 26175 (25.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether b8:27:eb:5d:e7:57 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
其中eth0爲有線網卡,lo表明127.0.0.1即localhost,wlan0表明無線網卡。網絡
下表對參數作一下簡單解釋框架
<> | UP 網卡已啓用less BROADCAST 廣播oop LOOPBACK 本地訪問ui RUNNING 網卡正在運行spa MULTICAST 多路廣播code |
mtu | MTU(Maximum Transmission Unit)最大傳輸單元 |
inet | IPV4地址 |
netmask | 網絡掩碼 |
broadcast | 廣播地址 |
inet6 | IPV6地址 |
prefixlen | 前綴長度 |
ether | 網卡地址(MAC) |
txqueuelen | 傳輸緩區長度大小意思 |
RX packets bytes | 接收{數據包數量 數據包大小} |
RX errors dropped overruns frame | 接收{錯誤數 丟包數 溢出數 框架} |
TX packets bytes | 發送{數據包數量 數據包大小} |
TX errors dropped overruns carrier collisions | 發送{錯誤數 丟包數 溢出數 載體 衝突} |
ESSID參數爲off顯然尚未連接無線網絡ip
root@raspberrypi:~# iwconfig wlan0 IEEE 802.11 ESSID:off/any Mode:Managed Access Point: Not-Associated Tx-Power=31 dBm Retry short limit:7 RTS thr:off Fragment thr:off Encryption key:off Power Management:on lo no wireless extensions. eth0 no wireless extensions.
列出可以搜索到的所有無線網絡ci
root@raspberrypi:~# iwlist wlan0 scan wlan0 Scan completed : Cell 01 - Address: A8:57:4E:86:7B:7E Channel:1 Frequency:2.412 GHz (Channel 1) Quality=43/70 Signal level=-67 dBm Encryption key:on ESSID:"TP-LINK_867" Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s 9 Mb/s; 12 Mb/s; 18 Mb/s Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s Mode:Master Extra:tsf=0000000000000000 Extra: Last beacon: 80ms ago IE: Unknown: 000B54502D4C494E4B5F383637 IE: Unknown: 010882848B960C121824 IE: Unknown: 030101 IE: Unknown: 2A0100 IE: Unknown: 32043048606C IE: Unknown: 2D1A6E1003FFFF000000000000000000000000000000000000000000 IE: Unknown: 3D1601050200000000000000000000000000000000000000 IE: IEEE 802.11i/WPA2 Version 1 Group Cipher : CCMP Pairwise Ciphers (1) : CCMP Authentication Suites (1) : PSK IE: WPA Version 1 Group Cipher : CCMP Pairwise Ciphers (1) : CCMP Authentication Suites (1) : PSK IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00 IE: Unknown: DD05000AEB0100 IE: Unknown: DD8E0050F204104A0001101044000102103B0001031047001000000000000010000000A8574E867B7E1021000754502D4C494E4B10230009544C2D57523834324E10240003342E3010420007312E312E312E331054000800060050F204000110110018576972656C657373204E20526F757465722057523834324E100800022288103C0001011049000600372A000120
root@raspberrypi:~# vim /etc/wpa_supplicant/wpa_supplicant.conf
在配置文件中增長無線wifi的配置
... network={ ssid="Xiaomi_F636" psk="imlichao" }
重啓系統後咱們能夠看到無線網卡已經啓用並鏈接到了wifi。
root@raspberrypi:~# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.31.159 netmask 255.255.255.0 broadcast 192.168.31.255 inet6 fe80::a579:e25:d60e:838a prefixlen 64 scopeid 0x20<link> ether b8:27:eb:08:b2:02 txqueuelen 1000 (Ethernet) RX packets 895 bytes 48460 (47.3 KiB) RX errors 0 dropped 1 overruns 0 frame 0 TX packets 91 bytes 13742 (13.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.31.134 netmask 255.255.255.0 broadcast 192.168.31.255 inet6 fe80::36eb:7046:a7fb:ddb3 prefixlen 64 scopeid 0x20<link> ether b8:27:eb:5d:e7:57 txqueuelen 1000 (Ethernet) RX packets 69 bytes 8121 (7.9 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 36 bytes 6014 (5.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@raspberrypi:~# iwconfig wlan0 IEEE 802.11 ESSID:"Xiaomi_F636" Mode:Managed Frequency:2.412 GHz Access Point: 64:09:80:12:F6:37 Bit Rate=24 Mb/s Tx-Power=31 dBm Retry short limit:7 RTS thr:off Fragment thr:off Encryption key:off Power Management:on Link Quality=55/70 Signal level=-55 dBm Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0 Tx excessive retries:0 Invalid misc:0 Missed beacon:0 lo no wireless extensions. eth0 no wireless extensions.