# Pihole overrides hostname without being instructed to do so

**URL:** <https://discourse.pi-hole.net/t/pihole-overrides-hostname-without-being-instructed-to-do-so/63455>\
**Category:** Help\
**Created:** [June 15, 2023, 1:07pm UTC](https://discourse.pi-hole.net/t/pihole-overrides-hostname-without-being-instructed-to-do-so/63455 "2023-06-15T13:07:51Z")\
**Posts on this page:** 1\
**Showing post:** 10

<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:** [June 15, 2023, 6:49pm UTC](https://discourse.pi-hole.net/t/pihole-overrides-hostname-without-being-instructed-to-do-so/63455/10 "2023-06-15T18:49:24Z")

</div>

> [@Bucking\_Horn](#):
>
> If you are not running software on that host machine that may depend on that value, you may safely remove that `127.0.1.1 debianserver` line from your `/etc/hosts`.  
> (_This should usually be the case for headless server installations_)

Am not sure if thats recommended.  
That would mean that if processes on the own host try to lookup their own name **debianserver** , they wont be able to connect without resorting to external DNS records.  
And some use that line to configure the FQDN for the own host:

```auto
pi@ph5b:~ $ man hostname
[..]
   THE FQDN
       The FQDN (Fully Qualified Domain Name) of the system is the name
       that the resolver(3) returns for the host name, such as, ursula.ex‐
       ample.com. It is usually the hostname followed by the DNS domain
       name (the part after the first dot). You can check the FQDN using
       hostname --fqdn or the domain name using dnsdomainname.

       You cannot change the FQDN with hostname or dnsdomainname.

       The recommended method of setting the FQDN is to make the hostname
       be an alias for the fully qualified name using /etc/hosts, DNS, or
       NIS. For example, if the hostname was "ursula", one might have a
       line in /etc/hosts which reads

              127.0.1.1 ursula.example.com ursula

```

Better to just instruct embedded **dnsmasq** to not read the **hosts** file with below directive:

```auto
pi@ph5b:~ $ man dnsmasq
[..]
       -h, --no-hosts
              Don't read the hostnames in /etc/hosts.

```

EDIT: I have this one ~~disabled~~ enabled anyway bc we have local DNS records now 😉

```auto
pi@ph5a:~ $ cat /etc/dnsmasq.d/99-no-hosts.conf
no-hosts

```

EDIT2: Ow and you most likely break **sudo** :

> [@Pi-hole install script and dhcpcd.conf](https://discourse.pi-hole.net/t/pi-hole-install-script-and-dhcpcd-conf/48047/12):
>
> That is an issue with sudo and not Pi-hole. If setup a Linux host properly without Pi-hole, your suppose to provide the own hostname in both the /etc/hostname & /etc/hosts files anyway like you did. That would have probably fixed your sudo issue. The /etc/hosts file has precedence over DNS name resolution meaning a ping, curl or netcat will first look at the hosts file before forwarding an A or AAAA query to a DNS server. Thats not hacking, thats the only proper way or a variant of it (I u…

---

_[View the full topic](https://discourse.pi-hole.net/t/pihole-overrides-hostname-without-being-instructed-to-do-so/63455)._
