Most of the systems in a network receive their IP addresses and other networking-related parameters from a DHCP server. You might know how to find your system's IP address assigned by a DHCP server. But do you know what's the IP address of your DHCP server?

Let’s briefly explain what a DHCP server actually is and how you can find its IP address on Linux.

What Is a DHCP Server?

A DHCP server, short for Dynamic Host Configuration Protocol server, provides IP addresses and other network parameters to the clients on a network. It lets devices automatically obtain and renew IP addresses.

Without a DHCP server, an administrator would have to manually configure the IP address for each device; hence it also reduces the efforts required to administer a network. A DHCP server also eliminates the chance of IP address conflict, which occurs if the same IP address is allocated to multiple devices.

The information the DHCP server provides includes the IP address, subnet mask, DNS server address, default gateway, and the lease time. Each DHCP client obtains an IP address from a DHCP server in the following simple steps:

  • Sends the DHCPDISCOVER broadcast message
  • Receives the DHCPOFFER message from the DCHP server
  • Sends the DHCPREQUEST message to the DCHP server
  • Receives the DHCPACK message from the DCHP server

1. Find the IP Address of a DHCP Server From the /var/log Directory

The /var/log directory on Linux stores most of the system's logs. It contains authorization logs, kernel logs, system logs, and the logs generated by the applications. From these logs, you can find the IP address of a DHCP server.

On Debian-based distributions, DHCP server-related information is stored in the /var/log/syslog directory while on RHEL-based distributions, this information is stored in the /var/log/messages directory.

On Debian-based distributions

To find the IP address of a DHCP server on Debian-based distributions, open the terminal and run the following command:

        cat /var/log/syslog | grep -i 'dhcp'
    

The output shows the entire DHCP process and from there, you can easily determine the IP address of the DHCP server, which is 192.168.42.254 in this case.

syslog DHCP Information

On RHEL-based distributions

On RHEL-based distributions, you would need to run the below command to find the IP address of a DHCP server:

        cat /var/log/messages | grep -i 'dhcp'
    

2. Find a DHCP Server IP Address Using journalctl

The journalctl command displays logs collected by systemd. It mostly shows the same information as shown by /var/log/syslog.

To find the IP address of a DHCP server, run the journalctl command as follows:

        sudo journalctl -r | grep -m1 DHCPACK
    

The below output shows that the system has obtained the IP address from the DHCP server 192.168.80.254.

journalctl-command-1

3. Find the IP Address of a DHCP Server Using dhclient.leases

The DHCP client or dhclient maintains a list of leases granted to it by the DHCP server in the dhclient.leases file. This file contains information about the DHCP server IP along with other information. You can find this file under the /var/lib/dhcp directory.

To determine the IP address of a DHCP server from the dhclient.leases file, run the following command:

        cat /var/lib/dhcp/dhclient.leases | grep -a -m1 “dhcp-server-identifier”
    
dhclient leases file

4. Find the IP Address of a DHCP Server Using dhclient

The dhclient command allows Linux clients to obtain, release, and renew IP addresses from the DHCP server.

You can use the following dhclient command to obtain an IP address from the DHCP server:

        sudo dhclient -v 
    

This command shows the entire DHCP process and from there you can easily find the IP address of your DHCP server.

dhclient command

Finding Your DHCP Server IP Address in Linux

You can now easily find the IP address of your DHCP server using any of the above methods. Although you might not need to know it often, learning how to find the DHCP server IP address can be handy at times.

In addition to the DHCP server IP address, knowing the IP address of your router can also be helpful. Because without this information, you cannot access its web page and make any configuration changes. Luckily, it is as simple as finding the IP address of the DHCP server.