I am running pihole on a raspberry pi assigned to 192.168.1.250 and my router configured to use pihole as the DNS. Ads are blocked as expected for connected devices. When a new device connects to the network, it gets the DNS entry of 192.168.1.250 as expected. For example, if I look at /etc/resolv.conf on my laptop: nameserver=192.168.1.250
Before pihole, I could ssh into other machines on my LAN by using their hostnames but after pihole, all the hostnames are missing. I believe this is due to pihole not being the DNS for the LAN. Is there a simple setting to fix this?
I can "undo" this simply by editing /etc/resolv.conf on my laptop and redefining 192.168.1.1 there but of course, doing that makes pihole's adblocking non-functional for the laptop.
You can use Pi-hole for your DHCP server, which would automatically give you the hostnames. Or you could give each device a DHCP reservation in the router and assign them hostnames via the Pi-hole's /etc/hosts file.
I'm using LEDE (based on OpenWRT) on my router + a pi-hole box on the LAN together and the setup works to:
Make new DHCP clients use pihole as their DNS
Block ads via pihole
Allow for local LAN ssh connections or ping command via the advertised hostname of that device
Basically, the router advertises the pi-hole IP address but it uses its own DNS servers if the request is not blocked by the pi-hole box. Since the router’s DNS is the only upstream resolver of the pi-hole machine, both LAN and WAN hostname resolving is possible.
The pi-hole machine's IP is 192.168.1.250 for me...
On LEDE, all defaults are set except for: Network>Interfaces>LAN>edit>DHCP Server>Advanced>DHCP Options: 6,192.168.1.250
On pihole:
/etc/dnsmasq.d/01-pihole.conf
addn-hosts=/etc/pihole/gravity.list
addn-hosts=/etc/pihole/local.list
addn-hosts=/etc/pihole/black.list
...
server=192.168.1.1
Any router firmware worth its salt will allow you to define a custom dnsmasq entry. As another example, on TomatoUSB: