Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is a follow up to this question.

I am having an issue with a Router that doesn't support hairpinning properly. See the link above for details.

Now I want to set up a local DNS server that Hosts in our LAN can use to resolve public Hostnames (usual webbrowsing... ).

Additionally I want to modify certain zones.

In our LAN we have some servers serving resources that are not available in our public dns zone.

We always have to configure our local LMHost files accordingly.

For example we have a staging installation with a new feature running on a local Webserver, and we cannot access it with the IP directly because the website runs in a named virtual host container, we have to configure LMHost file to point some domain to the local IP address.

And now we have also the Hair pinning issue.

So my question is: What software can I use? Will bind do the job? I just need to insert some A entries into the zone. As easy as possible. We have local Linux/Ubuntu servers.

share|improve this question
Bind, dnsmasq, tinydns, etc. – agy Jun 29 '11 at 23:27
up vote 2 down vote accepted

Depending on the size of you network bind may be overkill. For a smaller network you can use dnsmasq which will read a hosts file to configure the addresses. It can also be used as a DHCP server and local DNS cache.

Bind configuration can be a little difficult if you haven't done it before. If bind is not accessible from the Internet you don't need a split configuration and configuration is simpler. If not, you should implement and test a split configuration.

Once you have your DNS server configured, you will need to change the list of servers used to resolve addresses to include the server as the first server to be queried. If you use DHCP to configure IP addresses, then you may be able to push the change out when addresses are renewed. Normally, DHCP is configured to provide a list of DNS servers to be used. DHCP leases are normally renewed after half their lifetime. If you have a long lease times, it may take quite a while to push out the changes. Rebooting systems should cause them to refresh their configuration from DHCP.

share|improve this answer
worked like a charm and was set up in less than 5 minutes – The Shurrican Jun 30 '11 at 12:15

You can do this with BIND, but how depends on if the BIND server that you are going to use is already serving DNS publicly.

If it is, you'll need to use the view Statement and multiple zone files:-

view "internal" {
    match-clients {; };
    recursion yes;
    zone "" {
        type master;
        file "your-domain-internal.db";

view "external" {
  match-clients { any; };
    recursion no;
    zone "" {
        type master;
        file "your-domain-external.db";

(To save you some repetition, records common to both views could be stored in another file and $INCLUDEd in both zones.)

If it isn't (e.g., it's an internal-only server), you could just setup a zone for your domain as normal, or perhaps setup the specific hosts you need to modify as their own distinct zones so that DNS queries for other hosts will fall back to your public DNS instead of you needing to duplicate all public hosts internally.

zone "" { ... }

With all of that said, however, if you're not tied to BIND, you might want to look at something like dnsmasq instead, which supports "DNS doctoring":-

-V, --alias=[<old-ip>]|[<start-ip>-<end-ip>],<new-ip>[,<mask>]
    Modify IPv4 addresses returned from upstream nameservers; old-ip is 
    replaced by new-ip. If the optional mask is given then any address 
    which matches the masked old-ip will be re-written.

Using the IPs from your previous question, that would be as a simple as the below to modify all DNS queries matching your public IP address.

share|improve this answer

As I and joeqwerty have said before on ServerFault: What you need is "split horizon" DNS service, and there are several ways to set this up, depending in part from what softwares you are using. As you can see, there are a range of softwares that you can use for this, from Microsoft's DNS server and ISC's BIND to tinydns from djbdns.

Once you have set it up, don't forget to map in the parts of the external view of your part of the DNS namespace that you also want to exist as-is in your internal view. There are two ways to do this, too.

share|improve this answer

ubuntu server as DNS server or bind, they both support it

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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