1

My Pi will connect to different routers. They all provide the same network with the same SSID.

Now I would like to set up the dns server of my Pi with the IP of those routers, (there's a dns server running on them). The challenge is that they don't have the same IP.

From the search that I've done I found that I need to edit /etc/dhcp/dhclient.conf and add something like:

prepend domain-name-servers

Is there a way that I can get the IP of the router and set it in this file?

EDIT: here you have the output of cat /etc/resolv.conf:

domain lan                                                       
nameserver 10.44.55.1 //my router's IP                                            
nameserver 8.8.8.8                                               
nameserver 8.8.4.4 

2 Answers2

1

If you are running a network with multiple DHCP servers you will have problems. You should have a single DHCP server.

You could run multiple DHCP servers, if you had some reason to do so (although I find it difficult to think of a reason) provided they run non-overlapping ranges.

You DO NOT need to tell the Pi which DNS server to use, your network DHCP server/s should provide the appropriate settings, including DNS (this is what DHCP is for).

Milliways
  • 62,573
  • 32
  • 113
  • 225
1

Slightly off-topic, but since it answers the question:

$ sudo cat > /etc/resolv.conf <<-"EOF"
lookup file bind
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

then

$ sudo chattr +i /etc/resolv.conf

The last bit prevents automagic modification of the resolv.conf file. Those google DNS servers are never down, never have issues with latency. dhcpcd or dhclient may complain in logfiles, just ignore that.

slm
  • 163
  • 1
  • 11
user2497
  • 681
  • 5
  • 8