# Pihole DHCP writes to hosts file as well

**URL:** https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217
**Category:** Implemented
**Created:** [May 17, 2017, 4:40pm UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217 "2017-05-17T16:40:00Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![technicalpyro](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/technicalpyro/32/752_2.png) [@technicalpyro](https://discourse.pi-hole.net/u/technicalpyro)
#### Post date: [May 17, 2017, 4:40pm UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/1 "2017-05-17T16:40:00Z")

</div>

when a static lease is set in the DHCP portion of the admin page should be possible to write the lease to /etc/hosts as well allowing for simple adding of hostnames

---

<div class="post-metadata">

### Author: ![jacob.salmela](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jacob.salmela/32/8_2.png) [@jacob.salmela](https://discourse.pi-hole.net/u/jacob.salmela)
#### Post date: [May 19, 2017, 2:11am UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/2 "2017-05-19T02:11:16Z")

</div>

You can already set hostnames with the static leases, or am I misinterpreting your request?

 ![](https://discourse.pi-hole.net/uploads/default/original/2X/b/b29dae25befbf8a08e56a0df7c5e194586a74811.png)

---

<div class="post-metadata">

### Author: ![technicalpyro](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/technicalpyro/32/752_2.png) [@technicalpyro](https://discourse.pi-hole.net/u/technicalpyro)
#### Post date: [May 19, 2017, 2:34am UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/3 "2017-05-19T02:34:07Z")

</div>

Will test when I get home but to my knowledge this did not bring the hostnames into the webgui instead of ip's this feature request was based off of a troubleshooting thread from Reddit that I will link when not on mobile

---

<div class="post-metadata">

### Author: ![jacob.salmela](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/jacob.salmela/32/8_2.png) [@jacob.salmela](https://discourse.pi-hole.net/u/jacob.salmela)
#### Post date: [May 19, 2017, 2:36am UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/4 "2017-05-19T02:36:21Z")

</div>

Make sure you disable your router's DHCP if you use Pi-hole's otherwise clients might get an address from one or the other.

> [@How do I use Pi-hole's built in DHCP server (and why would I want to)?](https://discourse.pi-hole.net/t/how-do-i-use-pi-holes-built-in-dhcp-server-and-why-would-i-want-to/3026):
>
> Using Your Existing Router For Network-wide Ad Blocking You might not need to use Pi-hole's DHCP server: In many home environments, your router also functions as your DHCP server. In this case, you can often [set Pi-hole to be the DNS server for your network clients in the router's DHCP (or LAN) settings page](https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245), which allows all of your network clients to block ads simply by connecting to the network. Setting it up this way is also what makes Pi-hole very powerful for network-wide ad blocking. W…

---

<div class="post-metadata">

### Author: ![technicalpyro](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/technicalpyro/32/752_2.png) [@technicalpyro](https://discourse.pi-hole.net/u/technicalpyro)
#### Post date: [May 19, 2017, 2:37am UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/5 "2017-05-19T02:37:13Z")

</div>

I do not have this issue personally I just edit the hosts file myself

---

<div class="post-metadata">

### Author: ![deHakkelaar](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/dehakkelaar/32/674_2.png) [@deHakkelaar](https://discourse.pi-hole.net/u/deHakkelaar)
#### Post date: [May 19, 2017, 4:52am UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/6 "2017-05-19T04:52:51Z")

</div>

The hosts file is intended to be used by the own host itself and not to be shared by other hosts.  
The hosts file may contain entries like for example below one:

`127.0.1.1 pihole.your.domain`

Lets assume a second system tries to connect to "pihole.your.domain" reading from that same hosts file, it gets IP address "127.0.1.1" returned via DNS.  
That localhost IP address will make the other host try to connect to itself on the loopback interface instead of connecting to the intended host "pihole.your.domain".

Pi-Hole does some trickery so the hosts file can be read by dnsmasq but this file was never intended to be used by the other hosts on the network.  
See the hosts file more as a personalized map of the network from the own hosts point of view.

More complex systems have multiple hosts entries that would make no sense for the other hosts on the network when trying to resolve from host to host.  
Below an example of two different hosts files for if you might want to cluster the Pi-Hole services:

```
# /etc/hosts file for "ph-node1.your.domain"
10.0.0.10 ph-cluster.your.domain
127.0.0.1 ph-node1.your.domain
10.0.0.12 ph-node2.your domain
127.0.0.1 ph1-heartbeat.your.domain
192.168.0.2 ph2-heartbeat.your.domain

```

--

```
# /etc/hosts file for "ph-node2.your.domain"
10.0.0.10 ph-cluster.your.domain
10.0.0.11 ph-node1.your.domain
127.0.0.1 ph-node2.your domain
192.168.0.1 ph1-heartbeat.your.domain
127.0.0.1 ph2-heartbeat.your.domain

```

---

<div class="post-metadata">

### Author: ![yubiuser](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/yubiuser/32/12100_2.png) [@yubiuser](https://discourse.pi-hole.net/u/yubiuser)
#### Post date: [May 31, 2020, 9:54am UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/7 "2020-05-31T09:54:42Z")

</div>

> [@technicalpyro](#):
>
> simple adding of hostnames

Implemented in v5.0 with "Local DNS Records"

> [@technicalpyro](#):
>
> but to my knowledge this did not bring the hostnames into the webgui instead of ip’

Also implemented.

---

<div class="post-metadata">

### Author: ![technicalpyro](https://discourse-cdn.pi-hole.net/user_avatar/discourse.pi-hole.net/technicalpyro/32/752_2.png) [@technicalpyro](https://discourse.pi-hole.net/u/technicalpyro)
#### Post date: [June 1, 2020, 11:14pm UTC](https://discourse.pi-hole.net/t/pihole-dhcp-writes-to-hosts-file-as-well/3217/10 "2020-06-01T23:14:07Z")

</div>


