{"id":9325,"date":"2021-08-17T13:07:14","date_gmt":"2021-08-17T13:07:14","guid":{"rendered":"https:\/\/linuxways.net\/?p=9325"},"modified":"2021-08-17T13:07:14","modified_gmt":"2021-08-17T13:07:14","slug":"how-to-find-dhcp-server-ip-address-in-linux-using-cli","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-find-dhcp-server-ip-address-in-linux-using-cli\/","title":{"rendered":"How to Find DHCP Server IP Address in Linux Using CLI"},"content":{"rendered":"<h2>What is DHCP Server?<\/h2>\n<p>A DHCP server automatically provides and allocates IP addresses and other information like subnet mask, default gateway, DNS address, etc, to client devices on the network. It enables the systems on the network to communicate with other systems effectively. Without a DHCP server, an administrator has to manually configure the IP address and other information on all devices which is not only tedious but also increases the chance of errors like IP address conflict, typographical errors, etc. DHCP assigns each device a unique IP address and it also defines how long a device can keep this IP address.<\/p>\n<p>So, that was the quick overview of the DHCP server. But do you know who your DHCP server is? Today\u2019s in this guide, we will show you how to find your DHCP server IP address in a Linux OS using the command line.<\/p>\n<h2>Finding IP address of DHCP Server<\/h2>\n<p>You can find your DHCP server\u2019s IP address from different locations. Following are some methods for finding the IP address of a DHCP server.<\/p>\n<h2>Method #1 Using the \/var\/log<\/h2>\n<p>Mostly the Linux logs are located in the \/var\/log file. When a DHCP server offers an IP address to a client, it sends a DHCPOFFER message which contains its own IP address and the IP address that is offered to the client. This message is also logged in the log file. The log files contain so much information. So in order to find only the specific information (DHCPOFFER), we will filter it out using the grep command.<\/p>\n<p>Here is the command you can use for finding the IP Address of your DHCP server using the \/var\/log:<\/p>\n<pre>$ sudo grep -IR \"DHCPOFFER\" \/var\/log\/*<\/pre>\n<p>The output below showing our DHCP server IP address that is 192.168.72.254.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1051\" height=\"112\" class=\"wp-image-9326\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-302.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-302.png 1051w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-302-300x32.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-302-1024x109.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-302-768x82.png 768w\" sizes=\"auto, (max-width: 1051px) 100vw, 1051px\" \/><\/p>\n<h2>Method #2 Using the Journalctl<\/h2>\n<p>Journalctl is used for viewing and querying logs collected by systemd. Using the journalctl command with grep, we can also find out the IP address of the DHCP server. The DHCPACK message is sent by the DHCP server to the client which contains the IP address of the DHCP server and the configuration information which the client may have requested.<\/p>\n<p>Here is the command you can use for finding the IP Address of your DHCP server using the journalctl:<\/p>\n<pre>$ sudo journalctl | grep -m1 DHCPACK<\/pre>\n<p>The output below showing our DHCP server IP address that is 192.168.72.254.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1013\" height=\"74\" class=\"wp-image-9327\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-303.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-303.png 1013w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-303-300x22.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-303-768x56.png 768w\" sizes=\"auto, (max-width: 1013px) 100vw, 1013px\" \/><\/p>\n<h2>Method #3 Using the dhclient.leases file<\/h2>\n<p><em>The <\/em>dhclient keeps a record of <em>leases<\/em> it has been assigned in the dhclient<em>.<\/em>leases file. This file also contains information about the DHCP server address.<\/p>\n<p>Here is the command you can use for finding the IP Address of your DHCP server using the dhclient<em>.<\/em>leases file:<\/p>\n<pre>$ sudo grep -m1 \"dhcp-server\" \/var\/lib\/dhcp\/dhclient.leases<\/pre>\n<p>The output below showing our DHCP server IP address that is 192.168.72.254.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"844\" height=\"77\" class=\"wp-image-9328\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-304.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-304.png 844w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-304-300x27.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-304-768x70.png 768w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/p>\n<h2>Method #4 Using the dhclient utility<\/h2>\n<p>The dhclient utility is used to configure a network interface using the DHCP protocol. Using the dhclient utility, you can release an allocated IP address and request a new one from your DHCP server. You can also use it to find your DHCP IP address; however, this will make the dhclient to go through the entire DORA process (Discover; Offer; Request; Acknowledge).<\/p>\n<p>Here is the command you can use for finding the IP Address of your DHCP server using the dhclient utility:<\/p>\n<pre>$ sudo dhclient -d -nw &lt;interface_name&gt;<\/pre>\n<p>Replace &lt;interface_name&gt; with your network interface name:<\/p>\n<pre>$ sudo dhclient -d -nw ens33<\/pre>\n<p>The output below showing our DHCP server IP address that is 192.168.72.254.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"833\" height=\"313\" class=\"wp-image-9329\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-305.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-305.png 833w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-305-300x113.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/08\/word-image-305-768x289.png 768w\" sizes=\"auto, (max-width: 833px) 100vw, 833px\" \/><\/p>\n<p>In this post, we described four different methods using which you can find the IP address of your DHCP server in a Linux system. You can also visit our post on <a href=\"https:\/\/linuxways.net\/de\/ubuntu\/how-to-configure-dhcp-in-linux\/\">installing and configuring a DHCP server on Linux.<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>What is DHCP Server? A DHCP server automatically provides and allocates IP addresses and other information like subnet mask, default gateway, DNS address, etc, to client devices on&hellip;<\/p>","protected":false},"author":1,"featured_media":9433,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,4,5,83,165,2],"tags":[80,97],"class_list":["post-9325","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-debian","category-mint","category-opensuse","category-red-hat","category-ubuntu","tag-dhcp","tag-ip-address"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=9325"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/9325\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/9433"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=9325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=9325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=9325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}