0

I have a DNS server using BIND9 on Ubuntu 18.04 server, It acts as caching DNS server as well as local resolver for local network IPs.

This server forwards to Google DNS 8.8.8.8, 8.8.4.4.

I was wondering if it's possible to forward specific DNS request let's say www.foo.bar to another DNS server say 1.1.1.1 instead.

1 Answers1

3

Use type forward zone:

zone "example.com" IN {
        type forward;
        forwarders { 192.168.1.2; 192.168.1.254; };
};

zone "1.168.192.in-addr.arpa" IN {
        type forward;
        forwarders { 192.168.1.2; 192.168.1.254; };
};

http://www.zytrax.com/books/dns/ch7/zone.html#type

Nikita Kipriyanov
  • 8,033
  • 1
  • 21
  • 39
  • The URL is the zone name ? – Ossama Nasser Oct 30 '19 at 12:50
  • You asked for redirecting "specific DNS request". You didn't ask for "URL". And, that is impossible to resolve names based on anything beyond the sole domain name (port number, path and so on). Or I don't understand what do you mean by this comment. – Nikita Kipriyanov Oct 30 '19 at 12:58
  • Allow me to rephrase, the Domain which I am trying to resolve must be the zone name? – Ossama Nasser Oct 30 '19 at 14:15
  • If you want to do this with BIND, it seems yes, the only way to "replace" one hostname resolution is to configure it as if it is a distinct zone. Other servers could do other way, for example, `dnsmasq` simply reads local `hosts` and serves them, so for it you'll only need to add another entry into `hosts `file. – Nikita Kipriyanov Oct 31 '19 at 05:52