【OpenWrt】查看已连接设备

Posted by 西维蜀黍 on 2021-04-04, Last Modified on 2021-09-21

查看通过无线/有线连接的设备

Approach 1

$ cat /proc/net/arp
IP address       HW type     Flags       HW address            Mask     Device
192.168.0.1      0x1         0x2         **:95:**:5c:**:79     *        eth0.2
192.168.1.242    0x1         0x2         **:6c:**:77:**:40     *        br-lan
192.168.0.124    0x1         0x0         **:00:**:00:**:00     *        eth0.2
192.168.1.198    0x1         0x2         **:8d:**:5a:**:3c     *        br-lan
  • Flags标志可以表示是否在线状态,0x0表示离线,标志0x2表示在线
  • Device表示接口的名称

Approach 2

$ cat /tmp/dhcp.leases
1505227895   **:6c:**:77:**:40   192.168.1.242   android-5734b930181b5156   *
1505225907   **:8d:**:5a:**:3c   192.168.1.198   DESKTOP-AFGM9OL   01:40:8d:5c:5a:a0:3c

可以看到mac地址,IP,设备名等信息

查看 WIFI 连接设备

$ opkg update && opkg install iwinfo

$ iwinfo
wlan0     ESSID: unknown
          Access Point: DC:A6:32:B1:0E:06
          Mode: Client  Channel: 34 (5.170 GHz)
          Tx-Power: 0 dBm  Link Quality: unknown/70
          Signal: unknown  Noise: unknown
          Bit Rate: unknown
          Encryption: unknown
          Type: nl80211  HW Mode(s): 802.11bgnac
          Hardware: 02D0:A9A6 0000:0000 [Generic MAC80211]
          TX power offset: unknown
          Frequency offset: unknown
          Supports VAPs: no  PHY name: phy0
#ra0 是设备的名称,根据实际情况也可能是wlan0或者其他名称
$ iwinfo ra0 assoclist

结果:

**:**:**:C6:76:26  -44 dBm / -57 dBm (SNR 13)  37000 ms ago
    RX: 65.0 MBit/s, MCS 7, 20MHz                      0 Pkts.
    TX: 65.0 MBit/s, MCS 7, 20MHz                      0 Pkts.

**:**:**:FF:91:98  -44 dBm / -57 dBm (SNR 13)  6000 ms ago
    RX: 65.0 MBit/s, MCS 7, 20MHz                      0 Pkts.
    TX: 65.0 MBit/s, MCS 7, 20MHz                      0 Pkts.

Reference