debian/ubuntu连接wifi

  • iw方式

iw dev wlan0 scan #扫描wif列表
iw dev wlan0 connect openwrt #连接到openwrt
dhclient wlan0 #分配IP地址
iw dev wlan0 disconnect #断开连接
iw仅支持wep密码,但是wep已经没有路由器支持了,所以iw只能用于无密码的wifi连接
– wpa_supplicant

apt install wpasupplicant
wpa_passphrase myssid my_very_secret_passphrase > /etc/wpa_supplicant/wpa_supplicant.conf
#在/etc/network/interfaces中添加如下内容

allow-hotplug wlan0
iface wlan0 inet dhcp
        wpa-ssid myssid
        wpa-psk ccb290fd4fe6b22935cbae31449e050edd02ad44627b16ce0151668f5f53c01b

其中wpa-psk与wpa_supplicant.conf中的一致
systemctl enable wpa_supplicant
systemctl restart wpa_supplicant
ifup wlan0
iw dev wlan0 link #查看连接状态

参考:
https://wireless.wiki.kernel.org/en/users/documentation/iw
https://wiki.debian.org/WiFi/HowToUse
https://w1.fi/wpa_supplicant/

发表回复