Linux workstation and DNS servers

Dear Readers,

I am now blessed with having a full 100% Linux laptop at work. The laptop also travels between 2-3 clients with various network settings, all with their own DNS servers.

Usually, DHCP takes care of that and you haven’t got a care in the world.

Until now …. I now have a client with a few VPN’s that can turn on / off for various tasks and all of them push DNS settings to /etc/resolv.conf which makes other domains unreachable.

So the idea popped in my head: How to have different DNS servers for different domain-names on my laptop.

The answer was extremely stupid: install your own DNS server and use 127.0.0.1 as resolving!

See the following example:

[root@laptop:/root] # cat /etc/resolv.conf
domain first.domain.com
search second.domain.com third.domain.com
nameserver 127.0.0.1
nameserver 10.0.0.1

[root@laptop:/root] # tail -50 /etc/named.conf
zone "." IN {
        type forward;
        forwarders { 10.0.0.1; };  <<<<<<<<<<<<<<< This is the DNS server that DHCP gives you.
};

zone "second.domain.com" IN {
        type forward;
        forwarders { 192.168.1.1; }; <<<<<<<<<<<< Explicitly name a nameserver for second.domain.com

};

zone "third.domain.com" IN {
        type forward;
        forwarders { 192.168.2.4;  }; <<<<<<<<<<<< Explicitly name a nameserver for third.domain.com
};

Add more domains as you like. This solution will work for as many as 8 of them, because /etc/resolv.conf only supports 8 domain names in its search options.

Of course, you can add more than 8 but then you will have to always type the FQDN for domains 9 and higher.

Mark.