Forward DNS queries to specific Server

Sometimes you need to send certain domain names to specific servers, for example when you're connected to your works VPN and their DNS servers are too slow or you don't want them to know you're watching porn during work hours :P

It's pretty easy you just need to create a forwarder zoneā€¦

  • Install a DNS server: BIND is available on most Linux distros.
  • Set up the DNS server as Caching DNS
  • Configure the forwarding zone

To configure the forwarding zone add something like this to your /etc/named.conf file

zone "myworkzone.com" {
        type forward;
        forwarders {10.1.1.1; 10.1.1.2;};
};

Where your zone name is the top domain name that you use on your private network and forwarders has the list of the DNS servers set up by your VPN.