扫描WIFI
扫描指令: sudo iwlist wlan0 scan
扫描结果:
wlan0 Scan completed :
Cell 01 - Address: B8:F8:83:35:38:CA
Channel:1
Frequency:2.412 GHz (Channel 1)
Quality=45/70 Signal level=-65 dBm
Encryption key:on
ESSID:"lichen"
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: 60ms ago
IE: Unknown: 00066C696368656E
IE: Unknown: 010882848B960C121824
IE: Unknown: 030101
IE: Unknown: 050400010000
IE: Unknown: 0706434E20010D20
IE: Unknown: 2A0100
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 32043048606C
IE: Unknown: 2D1A6E101BFFFFFF0000000000000000008000000000000000000000
IE: Unknown: 3D1601050500000000000000000000000000000000000000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: DD180050F2020101010003A4000027A4000042435E0062322F00
IE: Unknown: DD0900037F01010000FF7F
Cell 02 - Address: 34:D7:12:A2:A2:46
Channel:8
Frequency:2.447 GHz (Channel 8)
Quality=51/70 Signal level=-59 dBm
Encryption key:on
ESSID:"Smartisan personal hotspot"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s
36 Mb/s; 48 Mb/s; 54 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 60ms ago
IE: Unknown: 001A536D6172746973616E20706572736F6E616C20686F7473706F74
IE: Unknown: 010482848B96
IE: Unknown: 030108
IE: Unknown: 3B0E515153547374757677787D7E7F80
IE: Unknown: 2A0100
IE: Unknown: 32080C1218243048606C
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 2D1A2D0113FF00000000000000000000000000000000000000000000
IE: Unknown: 3D1608000400000000000000000000000000000000000000
IE: Unknown: DD180050F2020101810003A4000027A4000042435E0062322F00
IE: Unknown: BF0C12F18033FEFF8601FEFF8601
IE: Unknown: C005000000FAFF
IE: Unknown: 7F080400000000000040
Cell 03 - Address: 74:05:A5:10:77:84
Channel:11
Frequency:2.462 GHz (Channel 11)
Quality=44/70 Signal level=-66 dBm
Encryption key:on
ESSID:"TP-LINK_7784"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 9 Mb/s
18 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 12 Mb/s; 24 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 60ms ago
IE: Unknown: 000C54502D4C494E4B5F37373834
IE: Unknown: 010882848B961224486C
IE: Unknown: 03010B
IE: Unknown: 2A0104
IE: Unknown: 32040C183060
IE: Unknown: 2D1AEE1117FFFF000001000000000000000000000000000000000000
IE: Unknown: 3D160B070400000000000000000000000000000000000000
IE: Unknown: 46057200000000
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
IE: Unknown: 7F080000080000000000
IE: Unknown: 0B05010000127A
IE: Unknown: DD180050F2020101000003A4000027A4000042435E0062322F00
IE: Unknown: 4A0E14000A002C01C800140005001900
IE: Unknown: 0706434E20010D10
IE: Unknown: DD07000C4303000000
这里的“ESSID”是无线网的名称。IEEE 802.11i/WPA2 Version 1是加密的方式,加密的类型是WPA2类型。
添加有密码的WIFI网络
通过配置wpa_supplicant.conf可以设置要连接的无线网。
sudo vim /etc/wpa_supplicant/wpa_supplicant.conf
在文件末尾出添加一下代码,并替换掉ssid_name以及password即可。
network={
ssid="ssid_name"
key_mgmt=WPA-PSK
psk="password"
}
通过
ifconfig wlan0
可以查看IP地址是否分配成功
添加没有密码的WIFI网络
添加没有密码的WIFI网络需要注意将key_mgmt设置为NONE
network={
ssid="ssid_name"
key_mgmt=NONE
}
错误的调试
如果出现连接不成功的情况,有很大的可能是由于配置文件配置错误的原因。
sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0
通过wpa_supplicant的直接连接,如果配置文件出现问题,则会直接提示配置文件的错误详情。
如果出现一下结果,则一般代表配置文件没有问题
Successfully initialized wpa_supplicant
nl80211: Driver does not support authentication/association or connect commands
wlan0: Failed to initialize driver interface