dhcp server liuxLinux serverNETWORK ADMINISTRATIONS

Unix & Linux: Command to list assigned dhcp addresses (6 Solutions!!)

Unix & Linux: Command to list assigned dhcp addresses

The Question: Is there a command I can use to ask the dhcpd server which addresses have been
assigned?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 21 people ==
No, you can only get this information server side from the DHCP server. This
information is contained in the DHCP server’s .lease file: /var/lib/dhcpd/
dhcpd.leases, if you’re using ISC’s DHCP server.
**** Example ****
$ more /var/lib/dhcpd/dhcpd.leases
# All times in this file are in UTC (GMT), not your local timezone. This is
# not a bug, so please don’t ask about it. There is no portable way to
# store leases in the local timezone, so please don’t request this as a
# feature. If this is inconvenient or confusing to you, we sincerely
# apologize. Seriously, though – don’t ask.
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.0.5-RedHat

lease 192.168.1.100 {
starts 4 2011/09/22 20:27:28;
ends 1 2011/09/26 20:27:28;
tstp 1 2011/09/26 20:27:28;
binding state free;
hardware ethernet 00:1b:77:93:a1:69;
uid “001000033w223241i”;
}

== This solution helped 9 people ==
egrep command can be used to get an output:
egrep “lease|hostname|hardware|}” /var/lib/dhcpd/dhcpd.leases
Output:
lease 192.168.11.10 {
hardware ethernet 20:6a:8a:55:19:0a;
client-hostname “Maryam-PC”;
}
lease 192.168.11.7 {
hardware ethernet 00:16:ea:51:d3:12;
client-hostname “parsoon”;
}
lease 192.168.11.3 {
hardware ethernet 00:17:c4:3f:84:e3;
client-hostname “zahra-ubuntu”;
}
lease 192.168.11.5 {
hardware ethernet 58:b0:35:f1:31:2f;
}

== This solution helped 23 people ==
isc-dhcpd package version 4.3.1 has this command to list leases:
dhcp-lease-list –lease PATH_TO_LEASE_FILE
This is a simple perl script script that also supports older DHCP releases. You
can see a copy in the http://sources.debian.net/src/isc-dhcp/4.3.3-5/contrib/
dhcp-lease-list.pl/ or in the official_DHCP_distribution (in contrib/) as well.
The output is pretty:
$ perl contrib/dhcp-lease-list.pl –lease /var/db/dhcpd/dhcpd.leases
To get manufacturer names please download http://standards.ieee.org/regauth/
oui/oui.txt to /usr/local/etc/oui.txt
MAC IP hostname valid until
manufacturer
With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user slm (https://unix.stackexchange.com/users/7453), user Shalom Craimer (https://unix.stackexchange.com/users/301735), user pylover (https://unix.stackexchange.com/users/28488), user Marko Todoric (https://unix.stackexchange.com/users/308537), user Hojat Modaresi (https://unix.stackexchange.com/users/55158), user damago1 (https://unix.stackexchange.com/users/220619), user Anthon (https://unix.stackexchange.com/users/33055), user anarcat (https://unix.stackexchange.com/users/30227), and the Stack Exchange Network (http://unix.stackexchange.com/questions/91799). Trademarks are property of their respective owners. Disclaimer: All information is provided “AS IS” without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.

source

by Roel Van de Paar

linux dhcp server

Alice AUSTIN

Alice AUSTIN is studying Cisco Systems Engineering. He has passion with both hardware and software and writes articles and reviews for many IT websites.

Leave a Reply

Your email address will not be published. Required fields are marked *