感谢支持
我们一直在努力

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

1. 系统版本信息
[root@ www.linuxidc.com ~]# uname -a
Linux 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@ www.linuxidc.com ~]# systemctl stop NetworkManager.service
[root@ www.linuxidc.com ~]# systemctl status NetworkManager.service
NetworkManager.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.service

Aug 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 unmanaged
Aug 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…8
Aug 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@ www.linuxidc.com ~]# ifconfig wlan0
wlan0: 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@ www.linuxidc.com ~]# iw wlan0 link
Not connected.


4. 获取SSID
[root@ www.linuxidc.com ~]# iw wlan0 scan | grep SSID
command failed: Network is down (-100)
[root@ www.linuxidc.com ~]# ifconfig wlan0 up
[root@ www.linuxidc.com ~]# ifconfig wlan0
wlan0: 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 0

5. 连接无线加密路由
[root@ www.linuxidc.com ~]# iw wlan0 connect -w n13u key d:0:’1234567890123′
wlan0 (phy #0): connected to bc:ae:c5:7e:ba:fc
# 此处对key的写法略作解释:key d:index:data
d: default (transmit) key, 默认传输密码
index: 0至3之间的单个数字,我第一次给的是0,能获取到dhcp ip,后面换成其他数字后运行dhclient获取不到ip
data: 必须是5或13位的ascii字符,或者10或26位的16进制数字


6. 查看连接完成后无线网卡的状态
[root@ www.linuxidc.com ~]# iw wlan0 link
Connected 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@ www.linuxidc.com ~]# ifconfig wlan0
wlan0: 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 0

7.获取无线路由提供的dhcp ip地址
[root@ www.linuxidc.com ~]# dhclient -r wlan0 #申请前先release
[root@ www.linuxidc.com ~]# dhclient  wlan0
[root@ www.linuxidc.com ~]# ifconfig wlan0
wlan0: 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 0

8. 已经可以连通外网
[root@ www.linuxidc.com ~]# ping 8.8.8.8
PING 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 ms
64 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 1000ms
rtt min/avg/max/mdev = 338.816/350.498/362.181/11.697 ms


9. 断开连接
[root@ www.linuxidc.com ~]# iw wlan0 disconnect
[root@ www.linuxidc.com ~]# iw wlan0 link
Not connected.
[root@ www.linuxidc.com ~]# ifconfig wlan0
wlan0: 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@ www.linuxidc.com ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.168.139 icmp_seq=10 Destination Host Unreachable
From 192.168.168.139 icmp_seq=11 Destination Host Unreachable
From 192.168.168.139 icmp_seq=12 Destination Host Unreachable
From 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 13001ms
pipe 4
[root@ www.linuxidc.com ~]#

赞(0) 打赏
转载请注明出处:服务器评测 » Fedora 17/Linux下如何通过命令行连上加密的无线路由
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏