1.移植wpa_supplicant ,上一篇当中已经说明了。
2.加载网卡驱动
我写了一个脚本:W311m.sh
#!/bin/sh
modprobe rt2800usb
echo 148F 5370 > /sys/bus/usb/drivers/rt2800usb/new_id
3.创建连接暗文密码
wpa_passphrase 路由器名 密码 > /etc/wpa_supplicant.conf
4.后台运行wpa_supplicant
wpa_supplicant -Dwext -iwlan0 -C/var/run/wpa_supplicant -c/etc/wpa_supplicant.conf &
要一直等待,直到出现:
Trying to associate with 94:44:52:b1:8b:83 (SSID=’yateksrd’ freq=2412 MHz)
Associated with 94:44:52:b1:8b:83
WPA: Key negotiation completed with 94:44:52:b1:8b:83 [PTK=CCMP GTK=CCMP]
CTRL-EVENT-CONNECTED – Connection to 94:44:52:b1:8b:83 completed (auth) [id=0 i]
5.自动配置IP地址
udhcpc -i wlan0
也要一直等待,直到出现:
Sending discover…
Sending select for 192.168.1.24…
Lease of 192.168.1.24 obtained, lease time 49979008
deleting routers
route: SIOCDELRT: No such process
adding dns 192.168.1.1
注意:如果出现内网或者网关无法ping通,看看是不是关闭了有线网卡。