With a little configuration, you can use your pi-hole as the DNS server for your LAN, if, for example, your router isn't doing a very good job serving local names. Here's how:
Create a second dnsmasq configuration file:
% echo "addn-hosts=/etc/pihole/lan.list" | sudo tee /etc/dnsmasq.d/02-lan.conf
(that % is for whatever your system prompt is; don't type it out )
After this, create a "hosts file" for your network /etc/pihole/lan.list with the format ipaddress fqdn hostname, eg
192.168.1.40 marvin.your.lan marvin
192.168.1.41 eddie.your.lan eddie
192.168.1.42 hactar.your.lan hactar
...substituting "your.lan" for whatever you want your domain name to be.
On your DHCP server (most likely your router, though pi-hole indeed can be configured into one), you'll also need to set your search domain to whatever "your.lan" corresponds to.
Finally, restart your name server:
% sudo pihole restartdns
Additional thoughts
If all this domain name stuff confuses you, you can leave it out and live a domain-less life on your LAN.
While you certainly can serve any name, also of hosts outside of your LAN, you probably can't outsmart Netflix to play shows from outside your geographical area . Drop that thought. It's probably against their TOS and you might end up losing your Netflix account.
The dnsmasq manual page suggests the configuration option hostsdir, but this didn't work on my raspi. Possibly i was just incompetent.
With the upcoming release we add two related settings:
You can now use your Pi-hole to be your DHCP server. Name resolution will work out-of-the-box.
If you still want to use your router as DHCP server, we add two settings where you can tell your Pi-hole to send local host names to the upstream DNS servers. Set your router as first upstream DNS server and your Pi-hole should be able to resolve all host names using the knowledge of your router.
Edit: This is outdated information. This feature has been moved to Conditional Forwarding. -Dan (2020/04/15)
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. Any downsides at all to using this option?
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.
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.
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?
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.
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.
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
I tried to withelist the domain of my house but nothing.
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:
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?
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".