Ubuntu – How to find the DHCP server

dhcpnetworking

On my LAN there are multiple DHCP servers running, and all of them are on the same range.

Now I use a machine which has a dynamic IP address from a DHCP server. I have to know from which server it comes.

How to do that?!

Best Answer

To find out the DHCP server that's giving you the IP, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

cat /var/lib/dhcp3/dhclient.leases

Or you can just use grep command to get DHCP server address.

grep dhcp-server-identifier /var/lib/dhcp3/dhclient.leases

OR

grep dhcp-server-identifier /var/lib/dhcp/dhclient.leases

For Ubuntu 14.04, 16.04, and 17.10 you can use:

dhclient -d -nw eth0

Sample output:

Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/00:0c:29:49:3e:67
Sending on   LPF/eth0/00:0c:29:49:3e:67
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x4f723f9)
DHCPREQUEST of 192.168.138.136 on eth0 to 255.255.255.255 port 67 (xid=0x4f723f9)
DHCPOFFER of 192.168.138.136 from 192.168.138.254
DHCPACK of 192.168.138.136 from 192.168.138.254
RTNETLINK answers: File exists
bound to 192.168.138.136 -- renewal in 892 seconds.
Related Question