I plan on standardizing host naming conventions and want to setup an "internal" network to allow easy communication between different servers. We purchase servers from multiple different dedicated server providers that aren't physically connected to the same local network. Currently when configuring web servers etc. we use each machines IP address. I wish to replace this with hostnames like "db1-fr.internalnet" to simplify things and to make things easily understandable. What is the best way to handle Name resolution on each machine? I'm currently planning on just plonking entries in the hosts file for each server however maintainability-wise this seems pretty low on the scale. I want to try and avoid hosting a full blown DNS server simply for internal network lookups but if that is the recommended way it is certainly an option. My next question would then be, where is the appropriate place to configure this DNS server? If I replace the server wide DNS servers things will start to break. Is there a certain config file for local lookups?
1 Answers
if your happy to use a production domain then you could run DNSMasq on your internal network and have all your servers use it as there caching resolver
this has 2 benefits
- Speed Up DNS resolution accross your internal network due to caching results locally
- Ability to use DNSMasq's alias config command to change DNS results on the fly
to give a bit more info about point 2 above from the dnsmasq example config:
# If you want to fix up DNS results from upstream servers, use the
# alias option. This only works for IPv4.
# This alias makes a result of 1.2.3.4 appear as 5.6.7.8
#alias=1.2.3.4,5.6.7.8
# and this maps 1.2.3.x to 5.6.7.x
#alias=1.2.3.0,5.6.7.0,255.255.255.0
# and this maps 192.168.0.10->192.168.0.40 to 10.0.0.10->10.0.0.40
#alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0
basically this means that if you ever do a DNS lookup for an address that normally returns IP 1.2.3.4 in DNS it will rewrite it on the fly to return 5.6.7.8
replace that for your external IP to internal IP mapping and then your on to a winner
the alternative if you want to use an "internal only zone" would again be to use DNSmasq and the hosts file on the dnsmasq server to define your internal DNS records, dnsmasq uses your hosts file and its configured external resolvers to return DNS results to its clients (with hosts file taking priority by default) just like if you were to add the records to the hosts file on each box but only having to do it in a single location
Just remember to reload/restart dnsmasq when you make changes to the hosts file on that machine
![](../../users/profiles/70426.webp)
- 3,983
- 2
- 20
- 24
-
And what would be the recommended way to set it up? As the primary DNS server on each machine? What if the machine goes down, how would each machine "fallback"? – jduncanator Jan 30 '14 at 06:09
-
can set it up however you like - most internal networks generally only have 1 resolver anyway.... you can offer it via DHCP or manually configure it per machine. if you want failback just setup a second dnsmasq instance with an identical config – anthonysomerset Jan 30 '14 at 11:35