HOWTO: Using pi-hole as LAN DNS server


#3

Let me add a little hint. If you manually add your local hosts to /etc/hosts it will not work as expected, because these two default entries:

127.0.0.1 localhost
127.0.1.1 pihole

break the configuration for details - the local hosts cannot be resolved. This issue should be fixed.


#4

I know this is an old post but I just stumbled upon this. This 2nd option is fantastic! I had no idea it was possible. This makes the Top Clients section so much more easily readable. :+1: Any downsides at all to using this option?


#5

Maybe.

If you have only set up one upstream DNS server (your router under one of the “Custom” fields), you’ll be fine. If you have enabled another upstream DNS server along your router (e.g. Google), this one will receive all your requests as well. Note that this could potentially be a privacy issue, if you have host names like contain plain text information or other sensible information.


#6

yeah I’ve just setup the 1 upstream provider to be my 192.168.1.1 dd-wrt router.

regarding the privacy issue, i’ve noticed that some clients request resolving local hostnames with .local anyway, so they seem to be sent often to the public upstream servers regardless of the privacy options. nothing too personally identifiable or sensitive though so i’m not majorly bothered.


#7

Adding local=/home.lan/ or local=/local/ or both to /etc/dnsmasq.d/02-pihole.conf will prevent upstream lookups for domains ending with those.


#8

I was poking around with this. Is there any negatives to adding my local servers to /etc/pihole/local.list? I know it works, but is there a down side to it?


Edit /etc/pihole/local.list through the web interface
#9

Yes, local.list is erased and re-written on each run of pihole -g, i.e. at least once per week. To possibly update changed IP addresses.
See here for the code that does this.


#10

a small update to my previous replies: i ended up switching entirely to pi-hole’s DHCP server over my router’s (DD-WRT set to DHCP forwarding mode to the pi-hole) and it’s SO much better. feels less hack-y and convoluted than the previous solution, and seems to be performing much better and more smoothly. it seems to be resolving hostnames and local addresses a lot better than dd-wrt’s own dnsmasq configuration. thanks for adding this as an option. it took me some apprehensive baby steps to make the jump but it’s a much more elegant solution to the overall package.


#11

Hello
it worked very well, thanks
I set the DNS server in the router config and all are properly resolved.
I have only one problem, the web admin pihole is blocked, he stops himself :grin:
I tried to withelist the domain of my house but nothing.

Some screen:


#12

What domain are you using to access the web interface? By default you can only use pi.hole, localhost, or the IP address.


#13

Hi, thanks for your tips but i have tried everything from the inside of machine itself and from outside (ip, fqdn etc).
The same from inside of machine whit ip, localhost, 127.0.0.1 etc:

EDIT: with “pi.hole” from inside of machine i did it! ty :slight_smile:

now i only have to understand how to have access from outside the pihole machine.


#14

You have been mislead by the fact that the blocking page will also be shown for everything that would receive an error 404 (Not Found).

In your case, the resource you have been looking for does not exist. Note that you have to go to

192.168.1.XXX/admin

Not

192.168.1.XXX

#15

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

Many thanks and sorry for bothering you


#16

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


#17

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?


#18

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.


#19

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


#20

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”.


#21

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.


#22

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

10.20.30.40 hornpidns