Fedora 17/Linux下如何通过命令行连上加密的无线路由

1. 系统版本信息[root@ ~]# uname -aLinux tp 3.3.4-5.fc17.x86_64 #1 SMP Mon May 7 17:29:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

2. 为防止NetworkManager服务带来干扰,先停止该服务[root@ ~]# systemctl stop NetworkManager.service[root@ ~]# systemctl status NetworkManager.serviceNetworkManager.service – Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled) Active: inactive (dead) since Sun, 12 Aug 2012 22:37:23 +0800; 4s ago Process: 8569 ExecStart=/usr/sbin/NetworkManager –no-daemon (code=exited, status=0/SUCCESS) CGroup: name=systemd:/system/NetworkManager.serviceAug 12 22:37:23 tp NetworkManager[8569]: <info> (em1): device state change: …]Aug 12 22:37:23 tp NetworkManager[8569]: <info> (em1): cleaning up…Aug 12 22:37:23 tp NetworkManager[8569]: <info> (em1): taking down device.Aug 12 22:37:23 tp NetworkManager[8569]: <info> (wlan0): now unmanagedAug 12 22:37:23 tp NetworkManager[8569]: <info> (wlan0): device state change…]Aug 12 22:37:23 tp NetworkManager[8569]: <info> (wlan0): deactivating device…]Aug 12 22:37:23 tp NetworkManager[8569]: <info> (wlan0): canceled DHCP trans…8Aug 12 22:37:23 tp NetworkManager[8569]: <info> (wlan0): cleaning up…Aug 12 22:37:23 tp NetworkManager[8569]: <info> (wlan0): taking down device.Aug 12 22:37:23 tp NetworkManager[8569]: <info> exiting (success)

3. 查看连接前的初始状态[root@ ~]# ifconfig wlan0wlan0: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet) RX packets 13547 bytes 13381624 (12.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12659 bytes 1974514 (1.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@ ~]# iw wlan0 linkNot connected.

4. 获取SSID[root@ ~]# iw wlan0 scan | grep SSIDcommand failed: Network is down (-100)[root@ ~]# ifconfig wlan0 up[root@ ~]# ifconfig wlan0wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet) RX packets 13547 bytes 13381624 (12.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12659 bytes 1974514 (1.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 05. 连接无线加密路由[root@ ~]# iw wlan0 connect -w n13u key d:0:’1234567890123’wlan0 (phy #0): connected to bc:ae:c5:7e:ba:fc# 此处对key的写法略作解释:key d:index:datad: default (transmit) key, 默认传输密码index: 0至3之间的单个数字,我第一次给的是0,,能获取到dhcp ip,后面换成其他数字后运行dhclient获取不到ipdata: 必须是5或13位的ascii字符,或者10或26位的16进制数字

6. 查看连接完成后无线网卡的状态[root@ ~]# iw wlan0 linkConnected to bc:ae:c5:7e:ba:fc (on wlan0) SSID: n13u freq: 2412 RX: 9499 bytes (134 packets) TX: 342 bytes (4 packets) signal: -47 dBm tx bitrate: 54.0 MBit/s bss flags: dtim period: 0 beacon int: 100[root@ ~]# ifconfig wlan0wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::62d8:19ff:fecc:7484 prefixlen 64 scopeid 0x20<link> ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet) RX packets 13550 bytes 13381882 (12.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12662 bytes 1974832 (1.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 07.获取无线路由提供的dhcp ip地址[root@ ~]# dhclient -r wlan0 #申请前先release[root@ ~]# dhclient wlan0[root@ ~]# ifconfig wlan0wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.168.139 netmask 255.255.255.0 broadcast 192.168.168.255 inet6 fe80::62d8:19ff:fecc:7484 prefixlen 64 scopeid 0x20<link> ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet) RX packets 13567 bytes 13386147 (12.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 12682 bytes 1979923 (1.8 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 08. 已经可以连通外网[root@ ~]# ping 8.8.8.8PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.64 bytes from 8.8.8.8: icmp_req=1 ttl=44 time=338 ms64 bytes from 8.8.8.8: icmp_req=2 ttl=44 time=362 ms^C— 8.8.8.8 ping statistics —2 packets transmitted, 2 received, 0% packet loss, time 1000msrtt min/avg/max/mdev = 338.816/350.498/362.181/11.697 ms

9. 断开连接[root@ ~]# iw wlan0 disconnect[root@ ~]# iw wlan0 linkNot connected.[root@ ~]# ifconfig wlan0wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.168.139 netmask 255.255.255.0 broadcast 192.168.168.255 inet6 fe80::62d8:19ff:fecc:7484 prefixlen 64 scopeid 0x20<link> ether 60:d8:19:cc:74:84 txqueuelen 1000 (Ethernet) RX packets 14214 bytes 13620419 (12.9 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 13375 bytes 2424481 (2.3 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0[root@ ~]# ping 8.8.8.8PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.From 192.168.168.139 icmp_seq=10 Destination Host UnreachableFrom 192.168.168.139 icmp_seq=11 Destination Host UnreachableFrom 192.168.168.139 icmp_seq=12 Destination Host UnreachableFrom 192.168.168.139 icmp_seq=13 Destination Host Unreachable^C— 8.8.8.8 ping statistics —14 packets transmitted, 0 received, +4 errors, 100% packet loss, time 13001mspipe 4[root@ ~]#

无论何时何地,只要创造就有收获,只有不息的奋进,才能证明生命的存在。

Fedora 17/Linux下如何通过命令行连上加密的无线路由

相关文章:

你感兴趣的文章:

标签云: