Setting up static IP address in host file

Hi,

I have successfully set up Pi-Hole with my Google Wifi Router pointing to Pi-Hole as the DNS provider. I would like pi-hole to return a local ip address for some domains e.g
192.168.86.10 printer
192.168.86.11 plex

Does anyone know how to setup local dns entries? i've tried to apply the above in /etc/hosts but it does not work,.

From a client connected to Pi-Hole, what is returned following this command:

nslookup printer

image

I've figured it out now that the correct file to edit would be:
/etc/pihole/local.list

AND NOT:

/etc/hosts

After editing i has to restart and it worked. EDIT: After restarting the host machine the entry was deleted so its not working.

This is how I set mine up with dnsmasq.d custom config files : Local domain persistance in Docker Pi-hole - #4 by diginc

in this case an entire wildcard domain but it doesn't have to be a whole domain. For simple single hostnames you most likely want to add in a new file specifying a custom addn-host file rather than modifying pi-hole's file directly.

1 Like

Hi @diginc,

Thanks for the reference. May i clarify where i can find " Edit the volume mounted directory / config"? I've currently installed Pihole using Docker on a Synology NAS. I can locate the Pihole /etc/dnsmasq.d/01-pihole.conf only after i enter:

sudo docker exec -it pihole bash

Can you advise a newbie like me which file i should edit and where?

Much appreciated.

It is recommended to volume map the /etc/dnsmasq.d and /etc/pihole folder from the inside of the container to your docker host (outside the container). Volumes are setup in your docker run configuration, usually with the style of <External Directory> to <Internal Directory> (dnsmasq.d). Ctrl+F Volume on this synology container knowledge base for an example of what volumes look like in synology. You want to make sure you have the following, update the synolgoy path on the left with whatever you want.

  • /some/synology/path/pihole -> /etc/pihole/
  • /some/synology/path/dnsmasq.d -> /etc/dnsmasq.d/

This helps persist any changes you make since it exists outside the conatiner & survives destroying the container and re-creating it with update image versions. Mapping the entire folder of dnsmasq.d makes it easy for you to add additional configuration files in it too. So you'd just create your new dnsmasq files in that volume mapped folder and restart the contianer.

1 Like