博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Fedora 17/Linux下如何通过命令行连上wep加密的无线路由
阅读量:4177 次
发布时间:2019-05-26

本文共 4999 字,大约阅读时间需要 16 分钟。

1. 系统版本信息
[root@tp ~]# 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@tp ~]# systemctl stop NetworkManager.service
[root@tp ~]# 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@tp ~]# 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@tp ~]#
iw wlan0 link
Not connected.
4. 获取SSID
[root@tp ~]#
iw wlan0 scan | grep SSID
command failed: Network is down (-100)
[root@tp ~]# ifconfig wlan0 up
[root@tp ~]# 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
[root@tp ~]#
iw wlan0 scan | grep SSID
    SSID: n13u
    SSID: FAST_Diablo
5. 连接无线加密路由
[root@tp ~]#
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@tp ~]#
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@tp ~]# 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@tp ~]#
dhclient -r wlan0 #申请前先release
[root@tp ~]#
dhclient  wlan0
[root@tp ~]# 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@tp ~]# 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@tp ~]#
iw wlan0 disconnect
[root@tp ~]# iw wlan0 link
Not connected.
[root@tp ~]# 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@tp ~]# 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@tp ~]#

转载地址:http://sjtai.baihongyu.com/

你可能感兴趣的文章
(转载)linux命令之二十一find命令之xargs
查看>>
centos下C编程调用libvirt的API访问KVM虚拟机
查看>>
(转载)linux命令之二十四tar命令
查看>>
(转载)linux命令之二十五chgrp命令
查看>>
IntelLinux显卡驱动安装指南
查看>>
(转载)linux命令之二十六chown命令
查看>>
(转载)linux命令之二十七gzip命令
查看>>
(转载)linux命令之二十八df 命令
查看>>
(转载)linux命令之二十九du 命令
查看>>
Qt浅谈之五十一QT_OpenGL
查看>>
linux下c/c++实例之十四c实现的bt软件下载(记录)
查看>>
linux下c/c++实例之十五简单的学生信息管理系统
查看>>
C#通过COM组件调用C++的代码(转载)
查看>>
DGN格式转化为shp格式
查看>>
VS2010 语法错误: 标识符“__RPC__out_xcount_part” 解决方法
查看>>
使用QT5对access数据库进行操作,读取Access数据库表名中文乱码问题
查看>>
Qt5编程——excel操作
查看>>
QT5使用OpenGL的错误
查看>>
opengl实现任意两点间画圆柱体
查看>>
最新:斐讯K3千兆无线路由器刷官改版固件的详细图文教程
查看>>