# \[ explain \] dhclient.eth0.leases file .

**URL:** https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379
**Category:** General Discussion
**Created:** [27 February 2022 19:28 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379 "2022-02-27T19:28:16Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![HattanBinNassar](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/h/2bfe46/32.png) [@HattanBinNassar](https://dietpi.com/forum/u/HattanBinNassar)
#### Post date: [27 February 2022 19:28 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/1 "2022-02-27T19:28:16Z")

</div>

Hey lovely ppl at Diet-Pi forum ! It’s me again seeking some help ,

can anyone explain for me this file ( dhclient.eth0.leases ) in var/lib/dhcp and how it’s work and the purpose of this file ?

and i have couple of questions about it :

- do this file catch dhcp infos ? " even if the device on static ip state " and i changed the dhcp server " DHCP server = router "

- is it possible to read this file as if you read the ’ interface ’ file ?

- this file have 2 parts , first one is old and the second one is updated one , the catche here both parts have identical names , can i read the second part only using ( bash ) ?

- Yeah I’m still a newbie XD

Thanks for the future answers you all !

- Shout-out to the legend " Joulinar " i know he speed ruining this forum topics and answer all of them ,

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [27 February 2022 21:23 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/2 "2022-02-27T21:23:39Z")

</div>

As you are still looking on “how to detect the DHCP server”, you might have a look to following web site [https://www.putorius.net/find-dhcp-server-ip-linux.html](https://www.putorius.net/find-dhcp-server-ip-linux.html)

basically 2 options you have

```nohighlight
journalctl | grep -m1 DHCPACK

```

or

```nohighlight
grep -m1 "dhcp-server" /var/lib/dhcp/dhclient.eth0.leases

```

Probably the first option might be best as it is independent from any file being present or not

---

<div class="post-metadata">

### Author: ![HattanBinNassar](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/h/2bfe46/32.png) [@HattanBinNassar](https://dietpi.com/forum/u/HattanBinNassar)
#### Post date: [27 February 2022 22:54 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/3 "2022-02-27T22:54:58Z")

</div>

> [@](#):
>
> As you are still looking on “how to detect the DHCP server”, you might have a look to following web site [Find DHCP Server IP Address on Linux Command Line - Putorius](https://www.putorius.net/find-dhcp-server-ip-linux.html)
> 
> basically 2 options you have
> 
> ```plaintext
> journalctl | grep -m1 DHCPACK
> 
> ```
> 
> or
> 
> ```plaintext
> grep -m1 "dhcp-server" /var/lib/dhcp/dhclient.eth0.leases
> 
> ```
> 
> Probably the first option might be best as it is independent from any file being present or not

What a great information !  
but i need my bash script to " read " from a file that contains the dhcp info ,  
Idk if " journalctl | grep -m1 DHCPACK " is capable of that ,

– i tried " journalctl | grep -m1 DHCPACK " in my putty in the command line but nothing shows up can you explain it a bit more ?

thanks a lot !

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [27 February 2022 23:07 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/4 "2022-02-27T23:07:38Z")

</div>

If there is nothing showing up, you might run a static IP? Could it be?

---

<div class="post-metadata">

### Author: ![HattanBinNassar](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/h/2bfe46/32.png) [@HattanBinNassar](https://dietpi.com/forum/u/HattanBinNassar)
#### Post date: [28 February 2022 00:24 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/5 "2022-02-28T00:24:12Z")

</div>

> [@](#):
>
> If there is nothing showing up, you might run a static IP? Could it be?

Oh , here is the problem , i want to get the dhcp info even when I’m on " Static IP " mode , is that possible tho ?

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [28 February 2022 12:12 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/6 "2022-02-28T12:12:26Z")

</div>

in this case you could try to use nmap tool

```nohighlight
nmap --script broadcast-dhcp-discover -e eth0

```

---

<div class="post-metadata">

### Author: ![HattanBinNassar](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/h/2bfe46/32.png) [@HattanBinNassar](https://dietpi.com/forum/u/HattanBinNassar)
#### Post date: [28 February 2022 14:34 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/7 "2022-02-28T14:34:42Z")

</div>

> [@](#):
>
> in this case you could try to use nmap tool
> 
> ```plaintext
> nmap --script broadcast-dhcp-discover -e eth0
> 
> ```

Nice ! ,

– 2 questions , is there a way to know if eth0 is contacted ( whether it’s have internet access or not ) like only hardware wise ?

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [28 February 2022 19:26 UTC](https://dietpi.com/forum/t/explain-dhclient-eth0-leases-file/6379/8 "2022-02-28T19:26:45Z")

</div>

We use a simple ping 9.9.9.9 to check if a device is connected to internet.
