PiHole DNS / DHCP Question

I currently have the PiHole setup as the DNS Server on my router. As a result, all requests logged in PiHole show up as coming from client 192.168.1.1//the router. If I wanted to be able to see which machine in my house actually made the request, would I need to setup each machine to use the PiHole as the DNS Server instead of just at the router level? Or if I used the PiHole as the DHCP server and let it hand out IP’s, would it then also more accurately log which machine is making the requests, or would that have no impact on that functionality since the router is still set to use the PiHole as the DNS?

1 Like

relay functionality?

2 Likes

PiHole > Settings > DNS > Advanced DNS settings

Never bothered to use it as it doesn’t bother me to much, but it might help you.

4 Likes

Various machines on your network send DNS requests to whatever DNS they have configured in their IP configuration. Whether this DNS configuration comes manually or if it comes through DHCP is up to you.

It doesn’t evening have to be on your LAN (e g. 1.1.1.1, 8.8.8.8, 9.9.9.9) would also work.

PiHole, when running as a DHCP server can serve its own IP as DNS, to clients looking to get their IP configuration over DHCP.

Some DHCP servers on routers let you override the IP that they give out… This would probably be the cleanest option. What router do you have?

3 Likes

If your router lets you set the dhcp-provided dns server, change that to the pihole ip. If not, disable dhcp on the router and use the pihole for dhcp.

4 Likes

@risk My router is a Netgear Nighthawk AX4 (RAX35).

  • @oO.o I think I miss understood what you meant and what I’m about to say will confirm that, or not, but I had already set the DNS server in the router to the IP of the PiHole - whose IP was assigned by the router acting as the DHCP server.

Fast forward to roughly an hour ago, I disabled DHCP on the router and enabled it on the PiHole instead. Before I could disable the router as the DHCP server I had to change it’s gateway IP from 192.168.1.1 to something else, I chose 192.168.10.1. Router reboots, and then I’m able to reaccess the PiHole again and enabled it as the DHCP server, giving it the new 196.168.10.1 gateway/router IP. It then starts handing out IP’s, and is showing all of the connected devices.

However, it wasn’t dishing out internet. And I could no longer access the router at the newly changed 192.168.10.1 address, or it’s previous 192.168.1.1. I turned the router off/on and when it finished rebooting it had reset itself (I hadn’t recessed reset button*). All the settings I configured were gone… SSID’s, forwarded ports, DNS server, etc. And there still was no internet. I ended up pulling power on the modem, and rebooting the router again which ended up fixing the issue with no internet.

With that said, that brief period where the PiHole was the DHCP server the queries were showing up the way I wanted… even if they weren’t reaching their destination. :slight_smile:

1 Like

I did give this a try, but that didn’t seem to do what I wanted. The client no longer showed as 192.168.1.1 for all the dns requests, but instead now showed up as routerlogin.net for some reason (routerlogin.net is a Netgear thing for accessing and configuring the router // just resolves to 192.168.1.1)

1 Like

Netgear has likely hardcoded into the router’s hosts file to return the router IP for “routerlogin.net” which is likely the value being returned when the pi-hole queries the router.

1 Like

Based on what you’ve described, your router is configured to forward dns queries to the pihole but it is telling all clients to query itself via dhcp, so you have client => router => pihole. You want the clients to query the pihole directly and for the router to stop performing any dns function whatsoever. You do this by providing the pihole ip as the dns server via dhcp. When setup properly, the router shouldn’t receive or perform any client dns lookups at all. Whether or not that config is available to you on your router, I couldn’t tell you.

As for your gateway issue, the router IPs and gateway IP shouldn’t change. You only want to disable dhcp assuming you prefer to let the pihole take care of that.

1 Like

I figured out why it wouldn’t let me disable the router as DHCP server without changing the routers IP (I don’t recall the exact error message)…

-With DNS manually set to a specific IP it wouldn’t allow me to turn off DHCP duties without changing router IP.
-Setting DNS back to the ‘Get Automatically From ISP’ I could turn off DHCP without changing router IP.

Where I’ve landed is…

  1. DHCP disabled in router, and enabled in PiHole
  2. DNS is still set to ‘Get Automatically From ISP’ in the router, but it appears PiHole is still blocking correctly.
  3. PiHole Query Log now shows the specific clients making the request like I wanted

Maybe this will make sense to those of you more network savvy than I, but one weird thing was while the router was still handling DHCP duties my work laptop was given 192.168.1.4, and I had remotely connected to that machine from my desktop. When I switched to PiHole acting as DHCP server it was showing the laptop as having 192.168.1.44 even though I was still connected to it from the 192.168.1.4 address. I just dropped the lease on .44 and manually assigned it .4.

2 Likes

This works.

That is because DNS settings is not set by the router, but by the DHCP server. Since the PiHole is now the primary DHCP server, it also sets the DNS.

Nice work.

3 Likes

If anyone else ends up here, the PiHole FAQ on their subreddit discourse page has some info on the topic:

I found this after the fact this morning.

2 Likes

You can look in your router, if it logs the DNS requests, to see which host is querying what. Alternatively, you can set your DHCP server (most likely your router) to send the Pi-Hole IP as the DNS server to be used by your clients, which is preferable anyway, since you’re introducing more DNS servers in the mix without any benefit. You don’t need to manually setup each client with a static DNS entry (your Pi-Hole IP), let the DHCP server send that information for you.

Make sure your Pi-Hole has a static DHCP entry if it doesn’t already.

Make sure that the DHCP server in the Pi-Hole either has a static DHCP entry for the router or just manually assign the IP to the router. The DHCP server has to have the default gateway to be the router’s IP address. Reserve some IPs (like 192.168.10.1 to 10.10) for manual or static DHCP IP configurations. Give the router the IP 10.1 and the Pi-Hole the IP 10.2 and default gateway 10.1. The DHCP server has to be configured to serve the default gateway as 10.1 and the DNS server 10.2.

To make it easier to comprehend, the default gateway has to be set both on the Pi-Hole’s ethernet settings and in the Pi-Hole’s DHCP server settings.

This ^

Ok, after getting to the last comment, seems like you figured it out. Still posting this, because I’ve took time to write this comment.

1 Like