|
第一步(ssid是wifi名称,passwd是密码):
root@myir-remi-1g:~# ifup_wifi_sta -ssid myir007 -passwd 12345678
SSID:myir007 PASSWD:12345678 DRIVER:nl80211
killall: hostapd: no process killed
killall: udhcpd: no process killed
find phy0 enable it
udhcpc: started, v1.31.1
udhcpc: sending discover
udhcpc: sending select for 192.168.0.104
udhcpc: lease of 192.168.0.104 obtained, lease time 7200
/etc/udhcpc.d/50default: Adding DNS 202.96.128.166
/etc/udhcpc.d/50default: Adding DNS 202.96.134.133
第二步(查看生成的wpa_supplicant-wlan0.conf):
root@myir-remi-1g:~# cat /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
ssid="myir007"
#psk="12345678"
psk=a1b5192bfbe5bd3b942bc83213d6c0e0bd281194844dbee97f4ece716946a2ed
}
第三步(使能wpa_supplicant@wlan0.service服务):
root@myir-remi-1g:~# systemctl enable wpa_supplicant@wlan0.service
Created symlink /etc/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service -> /lib/systemd/system/wpa_supplicant@.service.
第四步(创建11-wlan0.network文件):
root@myir-remi-1g:~# vi /etc/systemd/network/11-wlan0.network
root@myir-remi-1g:~# cat /etc/systemd/network/11-wlan0.network
[Match]
Name=wlan0
[Network]
DHCP=yes
[DHCP]
RouteMetric=20
第五步(重启):
root@myir-remi-1g:~# ifconfig wlan0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 metric 1
inet 192.168.30.248 netmask 255.255.255.0 broadcast 192.168.30.255
inet6 fe80::9a03:cfff:fe6c:f9d4 prefixlen 64 scopeid 0x20<link>
ether 98:03:cf:6c:f9:d4 txqueuelen 1000 (Ethernet)
RX packets 760 bytes 164544 (160.6 KiB)
RX errors 0 dropped 12 overruns 0 frame 0
TX packets 167 bytes 33031 (32.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
|
|