How do I set up a LAN-wide DNS server?

13,846

Solution 1

Setup DNS on a machine, and tell the router to hand out that IP address as the DNS server as part of the DHCP config. If your router doesn't support this, then perhaps consider something a little less arse.

Solution 2

It could be my misreading of the question, but it sounds like you're trying to give out a specific address for one or two specific domains, instead of providing full external DNS lookup/caching capability to a group of hosts on your LAN. If this is the case, you accomplish this by setting up an internal-only bind server, and configure it to serve up the domains you're trying to modify as zones.

For instance, if foocorp.com generally returns an external address of 4.2.2.2 to the rest of the outside world, but for the hosts on your lan you want it to return 192.168.0.95, tell your internal-only BIND server that it owns the zone 'foocorp.com' and give it a zonefile that defines an A-record for www.foocorp.com as 192.168.0.95. When your LAN hosts query 'foocorp.com', your internal BIND server won't even bother doing an external lookup. It will just say "Ah hah, I have a zonefile for foocorp.com right here, I'm going to return data from it" instead.

HTH,

--Lee

Solution 3

dnsmasq should suit all your needs. It can act as a DNS server, taking entries from your hosts file. In addition, it can be configured as a DHCP server, so all other machines on the LAN will pick up their addresses, gateway address, and the address of your local DNS server, automatically

Share:
13,846

Related videos on Youtube

stalepretzel
Author by

stalepretzel

I like math, therefore I like computers.

Updated on September 17, 2022

Comments

  • stalepretzel
    stalepretzel almost 2 years

    I'm familiar with the trick of of editing the /etc/hosts file to direct your computer's traffic to specific IP addresses. Now, I'm looking for a LAN-wide solution. Of course, I could edit all of the computers' /etc/hosts files (manually or automatically), but that's not ideal.

    An ideal solution would involve a machine running a DNS server, and the router recognizing that as the server that takes precedence over anything that internet-wide DNS servers may offer. Or, perhaps, the router could act as the DNS server (after all, it knows how to convert computer names to IP addresses as part of DHCP). I'd prefer not to need to change any settings on the computers on the network.

    Any suggestions? I'd hope this would be pretty easy.

    • Kyone
      Kyone almost 15 years
      Which OS are you planning on using for the DNS server? Just about every OS has suitable DNS and DHCP servers available for them.
    • Atulmaharaj
      Atulmaharaj almost 15 years
      Knowing how to convert computer names to IP addresses is not part of DHCP. It's an easy mistake to make. Your router's DHCP server advertises a bunch of settings, one of which is which DNS server clients should use. Your router is likely configured to advertise itself for DNS, and runs a small caching DNS server in its firmware. So although DHCP and DNS both run on the router they are separate services and can be split to separate machines.
    • Kyone
      Kyone almost 15 years
      All I was saying is that DNS and DHCP are commonly packed together on the same system.
  • MrGigu
    MrGigu almost 15 years
    It might not be the router running the DHCP, so if it's not, change whatever is running your DHCP.