Static IP and DNS name?

Hi,

I was wondering if anyone could help clarify the following for me. So I set my pi with static ip and use my routers DNS ip address as per the below.

sudo nano /etc/dhcpcd.conf

#static IP configuration

interface eth0

static ip_address=192.168.1.86/24

static routers=192.168.1.254

static domain_name_servers=192.168.1.254 Question 1>> should i change this to 192.168.1.86 (local ip of pi) if pihole as normal.
Question 2>>> should i change the last line above to 127.0.0.1 if running unbound server with FTLDNS?

Please let me know.

Regards,
VP

You should have
static domain_name_servers=127.0.0.1
which is the localhost address of RaspberyPi

2 Likes

What would be the reason for this? pihole is running independent of pi, and surely pi itself has to resolve to the router dns or atleast pihole's local ip address rather than 127.0.0.1 resolver? I am just curious to know why you think it should be 127.0.0.1 is there a documentation for this?

127.0.0.1 is used locally on the pi so it goes to loopback rather than potentially a rogue IP on your network. it is considered best practice when running a local resolver such as Pi-hole. running unbound (i do the same) does not affect this as that is a Pi-hole setting

thank you for clarifying. but if i wasn't running resolver/unbound then should i use the local ip address of pi or still 127.0.0.1?

Yes the point i was trying to make is that internally on you pi you should be using the loopback interface. On all other devices you should be using your Pi's IP address

Setting your pi to use its own IP address would work however if that ip changes for some reason that breaks all of those instances rather than 127.0.0.1 which will never change

no worries it happens will remove the two ignore this posts

My Raspberry Pi runs Pihole as DHCP & DNS server, it has a static IP address 192.168.10.15. My Router also has a static IP address 192.168.10.10 where DHCP and DNS is disabled, and below is my /etc/dhcpcd.conf file:

interface eth0
static ip_address=192.168.10.15/24
static routers=192.168.10.10
static domain_name_servers=127.0.0.1

Hi - Setting 127.0.0.1 as DNS means name resolution will not work if pihole is not installed and running correct? (or some other resolver)? Should you then in that .conf file add a backup 2nd entry for DNS, ie 8.8.8.8 or something? I wonder if this is why updating pihole failed when i tried it a while back (since started from scratch with a fresh install).

thx
Brett

Strange, because i just added 1.1.1.1 as a 2nd entry, rebooted and still get:

static domain_name_servers=127.0.0.1 1.1.1.1

ping: yahoo.com: Temporary failure in name resolution