HOWTO: Using pi-hole as LAN DNS server

yes, right. I can access to the admin page.

Many thanks and sorry for bothering you

No worries! We are glad if we can help :slight_smile:

1 Like

I have gone through the setup and this is what I am getting:
pi@HornPi:~ $ nslookup

server
Default server: 192.168.254.254
Address: 192.168.254.254#53
hornpidns
;; Warning: Message parser reports malformed message packet.
;; Warning: Message parser reports malformed message packet.
Server: 192.168.254.254
Address: 192.168.254.254#53

** server can't find hornpidns: NXDOMAIN

hornpi
Server: 192.168.254.254
Address: 192.168.254.254#53

Non-authoritative answer:
Name: hornpi.Home
Address: 192.168.254.1

server 192.168.254.2
Default server: 192.168.254.2
Address: 192.168.254.2#53
hornpidns
Server: 192.168.254.2
Address: 192.168.254.2#53

Name: hornpidns.Home
Address: 192.168.254.2
Name: hornpidns.Home
Address: 127.0.1.1

hornpi
Server: 192.168.254.2
Address: 192.168.254.2#53

Name: hornpi.Home
Address: 192.168.254.1

My question is why when I do a nslookup from the router (192.168.254.254) for the pi-hole system hornpidns I get the "Warning: Message parsar reports mailformed message packet" but when I do it from the pi-hole (192.168.254.2) it get the correct values?

Thats because you probably configured your upstream DNS resolving path like so:

[Clients] --> [Pi-Hole] --> [router DNS] --> [Upstream DNS could be your ISP] --> etc

The router doesnt have the DNS records your requesting and non of its upstream configured DNS servers (ISP etc) know the answer either.

The router has has the pi-hole for the DNS, the clients have the router for the DNS.

Difficult to explain as different routers do different things.
If a router serves both purposes of handing out IP details to clients via DHCP
and can resolve hostnames to IP addresses via DNS records,
they will create a new DNS record everytime a new client registers for a new IP address via DHCP.
Whenever a client asks a DHCP server for a new IP address (and other details like GW etc), the clients also advertise their own hostname so the router can create DNS records accordingly.
These are sometimes called "smart routers".
But as your hornpidns IP address is probably setup statically, eg. the IP address was not acquired via DHCP from the router, no DNS records are/where created on the router.
Some routers allow you to create DNS records manually.
So you would need to create an DNS "A-record" pointing to the IP address of your hornpidns box.
And if your network is setup for IPv6, you would also need to create an "AAA-record".

Or dont use a static IP address on Pi-Hole hornpidns and have the IP address fixed using the routers settings to fix an IP address for a particular device via the MAC address.
That way Pi-Hole hornpidns will ask your router via DHCP for an IP + DNS records will be created
and as you set a fixed MAC on the router, the same IP address will be assigned to Pi-Hole hornpidns persistently.

Or maybe putting an entry in the "/etc/hosts" file on the Pi-Hole box is sufficient eg:

10.20.30.40 hornpidns

Hi,

I set up everything as explained in the initial post (excep for the search domain in the router).

However, the name resolution only seems to work with the FQDN entries, NOT with host names alone.
In my lan.list file I have a line:
192.168.112.213 test.local test

When I "ping test.local" from a Windows machine, it resolves correctly.
When I only ping the hostname (ping test), I get:
"Ping request could not find host test. Please check the name and try again."

However, if I "nslookup test", I get:
Server: raspberrypi
Address: 192.168.112.22

Name: test
Address: 192.168.112.213

Any idea why I cant ping although nslookup works fine and what I could do?
I already restarted the Pi, flushdns, stopped the DNS Service in Windows, same issue.

Uncheck "never forward non-FQDNs" in the advanced DNS settings on the Pi-hole web interface.

That did unfortunately not resolve it.

I have not entered my router as upstream server, nor have I entered the pi-hole in my router as a DNS server.
Actually I want to use it completely stand alone.

What did "resolve" (rather work around) the issue is to enter "local" in the "Append these DNS suffixes (in order)" IPv4 settings of my client.
So it automatically adds a ".local" to all the hostnames.

At the moment I guess the issue is that a "normal" hostname resolution (like "ping test") would be done by the netbios protocol and not DNS, but I might be wrong here.

It might be an issue isolated to Win then. @Mcat12 might know more. Linux definitely uses DNS for ping as well, but - as I said - I'm not sure on the Win end of things.

Thank you for the response.

Since I m using pi-hole as my DHCP server now, the issue is resolved.

Just one thought for improvement.
When DHCP is disabled or enabled and no devices have a lease yet, the section to assign IP-addresses statically does not show up.

So I assumed at first, this was not supported and created a DNSMASQ conf file myself, only to see this option popping up in the webui after devices received their leases.

I m just saying: pi-hole is also a great DHCP server. You should feature it more prominently :smiley:

The reason why it doesn't show it is that there is nothing to be shown (not lease table) when it is not activated. However - as this was causing confusion more than once - I will change this behavior. Thanks!

See

EDIT: This feature has been merged.

2 Likes

4 posts were split to a new topic: Dnsmasq and its cache

For the noob Linux user, can you recommend an easy editor for adding network devices to a hosts file?
Do we use tabs between values in the host file like in Windows?

Thanks

You should be able to use any whitespace between the IP address and the hostname(s). You can edit it with any text editor, but you need to run it under root (administrator). You can do this by running sudo nano /etc/hosts in the terminal. To save the file, press CtrlX and click Enter a few times to confirm.

1 Like

Thank you for this line. I've had trouble resolving local hostnames and was just about to scrap pi-hole alltogether since my home network setup is a bit more complex:

  • 192.168.10.1 - Main router, only does NAT forwarding and DNS through my ISP
  • 192.168.10.99 - OpenWRT access point (actually a router but does not do any routing, all ports are in the same VLAN), provides DHCP and DNS for local hostnames (external DNS queries are forwarded to the main router) and stable services
  • 192.168.10.14 - RaspberryPi 3 on ethernet, running pi-hole and other experimental services (e.g. openhab for controlling my AC units)
  • 192.168.10.15 - RaspberryPi 3 on wifi
  • A plethora of other devices

Since I like my network being stable, I was serving DHCP option 6 (DNS server) with OpenWRT as primary and Main Router as secondary (in case OpenWRT crashes). It's the same way I configured the RaspberryPi statically and Pi-Hole in the setup menu.
Whatever I did, all requests for local hotnames (e.g. Vlad-PC) would not resolve. I hated the idea of duplicating the hosts file with whatever was configured in OpenWRT's DHCP server because it would mean maintaining two lists of devices.
It was your reply who led me to actually disable the main router DNS server from Pi-Hole config, leaving only OpenWRT as the sole DNS server.

My guess is that requests such as "mediaplayer.local" sent by my PC to Pi-Hole got forwarded to both servers, and since Main Router would reply with "no such name" and OpenWRT would reply with the IP address, Pi-Hole prefers the "no such name" reply.
Maybe this is something that can be improved in a future release of Pi-Hole?

2 posts were split to a new topic: Using Pi-hole for reverse DNS lookups