linux WIFI命令之iwlist、iwconfig、iwpriv、ifconfig

ifconfig:查询、设定网卡参数

ifconfig [interface] [up|down] ------查询网卡参数(如果不加interface的话,就会显示全部的活动的网卡参数,up和down分别是打开和关闭网卡)

[root@localhost ~]# ifconfig ------显示所有活动网卡参数

em1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 38:ea:a7:e4:1d:4b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 43790  bytes 20541338 (19.5 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 43790  bytes 20541338 (19.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.7  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::a617:31ff:fe8d:f9ed  prefixlen 64  scopeid 0x20<link>
        ether a4:17:31:8d:f9:ed  txqueuelen 1000  (Ethernet)
        RX packets 59402  bytes 65387010 (62.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 46445  bytes 11121984 (10.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

       就上面活动的无线网卡参数做详细解释:

       wlan0:就是网络卡的代号,也有 lo 这个 loopback ;

       HWaddr:就是网络卡的硬件地址,俗称的 MAC 地址;

       inet addr:IPv4 的 IP 地址,后续的 Bcast,Mask 分别代表的是 Broadcast 与 netmask !

       inet6 addr:是 IPv6 的版本的 IP ,我们没有使用,所以略过;

       MTU:标准以太网络所能传送的数据量最大可以到达 1500 bytes ,这个数值就被我们称为 MTU (Maximum Transmission Unit, 最大传输单位)

       RX:那一行代表的是网络由启动到目前为止的封包接收情况, packets 代表封包数、errors 代表封包发生错误的数量、 dropped 代表封包由于有问题而遭丢弃的数量等等

       TX:与 RX 相反,为网络由启动到目前为止的传送情况;

       collisions:代表封包碰撞的情况,如果发生太多次, 表示你的网络状况不太好;

       txqueuelen:代表用来传输数据的缓冲区的储存长度;

       RX bytes, TX bytes:总接收、发送字节总量


[root@localhost ~]# ifconfig wlan0 ------仅显示wlan0的参数

[root@localhost ~]# ifconfig wlan0 down------表示关掉wlan0,down掉后可以用ifconfig查看发现wlan0已经关掉不见了,可以用ifconfig wlan0 up重新启用。

设定ip地址:

[root@localhost ~]# ifconfig wlan0 192.168.1.10

       如果不加任何其他参数,则系统会依照该 IP所在的 class 范围,自动的计算出netmask 以及 network, broadcast等 IP 参数

设定MAC地址:首先要先关掉网卡,然后写入要设定的MAC地址,最后启动网卡即可。如下:

[root@localhost ~]#ifconfig wlan0 down

[root@localhost ~]#ifconfig hw ether 00:11:22:33:44:55

[root@localhost ~]#ifconfig wlan0 up


iwlist:扫描无线网络(前提是有无线网卡并处于活动状态)

[root@localhost ~]# iwlist wlan0 scanning 

    wlan0     Scan completed :
          Cell 01 - Address: 6C:E8:73:38:5A:C6
                    Channel:1
                    Frequency:2.412 GHz (Channel 1)
                    Quality=55/70  Signal level=-55 dBm  
                    Encryption key:on
                    ESSID:"xxxxxxxx"
                    Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
                              9 Mb/s; 12 Mb/s; 18 Mb/s
                    Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
                    Mode:Master

                    以下省略.........

iwconfig:配置无线网络(通用配置)

       iwconfig [interface]
       iwconfig interface [essid X] [nwid N] [mode M] [freq F]
                          [channel C][sens S ][ap A ][nick NN ]
                          [rate R] [rts RT] [frag FT] [txpower T]
                          [enc E] [key K] [power P] [retry R]
                          [modu M] [commit]

              Example :----配置mode
                   iwconfig eth0 mode Managed

                   iwconfig eth0 mode Ad-Hoc

              Examples :----配置工作频率
                   iwconfig eth0 freq 2422000000
                   iwconfig eth0 freq 2.422G
                   iwconfig eth0 channel 3
                   iwconfig eth0 channel auto

              Examples :----配置带宽
                   iwconfig eth0 rate 11M
                   iwconfig eth0 rate auto
                   iwconfig eth0 rate 5.5M auto

              Examples :----配置发射功率
                   iwconfig eth0 txpower 15
                   iwconfig eth0 txpower 30mW
                   iwconfig eth0 txpower auto
                   iwconfig eth0 txpower off

              Example :----配置接受灵敏度
                   iwconfig eth0 sens -80

              Examples :----配置调制方式
                   iwconfig eth0 modu 11g
                   iwconfig eth0 modu CCK OFDMa
                   iwconfig eth0 modu auto

iwpriv:iwpriv是iwconfig的辅助工具,用来配置无线网络接口的各种私有可选参数。

       iwpriv针对不同种类的驱动实现特定的参数处理和设置。iwpriv不跟参数时会列出每个接口上可用的私有命令和它们对应的参数。

[root@localhost ~]# iwpriv -----不加任何命令可以查看网卡的私有命令和参数

# iwpriv
lo        no private ioctls.----lo无私有命令

eth2      no private ioctls..----eth2无私有命令

eth3      no private ioctls..----eth3无私有命令

ra0       Available private ioctls :.----ra0有私有命令,如下
          set              (8BE2) : set 1024 char  & get   0
          ipv4_matinfo     (0001) : set 1024 char  & get 2047 char
          ipv6_matinfo     (0002) : set 1024 char  & get 2047 char
          cloneMAC         (0003) : set 1024 char  & get 2047 char
          connStatus       (0004) : set 1024 char  & get 2047 char
          driverVer        (0005) : set 1024 char  & get 2047 char
          bainfo           (0006) : set 1024 char  & get 2047 char
          descinfo         (0007) : set 1024 char  & get 2047 char
          get_wps_pin_ap   (0008) : set 1024 char  & get 2047 char

          .............

          .............


br0       no private ioctls..----br0无私有命令

usb0      no private ioctls..----usb0无私有命令



  • 2
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值