0

Is there a way to make bind answer some queries but forward all other queries (of the same domain) to another server, as in:

example.com A 127.0.0.1
www.example.com A 127.0.0.1

everything not on this list (example.com MX, ftp.example.com A etc) - ask 192.168.0.1 (another DNS server)

Essentially I want to intercept some (but not all) queries going to (in this example) 192.168.0.1 and answer for it.

example.com A- intercept
www.example.com - intercept
example.com MX - pass trough
ftp.example.com - pass trough

3 Answers 3

1

This is rather tricky to do with BIND. While it isn't quite what you asked have you considered using another DNS server like DNSMasq where this sort of thing is relatively simple?

1
  • Actually, DNSMasq looks like exactly what I want. Thank you
    – Pentium100
    Oct 22, 2013 at 6:07
1

Your BIND server will by default use the DNS servers in /etc/resolv.conf to resolve records that it isn't authoritative for, but only for localhost (i.e. itself) and localnets (see below). You should make sure that these are set accordingly.

Definition of localnets:

matches all the IP address(es) and subnetmasks of the server on which BIND is running. For example, if the server has a single interface with an IP address of 192.168.2.3 and a netmask of 255.255.255.0 (or 192.168.2.2/24) then localnets will match 192.168.2.0 to 192.168.2.255 and 127.0.0.1 (the loopback is always present and has a single address, that is a netmask of 255.255.255.255). Some systems do not provide a way to determine the prefix lengths of local IPv6 addresses. In such a case, localnets only matches the local IP addresses, just like localhost though in this case it will apply to external and internal (same host) requests.

You can also explicitly define global forwarders like this, remembering to secure your environment:

options {
  recursion yes;
  allow-recursion-on {
    192.168/24;
  };

  forwarders {
    8.8.8.8;
    8.8.4.4;
  };
};

If you want to direct queries for a specific domain to specific servers, you can do this by configuring forwarders for individual domains:

zone "myothernet.local" {
  type forward;
    forwarders {
      192.168.50.11;
      192.168.50.12;
    };
};

Further reading:

1
  • But can I split a domain, that is - lookup example.com locally, but ftp example.com from the other server (I'll edit the question to better explain it).
    – Pentium100
    Oct 21, 2013 at 13:08
0

I think you need subdomain delegation.. However, it is usually set up to point a specific subdomain in a zone to another server.

In your case, it might be easier to give the zone to your secondary server, set up a wildcard record in there, and set up subdomain delegation for that specific subdomain pointing to your primary server..

2
  • This was my first though as well, but the problem is that "example.com" should be answered by the primary server. Essentially I want to intercept some queries.
    – Pentium100
    Oct 21, 2013 at 13:26
  • Yeah, unfortunately wildcards are not valid in zones (although I could be mistaken) so it's hard to delegate "everything else" in that sense.
    – NickW
    Oct 21, 2013 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .