Linux find DHCP server IP address using CLI

In Windows XP/2000/Vista/8/10 ipconfig /all command will show me DNS server and DHCP server ip address. But, how do you know DHCP server address in Linux? How do I find the IP address of my DHCP server on Linux?

The DHCP protocol allows a host to contact a central server that maintains a list of IP addresses that may be assigned on one or more subnets. A DHCP client may request an address from this pool and then use it temporarily for communication on network.

Linux find DHCP server IP address command line options

The procedure to find out your DHCP IP address in Linux is as follows:

  1. Open the terminal application
  2. Run less /var/lib/dhcp/dhclient.leases command to list your DHCP server IP address
  3. Another option is to type grep dhcp-server-identifier /var/lib/dhcp/dhclient.leases command to find the IP address of a DHCP server
  4. One can use ip r Linux command to list default route which act as the DHCP Server on most home networks

Let us see all commands and examples in details.

The dhclient.leases file

Under Linux, you need to use dhclient command to obtain and managing dhcp tasks. In order to keep track of leases across system reboots and server restarts, dhclient keeps a list of leases it has been assigned in the dhclient.leases file. On startup, after reading the dhclient.conf file, dhclient reads the dhclient.leases file to refresh its memory about what leases it has been assigned.

When a new lease is acquired, it is appended to the end of the dhclient.leases file. In order to prevent the file from becoming arbitrarily large, from time to time dhclient creates a new dhclient.leases file from its in-core lease database. The old version of the dhclient.leases file is retained under the name dhclient.leases~ until the next time dhclient rewrites the database.

Find out DHCP server IP address on Linux

Usually dhclient.leases file is located at /var/lib/dhcp3/ or /var/lib/dhcp/ directory, type the following less command/cat command/more command to view it on screen:
$ more /var/lib/dhcp/dhclient.leases
Sample outputs:

lease {
  interface "ra0";
  option subnet-mask;
  option dhcp-lease-time 86400;
  option routers;
  option dhcp-message-type 5;
  <span style='color: rgb(255, 0, 0);'>option dhcp-server-identifier <span style='color: rgb(102, 102, 204);'>;</span></span>
  option domain-name-servers,;
  option dhcp-renewal-time 43200;
  option dhcp-rebinding-time 75600;
  option host-name "vivek-desktop";
  renew 0 2007/12/9 05:17:36;
  rebind 0 2007/12/9 15:06:37;
  expire 0 2007/12/9 18:06:37;
lease {
  interface "ra0";
  option subnet-mask;
  option routers;
  option dhcp-lease-time 86400;
  option dhcp-message-type 5;
  option domain-name-servers,;
  option dhcp-server-identifier;
  option dhcp-renewal-time 43200;
  option dhcp-rebinding-time 75600;
  option host-name "vivek-desktop";
  renew 0 2007/12/9 06:11:22;
  rebind 0 2007/12/9 16:13:50;
  expire 0 2007/12/9 19:13:50;

Look for dhcp-server-identifier. In this example, my DHCP server IP address is Alternatively, you can just use grep command to get DHCP server address, enter:
grep dhcp-server-identifier /var/lib/dhcp/dhclient.leases
Linux find DHCP server IP address commands

A note about RHEL / CentOS / Fedora Linux user

Redhat and friends uses /var/lib/dhcp/dhclient.leases file:
less /var/lib/dhcp/dhclient.leases

Using the ip command or route command

Typically, on most home or small business networks, your Internet WI-FI or router acts as the DHCP server too. Hence, it is possible to type the following command to obtain default routes on Linux:
ip r
roue -n r
ip r | grep default

Sample outputs:
default via dev wlp82s0 proto dhcp metric 600
You can find your default router IP address in GUI network config tool as follows:
How to Find The IP Address Of A DHCP server on Linux


You learned how to find the DHCP server IP address on Linux using various command-line methods. The dhclient.leases file act as a DHCP client log file.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 13 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
13 comments… add one
  • Robert de Bock Dec 10, 2007 @ 15:29

    In case you don’t have a lease, you could (but it’s more work) request a lease with dhclient(8) and use tcpdump(8) to see what server answered. Use something like this in one terminal:

    # tcpdump -i eth0 port 67 or port 68

    And something like this in a second terminal:

    # dhclient eth0

    If you are lucky, dhclient will even tell you what the DHCP server is.

    Regards, Robert.

  • 🐧 nixCraft Dec 11, 2007 @ 7:54


    When you run dhclient eth0, it always show DHCP address on screen, just look for DHCPACK (no need to run tcpdump)

    dhclient ra0
    There is already a pid file /var/run/ with pid 134519120
    Internet Systems Consortium DHCP Client V3.0.5
    Copyright 2004-2006 Internet Systems Consortium.
    All rights reserved.
    For info, please visit
    Listening on LPF/ra0/00:17:9a:0a:f6:44
    Sending on   LPF/ra0/00:17:9a:0a:f6:44
    Sending on   Socket/fallback
    DHCPDISCOVER on ra0 to port 67 interval 6
    DHCPOFFER from
    DHCPREQUEST on ra0 to port 67
    DHCPACK from
    bound to -- renewal in 39175 seconds.
  • Marko Mar 17, 2008 @ 15:04

    How can I get just DHCPACK value from code(C,C++) ?

  • Marko Mar 17, 2008 @ 15:13

    I need to know just my DHCP server address value from code, so if there is some script or a neath way to do it, without parsing the dhclient.leasing file?

  • Ryan Aug 5, 2008 @ 15:29

    Run this to get just your DHCP Server name:

    cat dhclient.leases | grep dhcp-server | uniq | cut -d” ” -f5 | cut -d”;” -f1

  • Shylesh Aug 26, 2008 @ 6:17

    Mine is at

    so the server would be
    grep dhcp-server /var/lib/dhclient/dhclient-eth0.leases

  • Saurabh Nov 22, 2008 @ 17:00

    Thanks for the good post admin
    and thanks to robert for telling how to get to know the dhcp server ip when their is no leases

    my case was also same as robert explain

  • KoteswaraRao Aug 10, 2009 @ 6:27


    iam kotesh pleces data to dhcp and dns server

  • me myself and i Aug 30, 2010 @ 16:09

    ho to findmy dhcp in windows there is a command which i use it for configuremy ps3

  • Dude Jan 26, 2011 @ 12:29

    “ipconfig /all” do NOT show dhcp ip, it will only show if client is dhcp enabled or not.

  • shuhaib Apr 1, 2011 @ 15:27

    i have one divice i need that divice reset DHCP show ip

  • Gsm Jan 14, 2013 @ 18:32

    I have a Mac OS X 10.8.2 and want to install 3G, K4510-Z, USB vmb modem. I just cannot uninstall the Microsoft software, for starters.
    Also what Mac software shall l need to install and proper procedure.

  • niko Nov 6, 2014 @ 8:44

    I have been given a desktop and this question:Configure a new domain with DNS an DHCP join the client machine to the new domain.Where do I start?its urgent.your help will be much appreciated

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum