Bind9 – Resolve Based on Server’s Own IP Address Requested

binddomain-name-systemnameserver

I have a bind9 DNS server with two (2) IP addresses assigned on it. Let's call them IP#1 and IP#2. I need a way to know which IP address the clients are using and respond with different results in their nslookup. I will try to explain with two examples below.

User "X" does nslookup against domainname.com with NS Server IP#1. The server should return a specific address.

User "Y" does the same nslookup against domainname.com with NS Server IP#2. The server should return a different address for him.

Any guidance on where to start looking would be a great help.

Best Answer

See bind "view" features at https://ftp.isc.org/isc/bind9/cur/9.18/doc/arm/html/reference.html#view-statement-grammar

You can match a specific zone content to a specific view and you can define a view depending on the destination IP address use, that is your server IP addresses.

view view_name [ class ] {
    match-clients { address_match_list } ;
    match-destinations { address_match_list } ;
    match-recursive-only yes_or_no ;
  [ view_option ; ... ]
  [ zone_statement ; ... ]
} ;

The view statement is a powerful feature of BIND 9 that lets a name server answer a DNS query differently depending on who is asking. It is particularly useful for implementing split DNS setups without having to run multiple servers.

Each view statement defines a view of the DNS namespace that is seen by a subset of clients. A client matches a view if its source IP address matches the address_match_list of the view’s match-clients clause, and its destination IP address matches the address_match_list of the view’s match-destinations clause.

While this feature exists and is used, note that it makes troubleshooting far more complicated, besides all problems of synchronizing data between various views. So take extra caution.