如何获取OpenWrt 10.03中已连接的wifi客户端列表?
答案1
您可以使用 arp-table 或 DHCP-leases。这不是一个完美的解决方案,也许就足够了?
列出 arp 表
arp
列出 DHCP 租约
cat /tmp/dhcp.leases
... 并结合
for ip in $(arp | grep -v IP | awk '{print $1}'); do
grep $ip /tmp/dhcp.leases;
done
答案2
为了查看关联的 wifi 客户端,即使它们没有 DHCP 客户端或者没有 IP,您也必须向 AP 询问关联的 wifi 设备:
# MAC80211
iw dev wlan0 station dump
# Universal (Tested with OpenWRT 14.07 and 15.05.X)
# iwinfo must be installed first as it is optional
# opkg update && opkg install iwinfo
iwinfo wlan0/wl0/ath0 assoclist
# using hostapd
ubus call hostapd.wlan0 get_clients
# Proprietary Broadcom (wl)
wl -i wl0 assoclist
# Proprietary Atheros (madwifi)
wlanconfig ath0 list sta
这样你还可以查看连接速度。对我来说,它看起来是这样的:
# iwinfo wlan0 assoclist
12:34:56:78:9A:BC -26 dBm / -95 dBm (SNR 69) 1930 ms ago
RX: 24.0 MBit/s, MCS 0, 20MHz 3359 Pkts.
TX: 130.0 MBit/s, MCS 14, 20MHz, short GI 1209 Pkts.
答案3
cat /tmp/dhcp.leases|wc -l
我的arp -a
解决方案是
opkg update
opkg install arp-scan
arp-scan --interface=br-lan --localnet | grep responded | awk '{print $12}'
它将返回通过 LAN 端口连接到 OpenWRT 的设备数量。几乎实时。
答案4
hostapd
要直接从(管理接入点的守护进程)获取它们:
$ ubus call hostapd.wlan0 get_clients
{
"freq": 2462,
"clients": {
"<mac addr 1>": {
"auth": true,
"assoc": true,
"authorized": true,
"preauth": false,
"wds": false,
"wmm": true,
"ht": true,
"vht": false,
"wps": false,
"mfp": false,
"rrm": [
0,
0,
0,
0,
0
],
"aid": 1
}
}
}
(或者替换wlan0
为你感兴趣的接口)