Hostname as "pi-hole. hostnamectl and more

Hi everyone!
I have a raspberry pi 3b working fine with pi-hole and unbound, but, when I try to change the hostame, although I get it (in fact the result of "hostname" is the fqdn I chose), when I "ping" the rasperry pi, the "ping" command return "64 bytes from pi.hole. Where do I have to change something in orden to the raspi to aswer as "raspi3b". Which is the real name it has.

Thank you in advance.

Beneath you'll find the answers to the commands I told about.

user@raspi3b:/etc/dnsmasq.d $ hostname
raspi3b.lar.jym

user@vmmint22:~$ nslookup raspi3b
Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	raspi3b.lar.jym
Address: 192.168.1.220
Name:	raspi3b.lar.jym

user@vmmint22:~$ ping raspi3b
PING raspi3b.lar.jym (192.168.1.220) 56(84) bytes of data.
64 bytes from pi.hole (192.168.1.220): icmp_seq=1 ttl=64 time=0.739 ms
64 bytes from pi.hole (192.168.1.220): icmp_seq=2 ttl=64 time=1.21 ms
64 bytes from pi.hole (192.168.1.220): icmp_seq=3 ttl=64 time=1.03 ms
64 bytes from pi.hole (192.168.1.220): icmp_seq=4 ttl=64 time=1.26 ms
^C
--- raspi3b.lar.jym ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 0.739/1.059/1.260/0.204 ms

From the pi run hostnamectl and make sure that the static hostname is set to what you want, then check /etc/hosts and make sure that its properly named there as well.

Checkout the PIHOLE_PTR= setting below:

https://docs.pi-hole.net/ftldns/configfile/

Also I would not recommend to configure a FQDN as a hostname.
You can supply the Pi with a static FQDN via the /etc/hosts file instead eg:

$ cat /etc/hostname
ph5b
$ cat /etc/hosts
127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

#127.0.1.1              raspberrypi
127.0.1.1      ph5b.home.dehakkelaar.nl  ph5b
$ hostname
ph5b
$ hostname -f
ph5b.home.dehakkelaar.nl
$ dnsdomainname
home.dehakkelaar.nl

See below:

$ 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.example.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

Thank you for your answer. Yes. I did it, but I am still getting the same result.

Thank you for your complete answer. I have checked everything you are telling me and the result of the commands you told me is:

$ cat /etc/hostname
raspi3b

$ cat /etc/hosts
127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

127.0.1.1	raspi3b.lar.jym raspi3b

$ hostname
raspi3b

$ hostname -f
raspi3b.lar.jym

$ dnsdomainname
lar.jym

The file /etc/pihole/pihole-FTL.conf is:

PRIVACYLEVEL=0
RATE_LIMIT=1000/60
PIHOLE_PTR=raspi3b

But the "ping" result from a different pc is the same. I have rebooted raspi after having done the changes...

ping raspi3b
PING raspi3b.lar.jym (192.168.1.15) 56(84) bytes of data.
64 bytes from pi.hole (192.168.1.15): icmp_seq=1 ttl=64 time=0.592 ms
64 bytes from pi.hole (192.168.1.15): icmp_seq=2 ttl=64 time=0.604 ms
64 bytes from pi.hole (192.168.1.15): icmp_seq=3 ttl=64 time=0.675 ms

I have no idea what to do next.
Thank you again for your help.

Both your nslookup as well as your ping for raspi3b succeed, so I don't quite get what your issue is?

Note that raspi3b is not valid.
Only allowed value is one of PI.HOLE, HOSTNAME, HOSTNAMEFQDN, NONE.

1 Like

Hi Buckking_Horn. I would like to know why if I have everything configured rightly, the answer to the ping is from pi.hole and not from raspi3b which is its real? name.
I just like to know the origin of things in order to be able to help other people afterwards.
By the way, Merry Christmas!!!!

It comes from a reverse DNS lookup (PTR query) which the ping command performs:

Similar as below on a client of mine (10.0.0.2 is my pi.hole):

$ nslookup 10.0.0.2
2.0.0.10.in-addr.arpa   name = pi.hole.

Dont need to.
Run below one when you make any configuration changes:

pihole restartdns

Below how is done with the upcoming v6 release:

dehakkelaar@ph6c:~$ pihole-FTL --config dns.piholePTR
PI.HOLE
dehakkelaar@ph6c:~$ nslookup $(hostname -I) localhost
7.0.0.10.in-addr.arpa   name = pi.hole.
dehakkelaar@ph6c:~$ sudo pihole-FTL --config dns.piholePTR 'HOSTNAMEFQDN'
HOSTNAMEFQDN
dehakkelaar@ph6c:~$ nslookup $(hostname -I) localhost
7.0.0.10.in-addr.arpa   name = ph6c.home.dehakkelaar.nl.

EDIT: Oh above is an IPv4 only system so hostname -I only returns a single IP :wink:

Ok. Thank you for the info. So I will have to wait until v6 to come in order to change that. (I have tried it in current version and it did not work.. lol). Thank you again.

Did you follow the instructions for the HOSTNAMEFQDN option?

Note about HOSTNAMEFQDN: If no local suffix has been defined, FTL appends the local domain .no_fqdn_available. In this case you should either add domain=whatever.com to a custom config file inside /etc/dnsmasq.d/ (to set whatever.com as local domain) or use domain=# which will try to derive the local domain from /etc/resolv.conf (or whatever is set with resolv-file, when multiple search directives exist, the first one is used).

Version 5:

$ sudo nano /etc/pihole/pihole-FTL.conf
PRIVACYLEVEL=0
RATE_LIMIT=1000/60
PIHOLE_PTR=HOSTNAMEFQDN
$ sudo nano /etc/dnsmasq.d/99-my-settings.conf
domain=home.dehakkelaar.nl
$ pihole restartdns
  [✓] Restarting DNS server
$ nslookup 10.0.0.4 10.0.0.4
4.0.0.10.in-addr.arpa   name = ph5b.home.dehakkelaar.nl.