1

OK so here's a little problem I have: I'm trying to set up my Raspberry Pi as a DNS server (for filtering and caching). The Raspberry Pi is in my network, and has a DHCP IP from the router. The DNS server works perfectly on the Raspberry Pi (I can tell because I set my laptop's DNS server to the local IP of my Raspberry Pi)

However, now I want to set the Raspberry Pi as the DNS server on the router level, so all DHCP clients will use it as their DNS server. The trouble is, if the Raspberry Pi is inside the network, and the network has the Raspberry Pi set as the DNS server, there is no connection to the internet.

Then I thought I'd put the Raspberry Pi outside my main network, on a router that has two clients: the Raspberry Pi and my other router (the main network). However, then I wouldn't be able to access the Raspberry Pi from an IP address set by the inner (main) network.

Basically what I want is the Raspberry Pi to have an IP assigned by the DHCP server on my router (this IP is static), but I want the router to use the Raspberry Pi as it's DNS server (this would mean having the real DNS server only accessible to the Raspberry Pi, and have all other clients use the Raspberry Pi as their DNS server). My router is an Apple Airport Extreme, and I doubt it'd support anything like this (and I'm not sure if anything supports anything like this)..

Is there a way of solving this problem? Thanks

5
  • Does the RaspPi DNS server have request forwarding setup to forward unknown requests to another (external/Internet) DNS server? Jul 4, 2013 at 15:53
  • Yes it does, but I think the problem is it can't reach the external DNS server because it's behind a router that is redirecting its DNS requests to the Raspberry Pi itself Jul 4, 2013 at 20:59
  • Did you not reference the outside DNS server (for forwards) by IP address? If so, DNS doesn't play a role in that. Jul 4, 2013 at 23:32
  • Yes that's true, it is referenced by IP. That's weird. Thanks Jul 4, 2013 at 23:51
  • Weird indeed. :) Maybe your router can't use DNS from it's LAN side. Personally I'd aim to setup the Pi as a DNS server, which forwards to an external DNS server, and then setup the DHCP server to serve the Pi's LAN as address as the DNS server address for the clients, but leave the router's DNS settings to whatever the ISP supplied. Jul 4, 2013 at 23:56

3 Answers 3

1

I had similar issues because the web interface on my router is very limited (doesn't allow access to a number of feature like dhcpd.conf). I got around the issue by installing dnscrypt, which encrypts the outbound queries and forwards them to OpenDNS via port 443. It's a bit overkill for what you want but it doesn't look like you have that many options.

0

Ok thanks for all the help, I figured out what was wrong.

In the /etc/resolv.conf file, nameserver was set to the address of my router. This should have been changed to 8.8.8.8 instead, as this will automatically switch dnsmasqs standard lookup address to 8.8.8.8 – whilst still looking for any altered routes in /etc/hosts.

Works perfectly now, the only problem is when I reboot the Raspberry Pi, the resolv.conf file gets reset. If anyone knows why that's happening or how to fix it that's great, but it's no big deal since I usually only reboot it for updates

1
  • 1
    Add the following to /etc/dhcp/dhclient.conf (change 8.8.8.8 to the IP of your desired DNS server): interface "eth0" {prepend domain-name-servers 8.8.8.8;} This will list 8.8.8.8 as the first nameserver and will also include the nameservers provided by the router. If you want to not include the domains offered by the router, use "superseded" instead of "prepend". For reference, see linux.about.com/od/commands/l/blcmdl5_dhclien.htm
    – joatd
    Jul 7, 2013 at 15:07
0

In the /etc/resolv.conf file, nameserver was set to the address of my router. This should have been changed to 8.8.8.8 instead, as this will automatically switch dnsmasqs standard lookup address to 8.8.8.8 – whilst still looking for any altered routes in /etc/hosts.

Are you sure about that? Looks to me you are completely by-passing your own local nameserver and using google's instead. Can you give your machines static local IP addresses using the method?

EDIT: here is how you can tell, from DNSmasq Installation & Configuration, Google Public DNS's respond time is about 36 msec constantly. If you are using google's DNS, your DNS query will always about 36 msec. If you are using your own local nameserver, DNS Query time should be able to drop to near 1 msec. Also serving static IP for your machines is another sure sign.

I want to set the Raspberry Pi as the DNS server on the router level, so all DHCP clients will use it as their DNS server. The trouble is, if the Raspberry Pi is inside the network, and the network has the Raspberry Pi set as the DNS server, there is no connection to the internet.

My DNSmasq DHCP&DNS server is behind my DSL router, and I'm able to use it to provide DNS to my local machines, while all connections to the internet are fine. Please refer to DNSmasq Installation & Configuration for details.

Just a thought.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .