What's new

DHCP client list from ssh

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Caverna

New Around Here
Hi guys, hope u all are doing alright.

I have a small project here .. recently I upgraded my Asus RT-AC66U from original to Merlin. Corrently I´m using 380.70-0 running nice and smootly.

I need to get the DHCP list through SSH. I need ALL CLIENTS connected, no mater if is wi-fi or cable.

tks
 
cat /var/lib/misc/dnsmasq.leases

That gives you all the current leases but of course a device could have disconnected and still have a live lease. Reduce the lease time to minimum to make this less likely.


Sent from my iPhone using Tapatalk
 
Thanks for your response!

I already tried this command, it brings me old data... like u said. I need to get the "current" connected devices.

Do u know what parameter I should set to put lease time at minimum? (through SSH, of course)
 
I need to get the DHCP list through SSH. I need ALL CLIENTS connected, no mater if is wi-fi or cable.
As JDB pointed out DHCP is not something that tracks connections. The leases merely give you a historical list of connections from sometime in the past.
 
Do u know what parameter I should set to put lease time at minimum? (through SSH, of course)
You can change the lease duration with:
Code:
nvram set dhcp_lease=120
nvram commit
service restart_dnsmasq
This will set the lease to 120 seconds (the minimum normally allowed), so clients will typically renew their lease at half that - 60 seconds. Of course having all your DHCP clients renewing their leases every 60 seconds is probably not something that is desirable ;). And it has no effect on non-DHCP clients.
 
You could also try
arp -a
or
ip neigh show


But these commands also have timeouts before the entry is removed or marked as STALE. AFAIK, the only reliable way to know if it's still connected is to walk the command output and try and ping each client.
 
So based on John's arp suggestion I thought about arp-scan as an option, however it's not native to AsusWRT and also not properly added to Entware, however I did manage to compile it and it seems to do what you want. Brief instructions here (assumes you have installed Entware - which requires a USB drive to be connected to the router).

Code:
opkg install git-http ca-bundle gcc ldd make gawk sed autoconf automake libpcap

Code:
git clone https://github.com/royhills/arp-scan.git
git clone https://github.com/the-tcpdump-group/libpcap

Code:
cp -r libpcap/pcap /opt/include/
cp -r libpcap/pcap/pcap.h  /opt/include/

Code:
cd arp-scan/
source /opt/bin/gcc_env.sh
autoreconf --install
./configure --prefix=/opt
make
chmod a+x install-sh
make install

In theory you now have arp-scan installed and can do something like;
arp-scan -I br0 10.11.12.0/24

br0 is the local LAN bridge (not sure if it's named the same on the 66U as on my 88U, check with ifconfig)

My CCTV camera's sometimes return duplicate responses for some reason, but they can easily be filtered out as they contain the keyword 'DUP' in them.

Example output;
admin@JDBRouter:/tmp/home/root/arp-scan# arp-scan -I br0 10.11.12.0/24
Interface: br0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9.5 with 256 hosts (https://github.com/royhills/arp-scan)
10.11.12.2 4c:ed:fb:cd:7f:10 (Unknown)
10.11.12.3 10:7b:44:45:38:60 ASUSTek COMPUTER INC.
10.11.12.87 78:3e:53:69:f8:82 BSkyB Ltd
10.11.12.57 70:2c:1f:4b:04:72 Wisol
10.11.12.108 28:c2:dd:f0:fa:45 AzureWave Technology Inc.
10.11.12.112 d0:d2:b0:83:f5:d4 (Unknown)
10.11.12.102 b0:19:c6:b7:26:d2 Apple, Inc.
10.11.12.149 10:93:e9:03:2d:1c Apple, Inc.
10.11.12.174 78:3e:53:73:a2:8a BSkyB Ltd
10.11.12.181 00:11:32:90:e1:02 Synology Incorporated
10.11.12.186 34:12:98:03:33:74 Apple, Inc.
10.11.12.190 14:b1:c8:01:61:1a InfiniWing, Inc.
10.11.12.201 00:1b:67:14:ee:fc Cisco Systems Inc
10.11.12.154 00:0a:e2:17:92:30 Binatone Electronics International, Ltd
10.11.12.154 00:0a:e2:17:92:30 Binatone Electronics International, Ltd (DUP: 2)
10.11.12.162 00:0a:e2:1f:a1:1f Binatone Electronics International, Ltd

I have verified that these are indeed the only actually active devices on the network at the time of scan.

If you are interested in/need hostnames for easier identification of devices you can then match this list to dnsmasq.leases I guess.
 
Last edited:
Hi JDB !

Until your post i didn't have installed Entware. Now I have!

When I go to:
opkg install git-http ca-bundle gcc ldd make gawk sed autoconf automake libpcap

Are returning: -sh: opkg: not found
 
I´m pretty sure that I have Installed succefully.

To check, I run again the entware-setup.sh. Follow the install log

Info: This script will guide you through the Entware installation.
Info: Script modifies "entware" folder only on the chosen drive,
Info: no other data will be changed. Existing installation will be
Info: replaced with this one. Also some start scripts will be installed,
Info: the old ones will be saved on Entware partition with name
Info: like /tmp/mnt/sda1/jffs_scripts_backup.tgz

Info: Looking for available partitions...
[1] --> /tmp/mnt/sda1
=> Please enter partition number or 0 to exit
[0-1]: 1
Info: /tmp/mnt/sda1 selected.

* Warning: Found previous installation, saving...
Info: Creating /tmp/mnt/sda1/entware folder...
* Warning: Deleting old /tmp/opt symlink...
Info: Creating /tmp/opt symlink...
Info: Creating /jffs scripts backup...
tar: removing leading '/' from member names
Info: Modifying start scripts...
Info: Creating folders...
Info: Deploying opkg package manager...
Downloading /opt/bin/opkg... success!
Downloading /opt/etc/opkg.conf... success!
Downloading /opt/etc/profile... success!
Downloading /opt/etc/init.d/rc.func... success!
Downloading /opt/etc/init.d/rc.unslung... success!
Info: Basic packages installation...
Downloading http://pkg.entware.net/binaries/mipsel/Packages.gz
Updated list of available packages in /opt/var/opkg-lists/entware-ng
Installing ldconfig (1.0.17-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/ldconfig_1.0.17-1_mipselsf.ipk
Installing findutils (4.6.0-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/findutils_4.6.0-1_mipselsf.ipk
Installing libc (1.0.17-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/libc_1.0.17-1_mipselsf.ipk
Installing libgcc (5.4.0-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/libgcc_5.4.0-1_mipselsf.ipk
Installing libssp (5.4.0-1) to root...
Downloading http://pkg.entware.net/binaries/mipsel/libssp_5.4.0-1_mipselsf.ipk
Configuring ldconfig.
Configuring libgcc.
Configuring libc.
Configuring libssp.
Configuring findutils.

Congratulations! If there are no errors above then Entware-ng is successfully initialized.

Found a Bug? Please report at https://github.com/Entware-ng/Entware-ng/issues

Type 'opkg install <pkg_name>' to install necessary package.
 
I dont know why... after reboot ... opkg it´s working.

Then I run:
opkg install git-http ca-bundle gcc ldd make gawk sed autoconf automake libpcap

And I got:
* opkg_install_cmd: Cannot install package gcc.
* opkg_install_cmd: Cannot install package autoconf.
* opkg_install_cmd: Cannot install package automake.
 
Last edited:
Try ‘opkg update’ first


Sent from my iPhone using Tapatalk
 
Done.

Same result.

Code:
admin@RT-AC66R:/tmp/home/root# opkg install git-http ca-bundle gcc ldd make

 gawk sed autoconf automake libpcap
Package git-http (2.15.1-1) installed in root is up to date.
Package ca-bundle (20170717) installed in root is up to date.
Unknown package 'gcc'.
Package ldd (1.0.17-1) installed in root is up to date.
Package make (4.2.1-2) installed in root is up to date.
Package gawk (4.2.0-2) installed in root is up to date.
Package sed (4.4-1) installed in root is up to date.
Unknown package 'autoconf'.
Unknown package 'automake'.
Package libpcap (1.8.1-1) installed in root is up to date.
Collected errors:
 * opkg_install_cmd: Cannot install package gcc.
 * opkg_install_cmd: Cannot install package autoconf.
 * opkg_install_cmd: Cannot install package automake.
admin@RT-AC66R:/tmp/home/root#
 
Long shot but try just “opkg install gcc”

If not then my guess is gcc etc is not available for your kernel/processor on your router. I did this all on my AC88U, not sure if there is a significant enough difference from your router to make that possible.


Sent from my iPhone using Tapatalk
 
Since you have an AC66 (MIPS based and Entware is no longer updated), the packages may not be available.
Run
opkg list | grep gcc

to check. If it is, you should see something like this (this is from my AC68)
gcc - 6.3.0-1b - build a native toolchain for compiling on target
libgcc - 7.3.0-8 - GCC support library
 
Follow the result. U r right! It´s not available.

admin@RT-AC66R-8F50:/tmp/home/root# opkg list | grep gcc
libgcc - 5.4.0-1 - GCC support library
admin@RT-AC66R-8F50:/tmp/home/root#
 
Hi Guys, returning to put some aditional info about this thread.

Since It was not possible to run de arp-scan (due the merlin version to my router) . I tried nmap and seems to be a good solution.

I have executed the follow commands:

opkg update
opkg upgrade
opkg install nmap

then:

nmap -PR 192.168.1.0/24 -sn

Returns only active hosts.

Thanks again for the prompt help I received from everyone.
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top