Clients connected to wifi

Is there a way to list the connected devices on my wifi access point?

I have an Angstrom Linux device acting as an access point, running hostapd , dhcpd , which works fine. Can I get a list of devices connected to the Wi-Fi? I know I can get the DHCP leases, but I need to know which devices connect through wlan0 . I’ve tried this ( iwlist has options):

iwlist wlan0 ap iwlist wlan0 accesspoints iwlist wlan0 peers 
wlan0 Interface doesn't have a list of Peers/Access-Points 

iwconfig , iwgetid , iwpriv and iwspy are also present in /sbin , but don’t seem to have options to display the client list.

8 Answers 8

iw also depends on nl80211 support in the WiFi interface’s driver — which is not present for all drivers yet. wireless.wiki.kernel.org/en/developers/documentation/nl80211

In case you have more than one devices, for example when having 2.4 GHz and 5GHz enabled, you might get an empty results back. This is an indicator that no client has connected to the specify interface or frequency.

Also i think that if you have wlan0.staX (certain wds/multiap/4addr configs) you would need to specify that interface for all staX interfaces

You could Use «arp» as root:

kinda nicer, but you got the point 🙂

It is downvoted because arp returns only hosts that are active on the network in the arp table on the host. If someone nasty associates with the AP and is passively sniffing they will never show up in the arp table.

Didn’t work for me. I call arp but it only contains entries for ethernet. If i use arp -i wlan0 nothing is shown. With iw dev wlan0 station dump it is working.

arp is really just a mapping from L3 (IP) to L2 (MAC) addresses. Deriving any information about connected stations is wrong. Its a wrong place to look. An could be a strict layer2 device and pass traffic without ever knowing the IP address of the AP. So down-voting.

You can also find list of connected devices to your AP by using this command:

cat /var/lib/misc/dnsmasq.leases 

dnsmasq.leases file lists all the devices which connected to AP so far. Also you can get list of all devices which connected to your device over WiFi or Ethernet by using this command:

That would be on systems that use dnsmasq as a DHCP server. The OP uses «dhcpd», presumably the ISC implementation. Also stations could associate and not request and DHCP lease or not send any IP or ARP traffic.

AP does not need to be a DHCP server nor does it even need to understand/talk in IP, so both your suggestions are off

arp-scan

As said on this answer you can use arp-scan package. Just arp-scan -l .

arp-scan is a command-line tool for system discovery and fingerprinting. It constructs and sends ARP requests to the specified IP addresses, and displays any responses that are received.

With systemd/udev names I found very useful an alias to

sudo arp-scan -l -t 200 -I $(ls /sys/class/net | grep -o "wl[^\t]\+") 

for the wireless interface and en instead of wl for wired interfaces.

  • -I —interface Use network interface . If this option is not specified, arp-scan will search the system interface list for the lowest numbered, configured up interface (excluding loopback).
  • -l —localnet Generate addresses from network interface configuration. Use the network interface IP address and network mask to generate the list of target host addresses.
  • -t —timeout Set initial per host timeout to ms, default=100. This timeout is for the first packet sent to each host.
Читайте также:  Проверка модуля wifi android

To read the arp cache table cool kids nowadays use ip neighbor .

I use something like this fast solution:

The /[1-9a-f]/ filter removes MAC addresses like 00:00:00. from listing.

The /^wl/ filter removes all non-wireless interfaces (without «wl» at the beginning of their names).

ip: 192.168.0.1 mac: 64:6e:ea:d1:d3:0a ip: 192.168.0.2 mac: a0:d3:a1:6d:d0:4a 

Also, for my convenience, I use a file macs with list of mac addresses of this context:

90:94:97:9f:85:10 My Huawei 64:6e:ea:d1:d3:0a Rostelecom Router 

To get a list of connected devices with parsing this file I use such command (the END section is unnecessary — it’s an updater):

awk 'BEGIN0)>$4~/[1-9a-f]+/&&$6~/^wl/>END>' /proc/net/arp 

So in this way the result will be:

192.168.0.1 Rostelecom Router 192.168.0.74 My Huawei 

The macupd.awk is the script for updating macs file. It gets vendor names from file oui.txt (located in the same directory) and uses them as descriptions of unknown hosts/clients connected to your machine and writes them to the macs list file (you may disable this by removing END section from command). Here is the script:

#!/usr/bin/gawk -f BEGIN< while((getline<"macs")>0) < str++ if($0!~"(^#|^$)")< nam=$0 gsub($1" ","",nam) macnamz[$1]=nam >> while((getline0)< if($4~/[1-9a-f]+/&&$6~/^wl/)< if(!macnamz[$4])< mac=macv=$4 gsub(":","",macv) vendor=substr(macv,1,6) rs=RS RS="\n|\r" while((getline<"oui.txt")>0) < if(toupper($1)~toupper(vendor))> RS=rs > > > if(update) < for(i in macnamz)"macs"> print "" > "macs" > > 

So if in the first running of my imperfect command the result will be (if all hosts where unknown):

192.168.10.1 00:d0:ef:aa:ee:ff 192.168.10.2 f4:bd:9e:00:00:00 192.168.10.3 00:22:72:11:22:33 

The second running will be such:

192.168.10.1 IGT 192.168.10.2 Cisco Systems, Inc 192.168.10.3 American Micro-Fuel Device Corp. 

The description of my script.

if($0!~»(^#|^$)») — Ignoring commented and empty lines.

gsub($1″ «,»»,nam) — I used nam variable for description (everything after space).

macnamz[$1]=nam — Final conversion of line to a part of associative array (there can not be 2 duplicated MACs — 2nd will overwrite 1st).

if($4~/[1-9a-f]+/&&$6~/^wl/) — Filtering out header line, zero MACs, and non-wireless interfaces.

if(!macnamz[$4]) — If connected device is not registered in our macs file.

gsub(«:»,»»,macv) and vendor=substr(macv,1,6) — Getting first 6 symbols of MAC.

RS=»\n|\r» — Because oui.txt may have MS Windows line endings.

macnamz[mac]=$0 — Converting line to an array member.

update=1 — This variable says that updating of file is necessary (if it is).

Источник

Connect to client Wi-Fi network

This page will explain how to connect your OpenWrt device to another Wi-Fi network by using its own radio. Due to technical limitations, your OpenWrt device will create its own subnet (in the example below it’s 192.168.2.x while the Wi-Fi router’s subnet is 192.168.1.x ) just as it would when connected to a modem, your OpenWrt device and devices connected to it will be able to reach the Internet, but won’t see devices connected to the other Wi-Fi/router).

If you want to actually set up a Wi-Fi repeater or keep devices connected to this device in the same subnet as the devices connected to the other router, you will need to follow this tutorial instead.

Web interface instructions

Refreshed with 21.02 LuCI images.

As said above, the LAN interface must be set in a different subnet than the Wi-Fi network you are connecting to. In our example the Wi-Fi network we are connecting to is using 192.168.1.x addresses, so we will need to change the IP address of the LAN interface first to 192.168.2.1

The LAN interface must be set in a different subnet than the Wi-Fi network you are connecting to.

We will now set up the client Wi-Fi network, the configuration needed to connect to another Wi-Fi network.

Once you are logged into the router,

Recommend to tick the ‘Replace wireless configuration’ to delete the wireless access point (Master) for the chosen radio.

If there is no *wan* firewall zone you need to create it, don’t save the Wi-Fi configuration. Go to bottom of this section describing how to create *wan* firewall zone.

Enter the Wi-Fi password, leave the “name of new network” as “wwan” and select wan firewall zone.

You will land in the client Wi-Fi settings page. Edit as required.
The most important settings are on the Operating Frequency line.

Set the Mode to Legacy if you are connecting to a Wi-Fi g network, or N if you are connecting to a Wi-Fi n (and so on).

Set the Width to the same value that you set on the Wi-Fi you are connecting to (to avoid bottlenecking the connection for no reason).

Press Save
Press Save & Apply.
Configuration is now complete.

This is the final result. Note how the client network has a ? instead of a IP address.
The wwan IP address is only visible in the Network Interfaces page.

This step should not be necessary if you had reset the router to OpenWrt defaults. If you have no “wan” firewall zone you must create it.

Click on Network and then on Firewall, then click on the Add button, and set up the new zone as you see in the following screenshot (which is a default wan firewall interface),

After you have done this, go back and repeat the other steps to add and save the Wi-Fi connection.

Command-line instructions

Before doing any actual configuration, the Wi-Fi interface must be enabled in order to be able to scan for networks in the vicinity:

uci set wireless.@wifi-device[0].disabled="0" uci commit wireless wifi

if you have more than one Wi-Fi radio in your device, then you can use the others in this tutorial instead by substituting their number. For example to enable the second Wi-Fi radio (usually a 5Ghz radio) you would need to uci set wireless.@wifi-device[1].disabled=0 and then use wlan1 instead of wlan0 in the command below.

Now we can list networks in range substituting your actual wireless interface for wlan0 :

# iw dev wlan0 scan BSS c8:d5:fe:c8:61:b0(on wlan0) -- associated TSF: 24324848870 usec (0d, 06:45:24) freq: 2412 beacon interval: 100 TUs capability: ESS (0x0411) signal: -72.00 dBm last seen: 140 ms ago Information elements from Probe Response frame: SSID: Violetta RSN: * Version: 1 * Group cipher: CCMP * Pairwise ciphers: CCMP * Authentication suites: PSK * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000) BSS f8:35:dd:eb:20:f8(on wlan0) TSF: 24225790925 usec (0d, 06:43:45) freq: 2457 beacon interval: 100 TUs capability: ESS (0x0431) signal: -90.00 dBm last seen: 1450 ms ago Information elements from Probe Response frame: SSID: GOinternet_EB20FB HT capabilities: Capabilities: 0x11ee HT20/HT40 SM Power Save disabled RX HT20 SGI RX HT40 SGI TX STBC RX STBC 1-stream Max AMSDU length: 3839 bytes DSSS/CCK HT40 Maximum RX AMPDU length 65535 bytes (exponent: 0x003) Minimum RX AMPDU time spacing: 4 usec (0x05) HT RX MCS rate indexes supported: 0-15, 32 HT TX MCS rate indexes are undefined HT operation: * primary channel: 10 * secondary channel offset: below * STA channel width: any RSN: * Version: 1 * Group cipher: TKIP * Pairwise ciphers: TKIP CCMP * Authentication suites: PSK * Capabilities: 1-PTKSA-RC 1-GTKSA-RC (0x0000)

In the example, there are two networks, a Wi-Fi g one called Violetta and a Wi-Fi n one called GOinternet_EB20FB. The device was configured to connect to the one called Violetta.

These are the uci values that were added or changed by the configuration procedure.
For SSID, BSSID, and encryption you must use the info you got from the Wi-Fi scan above.
For an explanation of why these values were changed, please read the luci tutorial above.

network.lan.ipaddr='192.168.2.1' network.wwan=interface network.wwan.proto='dhcp' firewall.@zone[1]=zone firewall.@zone[1].name='wwan' firewall.@zone[1].input='REJECT' firewall.@zone[1].output='ACCEPT' firewall.@zone[1].forward='REJECT' firewall.@zone[1].masq='1' firewall.@zone[1].mtu_fix='1' firewall.@zone[1].network='wwan' wireless.@wifi-iface[1]=wifi-iface wireless.@wifi-iface[1].network='wwan' wireless.@wifi-iface[1].ssid='Violetta' wireless.@wifi-iface[1].encryption='psk2' wireless.@wifi-iface[1].device='radio0' wireless.@wifi-iface[1].mode='sta' wireless.@wifi-iface[1].bssid='C8:D5:FE:C8:61:B0' wireless.@wifi-iface[1].key='myWifiPasswordHere'

Known Issues

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website. OK More information about cookies

Self-registration in the wiki has been disabled.
If you want to contribute to the OpenWrt wiki, please post HERE in the forum or ask on IRC for access.

Except where otherwise noted, content on this wiki is licensed under the following license:
CC Attribution-Share Alike 4.0 International

Источник

Оцените статью
Adblock
detector