linux下ifconfig、iwconfig、iwlist命令详解

2019-07-13 09:27发布

 在linux下查看网络信息。 一、ifconfig      用途:配置网络信息。      如果没有参数,将给出当前的active 接口。 # ifconfig eth0 Link encap:Ethernet HWaddr 02:00:E1:00:11:5A inet addr:192.168.1.234 Bcast:192.168.1.255 Mask:255.255.254.0 inet6 addr: fe80::e1ff:fe00:115a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:17338002 errors:0 dropped:11993 overruns:0 frame:0 TX packets:228594 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1759095713 (1.6 GiB) TX bytes:67780580 (64.6 MiB) Interrupt:33 Base address:0xc000 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:65536 Metric:1 RX packets:43362 errors:0 dropped:0 overruns:0 frame:0 TX packets:43362 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4835488 (4.6 MiB) TX bytes:4835488 (4.6 MiB) wlan0 Link encap:Ethernet HWaddr CC:79:CF:E2:FB:91 inet addr:192.168.50.180 Bcast:192.168.50.255 Mask:255.255.255.0 inet6 addr: fe80::ce79:cfff:fee2:fb91/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:460463 errors:0 dropped:26240 overruns:0 frame:0 TX packets:276794 errors:0 dropped:4 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:159088799 (151.7 MiB) TX bytes:83207394 (79.3 MiB) 这是开发板上的一块物理网卡和一个wifi模块。我们可以看到IP信息,网卡地址等等。这个命令还常用来设置网络信息 其中lo地址是127.0.0.1,这个地址是一个回环地址,代表本机(localhost)。 eg:ifconfig eth0 192.168.1.100. 设置IP有文档描述此命令即将废除,取代这个命令的是ip addr和ip link。 可以试试 ip -s link。

二、iwconfig 用途:配置无线网络接口 iwconfig [interface] iwconfig interface [essid X] [nwid N] [modeM] [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] 描述:iwconfig和ifconfig很相似。但是iwconfig仅仅和无线网络相关。用来设置参数等。 freq/channel eg: iwconfig eth0 freq 2422000000 iwconfig eth0 freq 2.422G iwconfig eth0 channel 3 iwconfig eth0 channel auto 三、iwlist iwlist:从无线网卡获取更详细的无线信息 描述:用于显示关于无线网络的额外信息。这些信息往往是iwconfig没有显示出来的。 scan:给出可以接入的热点列表信息。 rate/bit: 列出设备支持的比特率 相关文件: /proc/net/wireless Usage: iwlist [interface] scanning [essid NNN] [last] [interface] frequency [interface] channel [interface] bitrate [interface] rate [interface] encryption [interface] keys [interface] power [interface] txpower [interface] retry [interface] ap [interface] accesspoints [interface] peers [interface] event [interface] auth [interface] wpakeys [interface] genie [interface] modulation # iwlist wlan0 frequency wlan0 13 channels in total; available frequencies : Channel 01 : 2.412 GHz Channel 02 : 2.417 GHz Channel 03 : 2.422 GHz Channel 04 : 2.427 GHz Channel 05 : 2.432 GHz Channel 06 : 2.437 GHz Channel 07 : 2.442 GHz Channel 08 : 2.447 GHz Channel 09 : 2.452 GHz Channel 10 : 2.457 GHz Channel 11 : 2.462 GHz Channel 12 : 2.467 GHz Channel 13 : 2.472 GHz Current Frequency:2.457 GHz (Channel 10) # iwlist wlan0 channel wlan0 13 channels in total; available frequencies : Channel 01 : 2.412 GHz Channel 02 : 2.417 GHz Channel 03 : 2.422 GHz Channel 04 : 2.427 GHz Channel 05 : 2.432 GHz Channel 06 : 2.437 GHz Channel 07 : 2.442 GHz Channel 08 : 2.447 GHz Channel 09 : 2.452 GHz Channel 10 : 2.457 GHz Channel 11 : 2.462 GHz Channel 12 : 2.467 GHz Channel 13 : 2.472 GHz Current Frequency:2.457 GHz (Channel 10)