可以通过iw命令查看当前无线网卡连接状态,获取连接wifi的MAC地址BSSID,也可以扫描附近的无线网络,获取附近的无线网络信息。

如果没有iw命令,可以通过以下命令安装

# Ubuntu下安装iw
sudo apt install iw

操作示例:

iw dev wlxc83a35xxxxx link 查看当前无线网卡连接状态

iw dev wlxc83a35xxxxx scan 扫描附近的无线网络

1.获取无线网卡名称

通过ip addr查看wifi网卡名称

3: wlxc83a3550000: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether c8:3a:35:58:49:9c brd ff:ff:ff:ff:ff:ff
    inet 192.168.55.1/21 brd 192.168.55.255 scope global wlxc83a3550000
       valid_lft forever preferred_lft forever
    inet6 fe80::ca3a:35ff:fe58:499c/64 scope link
       valid_lft forever preferred_lft forever

这里的网卡名称是 wlxc83a35xxxxx

2.查看当前无线网卡连接状态

查看当前连接的WiFi的BSSID,也就是mac地址

# 查看当前无线网卡连接状态
iw dev wlxc83a35xxxxx link

输出

Connected to b0:44:14:xx:xx:xx (on wlxc83a35xxxxx)         # 当前连接的无线MAC地址 b0:44:14:xx:xx:xx
        SSID: test                                          # SSID 连接的无线网络名称 test
        freq: 5260                                          # 频率 5260 MHz,无线连接使用的 射频频道
        RX: 3493948 bytes (17276 packets)                   # 接收数据包
        TX: 7693505 bytes (18522 packets)                   # 发送数据包
        signal: -52 dBm                                     # 信号强度
        rx bitrate: 292.5 MBit/s VHT-MCS 7 80MHz VHT-NSS 1  # 接收速率
        tx bitrate: 263.3 MBit/s VHT-MCS 6 80MHz VHT-NSS 1  # 发送速率

3.扫描附近的无线网络

iw dev wlxc83a3550000 scan

输出示例:

BSS 68:dd:b7:xx:xx:xx(on wlxc83a35xxxxx)
        TSF: 1745890211343116 usec (20207d, 01:30:11)
        freq: 2437
        beacon interval: 100 TUs
        capability: ESS Privacy ShortSlotTime RadioMeasure (0x1411)
        signal: -72.00 dBm
        last seen: 2396 ms ago
        Information elements from Probe Response frame:
        SSID: test
        Supported rates: 1.0* 2.0* 5.5* 11.0* 6.0 9.0 12.0 18.0
        Extended supported rates: 24.0 36.0 48.0 54.0
        DS Parameter set: channel 6
        Country: CN     Environment: bogus
                Channels [1 - 13] @ 30 dBm
        ERP: <no flags>
        HT capabilities:
                Capabilities: 0x106e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 3839 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 2 usec (0x04)
                HT RX MCS rate indexes supported: 0-15
                HT TX MCS rate indexes are undefined
        HT operation:
                 * primary channel: 6
                 * secondary channel offset: below
                 * STA channel width: any
                 * RIFS: 0
                 * HT protection: no
                 * non-GF present: 0
                 * OBSS non-GF present: 0
                 * dual beacon: 0
                 * dual CTS protection: 0
                 * STBC beacon: 0
                 * L-SIG TXOP Prot: 0
                 * PCO active: 0
                 * PCO phase: 0
        RSN:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        WPA:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
        WMM:     * Parameter version 1
                 * BE: CW 15-1023, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec
        Extended capabilities:
                 * BSS Transition
BSS 68:dd:b7:xx:xx:xx(on wlxc83a35xxxxx)
        TSF: 1745890213380663 usec (20207d, 01:30:13)
        freq: 5745
        beacon interval: 100 TUs
        capability: ESS Privacy SpectrumMgmt RadioMeasure (0x1111)
        signal: -83.00 dBm
        last seen: 360 ms ago
        Information elements from Probe Response frame:
        SSID: test
        Supported rates: 6.0* 9.0 12.0* 18.0 24.0* 36.0 48.0 54.0
        DS Parameter set: channel 149
        Country: CN     Environment: Indoor/Outdoor
                Channels [36 - 64] @ 23 dBm
                Channels [149 - 165] @ 30 dBm
        Power constraint: 3 dB
        RSN:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
                 * Capabilities: 16-PTKSA-RC 1-GTKSA-RC (0x000c)
        HT capabilities:
                Capabilities: 0x86e
                        HT20/HT40
                        SM Power Save disabled
                        RX HT20 SGI
                        RX HT40 SGI
                        No RX STBC
                        Max AMSDU length: 7935 bytes
                        No DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: No restriction (0x00)
                HT RX MCS rate indexes supported: 0-15
                HT TX MCS rate indexes are undefined
        HT operation:
                 * primary channel: 149
                 * secondary channel offset: above
                 * STA channel width: any
                 * RIFS: 0
                 * HT protection: no
                 * non-GF present: 1
                 * OBSS non-GF present: 0
                 * dual beacon: 0
                 * dual CTS protection: 0
                 * STBC beacon: 0
                 * L-SIG TXOP Prot: 0
                 * PCO active: 0
                 * PCO phase: 0
        WPA:     * Version: 1
                 * Group cipher: CCMP
                 * Pairwise ciphers: CCMP
                 * Authentication suites: PSK
        WMM:     * Parameter version 1
                 * BE: CW 15-1023, AIFSN 3
                 * BK: CW 15-1023, AIFSN 7
                 * VI: CW 7-15, AIFSN 2, TXOP 3008 usec
                 * VO: CW 3-7, AIFSN 2, TXOP 1504 usec
        VHT capabilities:
                VHT Capabilities (0x03d979b1):
                        Max MPDU length: 7991
                        Supported Channel Width: neither 160 nor 80+80
                        RX LDPC
                        short GI (80 MHz)
                        TX STBC
                        SU Beamformer
                        SU Beamformee
                        MU Beamformer
                        MU Beamformee
                        +HTC-VHT
                VHT RX MCS set:
                        1 streams: MCS 0-9
                        2 streams: MCS 0-9
                        3 streams: not supported
                        4 streams: not supported
                        5 streams: not supported
                        6 streams: not supported
                        7 streams: not supported
                        8 streams: not supported
                VHT RX highest supported: 867 Mbps
                VHT TX MCS set:
                        1 streams: MCS 0-9
                        2 streams: MCS 0-9
                        3 streams: not supported
                        4 streams: not supported
                        5 streams: not supported
                        6 streams: not supported
                        7 streams: not supported
                        8 streams: not supported
                VHT TX highest supported: 867 Mbps
        VHT operation:
                 * channel width: 1 (80 MHz)
                 * center freq segment 1: 155
                 * center freq segment 2: 0
                 * VHT basic MCS set: 0xfffa
        Extended capabilities:
                 * Extended Channel Switching
                 * BSS Transition
                 * SSID List
                 * Operating Mode Notification
                 * Max Number Of MSDUs In A-MSDU is unlimited

标签: Linux, WiFi

添加新评论