/usr # wpa_supplicant -Dwext -iwlan0 -C/var/run/wpa_supplicant -c/etc/wpa_supplicant.conf -B &
链接wifi /usr # udhcpc -i wlan0 udhcpc (v1.20.2) started Sending discover... Sending discover... Sending select for 192.168.43.4... Lease of 192.168.43.4 obtained, lease time 3600 /usr # ifconfig wlan0 192.168.43.4 /usr # ifconfig eth0 Link encap:Ethernet HWaddr 5E:F1:A1:49:56:A6 inet addr:192.168.1.155 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) Interrupt:57 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) wlan0 Link encap:Ethernet HWaddr 28:F3:66:F8:AC:20 inet addr:192.168.43.4 Bcast:192.168.43.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:30 errors:0 dropped:0 overruns:0 frame:0 TX packets:5 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2461 (2.4 KiB) TX bytes:1358 (1.3 KiB) /usr # ping 192.168.43.1 PING 192.168.43.1 (192.168.43.1): 56 data bytes 64 bytes from 192.168.43.1: seq=0 ttl=64 time=7.267 ms 64 bytes from 192.168.43.1: seq=1 ttl=64 time=4.245 ms --- 192.168.43.1 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 4.245/5.756/7.267 ms /usr # ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 data bytes ping: sendto: Network is unreachable /usr # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 192.168.43.0 * 255.255.255.0 U 0 0 0 wlan0 /usr # route add default gw 192.168.43.1 //写默认路由的下一跳地址 默认网关一般填写192.168.x.1,网关实质上是一个网络通向其他网络的IP地址。 /usr # ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 8.8.8.8: seq=0 ttl=53 time=259.829 ms 64 bytes from 8.8.8.8: seq=1 ttl=53 time=134.150 ms --- 8.8.8.8 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max = 134.150/196.989/259.829 ms /usr # route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default 192.168.43.1 0.0.0.0 UG 0 0 0 wlan0 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0192.168.43.0 * 255.255.255.0 U 0 0 0 wlan0
wpa_supplicant.conf:
ctrl_interface=/var/run/wpa_supplicant update_config=1 network={ ssid="123456" key_mgmt=WPA-PSK psk="123456789" }