通过终端列出热点连接的设备

通过终端列出热点连接的设备

我通过 ap-hotspot 连接我的热点,然后我可以看到弹出的通知显示新设备已连接设备已断开连接。(因为我想了解使用或不使用热点的访问权限。)

如何列出通过终端连接的设备?

答案1

arp -a应该返回所有连接设备的列表。

答案2

显示设备列表:(替换<interface>为您的 wifi 接口的接口名称)

iw dev <interface> station dump

如果您不知道您的 wifi 接口的名称,请使用此命令来找出接口名称:

iw dev

答案3

如果你想要更详细的列表,我进行了调整这个脚本对于ap-hotspot脚本来自 webupd8

#!/bin/bash

# show_wifi_clients.sh
# Shows MAC, IP address and any hostname info for all connected wifi devices
# written for openwrt 12.09 Attitude Adjustment
# modified by [email protected] from http://wiki.openwrt.org/doc/faq/faq.wireless#how.to.get.a.list.of.connected.clients

echo    "# All connected wifi devices, with IP address,"
echo    "# hostname (if available), and MAC address."
printf  "# %-20s %-30s %-20s\n" "IP address" "lease name" "MAC address"
leasefile=/var/lib/misc/dnsmasq.leases
# list all wireless network interfaces 
# (for MAC80211 driver; see wiki article for alternative commands)
for interface in $(iw dev | grep Interface | cut -f 2 -s -d" ")
do
  # for each interface, get mac addresses of connected stations/clients
  maclist=$(iw dev "$interface" station dump | grep Station | cut -f 2 -s -d" ")
  # for each mac address in that list...
  for mac in $maclist
  do
    # If a DHCP lease has been given out by dnsmasq,
    # save it.
    ip="UNKN"
    host=""
    ip=$(cat $leasefile | cut -f 2,3,4 -s -d" " | grep "$mac" | cut -f 2 -s -d" ")
    host=$(cat $leasefile | cut -f 2,3,4 -s -d" " | grep "$mac" | cut -f 3 -s -d" ")
    # ... show the mac address:
    printf "  %-20s %-30s %-20s\n" "$ip" "$host" "$mac"
  done
done

将其复制到你的 PATH 中的一个文件中,例如~/bin/show_wifi_clients,使用 使其可执行chmod +x,然后享受。

答案4

我将手机连接到网络,并使用了Fing 应用程序(为了安卓iPhone)扫描已连接的客户端。

相关内容