(1)首先ifconfig命令查看一下,这个就是查看你的前提是否满足,我的无线网卡设备名字为wlan0,这里已经成功加载
1|root@sabresd_6dq:/ # ifconfig
eth0 Link encap:Ethernet HWaddr 12:21:12:12:12:34 inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0 UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:2083 errors:0 dropped:0 overruns:0 frame:0 TX packets:43 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:169875 (165.8 KiB) TX bytes:2959 (2.8 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3208 (3.1 KiB) TX bytes:3208 (3.1 KiB) wlan0 Link encap:Ethernet HWaddr 7C:DD:90:78:81:51 inet6 addr: fe80::7edd:90ff:fe78:8151/64 Scope:Link UP BROADCAST RUNNING 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:4086851 (3.8 MiB) TX bytes:187712 (183.3 KiB)
(2)关闭eth0(eth0是本地的以太网)
root@sabresd_6dq:/ # ifconfig eth0 down
//此时eth0 就已经下线了 记得命令加权限哈,我这里是root //不是root的记得这样执行:
root@sabresd_6dq:/ # sudo ifconfig eth0 down (3)关掉了eth0之后,我们就可以开启USB WiFi无线网卡
root@sabresd_6dq:/ # ifconfig wlan0 up0x1300 = 00064300
可以看到:wlan0已经启动,再使用ifconfig查看,就可以看到eth0没有了,wlan0 还在
root@sabresd_6dq:/ # ifconfig
inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3208 (3.1 KiB) TX bytes:3208 (3.1 KiB) wlan0 Link encap:Ethernet HWaddr 7C:DD:90:78:81:51 inet6 addr: fe80::7edd:90ff:fe78:8151/64 Scope:Link UP BROADCAST RUNNING 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:5748079 (5.4 MiB) TX bytes:267896 (261.6 KiB)
(4)(上面的基础有了之后)扫描可用的无线网络
root@sabresd_6dq:/ # iwlist wlan0 scan | grep ESSID //根据ESSID进行过滤查找 ESSID:”LEDE-lede” ESSID:”hp_dx” ESSID:”PandoraBox_1708F0″ ESSID:”MiPhone” ESSID:”CMCC-FREEMM” ESSID:”CQUPT-Free” ESSID:”LEDE_q” ESSID:”CQUPT” ESSID:”CMCC-EDU-TEST” ESSID:”sk” ESSID:”dlink2001″ ESSID:”ChinaNet” ESSID:”CQUPT”
root@sabresd_6dq:/ # iwconfig wlan0 essid “MiPhone”(6)输入该网络的安全密码
root@sabresd_6dq:/ # iwconfig wlan0 key 15330478604(7)连接到指定的AP(无线路由)
root@sabresd_6dq:/ # iwconfig wlan0 ap auto(8)设置无线网卡的IP地址
root@sabresd_6dq:/ # ifconfig wlan0 192.168.1.120(9)使用 ping 命令检测无线网连通状况
root@sabresd_6dq:/ # ping 192.168.1.1PING 192.168.1.1 (192.168.1.1): 56 data bytes64 bytes from 192.168.1.1: seq=0 ttl=64 time=42.804 ms64 bytes from 192.168.1.1: seq=1 ttl=64 time=5.020 ms
以上就是为各位朋友分享的相关内容。想要了解更多Linux相关知识记得关注公众号“良许Linux”,或扫描下方二维码进行关注,更多等着你!