I am happily using an old PC as a router. Two network cards, Debian wheezy, NAT, ... everything just fine. My home network uses static IPs, which I am also happy with.

However, every box on my home network needs my provider's name servers in its own /etc/resolv.conf file for the internet to work. I thought this would be the way to go, but I notice that when using a notebook on a commercial router, the /etc/resolv.conf file gets overwritten once I dhclient to the router, and just the router's own IP address is listed, no external name servers.

I figure that (1) the only way for this to work is that the router has some way of accepting the clients' name resolving requests and passes them on to the provider's name servers and (2) this is actually a quite handy solution because it would allow me to just put my router's IP into any client's /etc/resolv.conf and not worry about telling each client my provider's name servers.

  1. Are these assumptions (1, 2) correct?

  2. Is this a feature buried in DHCP requiring my router to be a DHCP server, or would it work with static IPs, too?

  3. What do I need to configure on my router in order to enable forwarding/handling my clients' name server requests?


Your assumptions are correct. However, what you observe on a commercial router is not a feature of DHCP, but a separate program, a name server. The bind nameserver is a very common choice for nameserver. You install it on your router. Then, you reconfigure DHCP, because DHCP(d) can tell the clients which nameserver to use. To tell you how to reconfigure your dhcpd I would need to know which it is.

This is a DNS howto. Section 3 tells you how to set up bind to be a forwarding and caching nameserver. The idea is that every local client directs DNS requests at your server, which in turn does the lookup and returns the result to the client. While doing that it caches request and response so that when another client asks for the same hostname, your local nameserver can answer the question immediately without sending packet across the internet.

| improve this answer | |

Yes, (1) is correct, and it's in fact a typical configuration. Run a DNS caching proxy on your router.

For a small network with no special requirements, I recommend dnsmasq. It's small, lightweight (it's what my home router with 16 MB RAM runs) and easy to configure. Besides being a DNS caching proxy, dnsmasq can serve some static names (so you can define names for your home machines) and can also be a DHCP server should you ever want one (but you don't have to activate this feature if you don't want it).

See How to make a machine accessible from the LAN using its hostname for a Dnsmasq tutorial.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.