首先ifconfig查找自己的网卡标示。
然后ifconfig wlan0 up 开启网卡.
第一步:
/sbin/iwlist wlan0 scan 查找可用的无线ap
得到的结果如:
Cell 01 - Address: 00:11:22:33:44:55
ESSID:"00001"
Mode:Master
Channel:6
Frequency:2.437 GHz (Channel 6)
Quality=75/100 Signal level=-59 dBm Noise level=-80 dBm
Encryption key:on
IE: WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : TKIP
Pairwise Ciphers (2) : TKIP CCMP
Authentication Suites (1) : PSK
Preauthentication Supported
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
12 Mb/s; 24 Mb/s; 36 Mb/s; 9 Mb/s; 18 Mb/s
48 Mb/s; 54 Mb/s
Extra:tsf=0000000064554a71
这里我们感兴趣的是ESSID,Channel,Encryption key,Group Cipher,Pairwise Ciphers,Authentication Suites。
第二步:
/sbin/iwconfig wlan0 mode managed channel 6 key off essid 00001
/sbin/iwconfig wlan0 ap 00:11:22:33:44:55
因为ap是WPA2加密,所以接下来我们要先配置/etc/wpa_supplicant.conf 。
network={
scan_ssid=0
ssid="00001"
proto=WPA2
key_mgmt=WPA-PSK
pairwise=TKIP CCMP
group=TKIP
psk="your password"
}
第三步:
/usr/sbin/wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf
下面就能配置自己的ip和网关和DNS了。
第四步:配置自己的ip地址
/sbin/ifconfig wlan0 192.168.1.10 netmask 255.255.255.0
/sbin/route add default gw 192.168.1.1
最后在/etc/resolv.conf 里
nameserver 211.161.46.84
nameserver 211.161.46.85
这里就结束了,应该可以上网了。
最后断开网络后,记得
/sbin/route del default gw 192.168.1.1
/sbin/iwconfig wlan0 mode managed key off ap off essid off