Router not resolving pi-hole hostname

So I've installed pi-hole in my debian 10 server. Everything good but my router can't resolve the server hostname. On my router connected devices the server doesn't have its hostname (debianserver) but "computer" and now is "computer-2". I think my router give it a standard name because it can't find the hostname. I can't disable DHCP on my router so pi-hole is not doing DHCP server. I set static ip 192.168.1.100 and this are the outputs

/etc/dhcpcd.conf

interface enp3s0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=127.0.0.1

/etc/hostname

debianserver

/etc/hosts

127.0.0.1 localhost
192.168.1.100 debianserver

I can get to pi-hole admin page using 192.168.1.100/admin from other computers, but I would like to know what is the problem because it's all day that I'm trying and I'm learning linux.
Thanks

EDIT
So I changed /etc/network/interfaces from

iface enp3s0 inet static
address 192.168.1.100/24
gateway 192.168.1.1
hostname debianserver

to

iface enp3s0 inet dhcp

Now "debianserver" is back on thr router connected devices page but I can't reach any site on my macbook using pihole ip.
I switched back to static and now everything is working, debianserver is still in the router connected devices page and I can connect to pihole admin page using server/admin on my macbook.
Anyway I will add an entry to /etc/hosts on my macbook so I'm sure I will always reach "debianserver".

I don't understand if the static ip is set using /etc/dhcpcd.conf or /etc/network/interfaces.
Linux is complicated :grimacing:

Below applies to the routers DHCP service as well:

As the Pi-hole host is set with a static IP address (not acquired via DHCP), it wont be able to advertise its hostname to the router which usually happens during the DHCP process when a client connects.

Change it back or else might break dhcpcd5:

pi@noads:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
[..]
iface eth0 inet manual
[..]

I would say live with it ... or find a way to hack the /etc/hosts file on the router.
Is it that important to know actual hostname on the router ?
How many times a year do you really depend on this info :wink:

It's not important but I was trying to understand why the hostname wasn't there. I like to understand how things works.
I found a workaround, I can't turn off DHCP on my router but I can select the range.
So this are the DHCP setting in the router:

From 192.168.1.100 (Pi-hole IP)
To 192.168.1.100
Static dhcp lease on 192.168.1.100
router ip 192.168.1.1

So the router can't assign any IP to new hosts. Since it can give only 1 IP but it's already reserved.
I enabled the DHCP server on pihole and set this range:

From 192.168.1.2
To 192.168.1.99
Gateway 192.168.1.1

Now I can't see hostnames on router but I can see them on pihole and all host can ping hostname in the network because they have pihole IP as DNS .

I understood that but why my macbook, using pihole IP as its DNS server, couldn't resolve the hostname "debianserver"? The request went from my macbook to my pihole and it should now that debianserver resolve to itself.

I don't understand if have to change to manual, now I have static.

mattia@server:~$ cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp3s0
iface enp3s0 inet static
	address 192.168.1.100/24
	gateway 192.168.1.1
	hostname debianserver
#	# dns-* options are implemented by the resolvconf package, if installed
#	dns-nameservers 127.0.0.1
#	dns-search station

I don't have the following comments like in your pi. (I don't have a raspberry)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

I think that raspberry uses dhcpcd.conf to set static ip and debian /etc/network/interfaces

EDIT:
Ok is more complicated.

And from documentation

Pi-hole needs a static IP address to properly function (a DHCP reservation is just fine). Users may run into issues because we currently install dhcpcd5 , which may conflict with other running network managers such as dhclient , dhcpcd , networkmanager , and systemd-networkd .
As part of our install process, we append some lines to /etc/dhcpcd.conf in order to statically assign an IP address , so take note of this prior to installing.

So I don't remeber if edited dhcpcd.conf or pihole installation did.

Can you post results for below two on the Macbook:

nslookup debianserver 192.168.1.100

nslookup debianserver

And on Pihole:

hostname -f

cat /etc/hosts

cat /etc/pihole/local.list

If you have dhcpcd5 installed that comes with Pi-hole:

pi@noads:~ $ apt policy dhcpcd5
dhcpcd5:
  Installed: 1:6.11.5-1+rpt7
  Candidate: 1:6.11.5-1+rpt7

And active:

pi@noads:~ $ sudo service dhcpcd5 status
[..]
   Active: active (running) since Sun 2019-09-08 22:28:43 CEST; 1 weeks 0 days ago
[..]

IP settings belong in /etc/dhcpcd.conf:

pi@noads:~ $ tail /etc/dhcpcd.conf
[..]
interface eth0
  static ip_address=10.0.0.2/24
  static routers=10.0.0.1
  static domain_name_servers=127.0.0.1

And /etc/network/interfaces should resemble below:

pi@noads:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

[~] $ nslookup debianserver 192.168.1.100

Server: 192.168.1.100

Address: 192.168.1.100#53

Name: debianserver.station

Address: 192.168.1.100

[~] $ nslookup debianserver

Server: 192.168.1.100

Address: 192.168.1.100#53

Name: debianserver.station

Address: 192.168.1.100

mattia@server : ~ $ hostname -f

debianserver.station

mattia@server : ~ $ cat /etc/hosts

127.0.0.1 localhost

192.168.1.100 debianserver

# The following lines are desirable for IPv6 capable hosts

1 localhost ip6-localhost ip6-loopback

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

mattia@server : ~ $ cat /etc/pihole/local.list

192.168.1.100 debianserver

192.168.1.100 pi.hole

mattia@server:~$ apt policy dhcpcd5
dhcpcd5:
Installed: 7.1.0-2
Candidate: 7.1.0-2
Version table:
*** 7.1.0-2 500
500 Index of /debian buster/main amd64 Packages
100 /var/lib/dpkg/status

mattia@server : ~ $ sudo service dhcpcd5 status

Unit dhcpcd5.service could not be found.

mattia@server : ~ $ systemctl status dhcpcd5

Unit dhcpcd5.service could not be found.

It seems the Mac is resolving debianserver as expected now right ?

And you dont have dhcpcd5 active so yes, put the IP details in /etc/network/interfaces if no other network manager/mangler is active.

EDIT: just to be sure, not active with below one either right ?

sudo service dhcpcd status

yes, probably because now the pihole is the DHCP server.

So if it isn't using settings inside /etc/dhcpcd.conf, the DNS are read using in resolv.conf?

mattia@server : ~ $ cat /etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)

# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

nameserver 127.0.0.1

The DHCP part has little to do with DNS resolution except maybe that its one binary pihole-FTL doing both.

With dhcpcd active, IP details need to be only in /etc/dhcpcd.conf as said before:

dhcpcd5 hooks resolvconf which in turn populates /etc/resolv.conf

If you reboot to create fresh logs, you can see what dhcpcd5 did at boot with below one:

journalctl -u dhcpcd

1 Like

I set to manual like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp3s0
iface enp3s0 inet manual
# address 192.168.1.100/24
# gateway 192.168.1.1
# hostname server
# dns-* options are implemented by the resolvconf package, if installed
# dns-nameservers 127.0.0.1
# dns-search station

But is bad. Even on macbook website are not working and on server apt-get update was stuck. Switched back to static and everything works. I'll leave it static :joy:

Should have checked what went wrong:

journalctl -u dhcpcd

But if works, dont touch !!!

:wink:

But now using debianserver/admin in chrome = This site can’t be reached.

nslookup debianserver
Server: 192.168.1.100
Address: 192.168.1.100#53
Name: debianserver
Address: 192.168.1.100

ping debianserver
ping: cannot resolve debianserver: Unknown host

:man_shrugging:

Could be cache.
Try reboot the client.

Nothing. Nevermind I go to sleep. Thanks for the help

1 Like

I found that I can ping debianserver by adding a dot at the end. :sweat_smile:

→ [~] $ ping debianserver.
PING debianserver (192.168.1.100): 56 data bytes
64 bytes from 192.168.1.100: icmp_seq=0 ttl=64 time=2.531 ms
64 bytes from 192.168.1.100: icmp_seq=1 ttl=64 time=8.920 ms

Not sure if will fix but find out your DNS suffix on the router:

image

With your Win10 PC you can figure out suffix with ipconfig:

C:\>ipconfig /all
[..]
Ethernet adapter Local Area Connection:

   Connection-specific DNS Suffix  . : dehakkelaar.nl
[..]

EDIT: Oops sorry, was confusing this thread with another ... if the client is a Mac, hostname -f should display the full name including suffix.

And change the hostname on the Pi-hole box accordingly including the suffix:

pi@noads:~ $ hostname -f
noads

pi@noads:~ $ sudo hostnamectl set-hostname noads.dehakkelaar.nl
pi@noads:~ $

pi@noads:~ $ hostname -f
noads.dehakkelaar.nl

EDIT2: one more when changing hostname on Pihole, also make sure its reflected in below file:

pi@noads:~ $ cat /etc/hosts
[..]
127.0.1.1       noads.dehakkelaar.nl
[..]

You also might need to run below and select repair to let Pi-hole know of the change:

pihole -r

Below some links I DuckDucked explaining the trailing dot:

http://www.dns-sd.org/TrailingDotsInDomainNames.html

1 Like

Not entirely clear who is doing what now:

Did you manage to have Pi-hole doing DHCP now instead of the router ?

1 Like

Yes pihole is DHCP.

And finally :smiley:, I think 127.0.1.1 line in /etc/hosts fixed the problem.


1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.