DNS server for fake domain, for internal testing usage only (on Linux)

binddomain-name-systeminternal-dnsnameservertinydns

Let's say that I have several machines (or VMs) on an internal (10.0 or 192.168 class) LAN, that need to communicate with each other, but instead of configuring a somewhat dynamic, tedious to keep updated /etc/hosts file (as new VMs get added every now and then), I'd like to set up an internal DNS server. All of my test machines and VMs are running Linux. I have some questions in this regard:

  1. Can I setup the DNS server s.t. I can use a fake domain (say "example.com" since it is reserved) as my domain as known internally in the private network ?
  2. Can I setup the DNS server s.t. the /etc/resolv.conf points to this server to resolve all the machine IP-addresses for hosts in this private / fake domain ? However, for a real / actual existing domain, the DNS server should point-to or fetch resolved IP-address from a cascaded actual DNS server (s.a. a public DNS server) ? The latter is for access to general public internet from the test machines, through a NAT-Proxy.
  3. Could I do something of this nature with say TinyDNS ? I find Bind a bit too intimidating, and perhaps an overkill for my needs ?

Best Answer

The short answer is yes and it doesn't matter whether your domain is real or fake. It's just generally a better idea to use something you own (or a sub-domain of something you own) to avoid potential problems in the future. Using a real domain you own also makes it possible to get real (publicly trusted) certificates for names in that domain without needing to stand up an internal PKI.

Just about any DNS software can support what you're trying to do. It will be acting as both an "authoritative" and "recursive" DNS server. It will be authoritative for the example.com (or whatever) zone and recursion is the piece that allows queries it is not authoritative for to get resolved from the internet.

So your clients point to only your DNS server in their resolv.conf. Queries for anything in example.com get resolved using its records. Queries for anything else will have the DNS server reach out to the internet for the answers, (likely) cache them, and return them as "non-authoritative" responses to the client.