Find Out If Ubuntu / Debian / Linux Mint is Using dhcp

There are a few command line tricks that help you find out if your Ubuntu, Linux Mint, Debian or Knoppix has an static IP or a dynamic one, received from the dhcp server.

Watch Free Movies

The static IP is fixed and the dynamic one changes every time you reboot the network interface.

A good method for finding out what “kind of IP” you have, is to grep for dhcp in the logs. Like this: cat /var/log/syslog | grep -i dhcp

$ cat /var/log/syslog | grep -i dhcp
Jan 29 07:44:55 naboo dhclient: DHCPREQUEST of 192.168.8.221 on eth0 to 192.168.8.254 port 67
Jan 29 07:44:55 naboo dhclient: DHCPACK of 192.168.8.221 from 192.168.8.254
Jan 29 07:44:55 naboo NetworkManager[423]: (eth0): DHCPv4 state changed reboot -> renew

If we study the output, we can see that the IP address on the machine is gave by the dhcp server, and it is a value between: 192.168.8.221 and 192.168.8.254.

Another thing that can be done, to find out the “kind of IP you have”, is to see the dhclient-*.lease files, from /var/lib/dhcp/:

You will see some files called /var/lib/dhcp/dhclient-*-eth0.lease, where * is replaced by a string of characters, like the ones in the listed output:

$ ls -ltr /var/lib/dhcp
total 8
-rw-r--r-- 1 root root 0 Apr 25 2012 dhclient.leases
-rw-r--r-- 1 root root 1479 Sep 19 20:01 dhclient-e70427e6-837d-4ffa-8cb0-4d38657040f3-eth0.lease
-rw-r--r-- 1 root root 1972 Jan 29 07:59 dhclient-ddf9008d-243a-4aeb-a612-d6f66b9bf5b7-eth0.lease

Now, do grep in the most recent file:

$ cat dhclient-*-eth0.lease | egrep "eth0|fixed|dhcp-server

You can have more than one dhclient-*-eth0.lease files, but only the latest file, has the latest IP addresses.

Scroll to Top