Query Router/DHCP Server for copu of its leases list
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Query Router/DHCP Server for copu of its leases list
I know (from visiting its web admin pages) that my router/dhcp server maintains a list of hostnames to IP addresses. It preserves these even when the host in question is powered off.
This is a small (10-12 computers) local subnet that has no DNS server (it is not a windows domain), has mostly LINUX boxes (Netbios / samba server is not running on most of them) and has also a couple of cell phones, and a couple of MAC computers.
It is just big enough that trying to maintain a bunch of /etc/hosts files is a drag, and the dynamic IPs change just often enough that one can never be sure that what worked last week will work this week.
I would like to be able to access this information (IP addr <==> hostname pairs) from a script. Is there any cmd or piece of the DHCP protocol that can allow me to do that?
Please do NOT reply with any suggestions that involve DNS, WINS, /etc/hosts, or nbtscan.
I am also NOT asking how to find the ip address of the DHCP server, or my own hostname/IP address.
I mention all this negativity only because whenever this question (or a similar one) gets asked on the net, one of the above anwsers is invariably provided and they will not work in this case.
It seems to me that asking the DHCP server for a copy of the info it provides thru its web interface is the most efficient way to go.
Is this possible? (I could write something in Perl or Python if necessary. Or even in C)
Is this possible? (I could write something in Perl or Python if necessary. Or even in C)
Thanks,
pgmer6809
Put simply, yes, it's possible. You could send an HTTP request to the page that would contain that information; log in, if needed; parse out the data you need.
Last edited by individual; 09-15-2018 at 06:41 AM.
Reason: forgot a word.
Routers for SOHO tend to allow leases based on some number of settings. One maybe to set leases permanent. Not sure why you'd play with hosts files unless you have already set either IP's to static or set leases to permanent. Any sort of less than forever lease would result in a chance of IP changing.
I guess if you can access this router via ssh then you may get info for something like this.
Thanks jefro. Good idea to use ssh or so if avail. I should have been thinking out of the box I guess.
I did run nmap to check on ports:
Code:
nmap -sV 192.168.1.254
Starting Nmap 7.60 ( https://nmap.org ) at 2018-09-18 23:52 PDT
Nmap scan report for _gateway (192.168.1.254)
Host is up (0.0054s latency).
Not shown: 992 closed ports
PORT STATE SERVICE VERSION
20/tcp filtered ftp-data
21/tcp filtered ftp
22/tcp filtered ssh
23/tcp filtered telnet
80/tcp open http micro_httpd
443/tcp open ssl/http micro_httpd
5431/tcp open upnp Belkin/Linksys wireless router UPnP (UPnP 1.0; BRCM400 1.0)
9878/tcp open kca-service?
Service Info: OS: Linux 2.4; Device: router; CPE: cpe:/o:linux:linux_kernel:2.4
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 150.40 seconds
and it looks like ssh is running.
But when I try to connect using say:
Code:
ssh 192.168.1.254 -l <priviledged-account>
it just hangs. Ditto if I use ssh loginname@192.168.1.254
Other attempts to use say telnet or ftp are also unsuccessful.
Any other good ideas?
pgmer6809
Thanks jefro. Good idea to use ssh or so if avail. I should have been thinking out of the box I guess.
I did run nmap to check on ports:
Code:
nmap -sV 192.168.1.254
Starting Nmap 7.60 ( https://nmap.org ) at 2018-09-18 23:52 PDT
Nmap scan report for _gateway (192.168.1.254)
Host is up (0.0054s latency).
Not shown: 992 closed ports
PORT STATE SERVICE VERSION
20/tcp filtered ftp-data
21/tcp filtered ftp
22/tcp filtered ssh
23/tcp filtered telnet
80/tcp open http micro_httpd
443/tcp open ssl/http micro_httpd
5431/tcp open upnp Belkin/Linksys wireless router UPnP (UPnP 1.0; BRCM400 1.0)
9878/tcp open kca-service?
Service Info: OS: Linux 2.4; Device: router; CPE: cpe:/o:linux:linux_kernel:2.4
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 150.40 seconds
and it looks like ssh is running.
That result doesn’t say ssh is running. In fact it says port 22 is filtered.
What individual said...a script using wget, probably...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.