Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am setting up two small isolated networks. Neither of these networks will have an Internet connection. I am trying to provide DNS and DHCP to both networks via a single Ubuntu server I have available, and while DHCP is working file, I have never set up BIND before.

Following the DNS Howto guide, I edited named.conf.local and told it to look for the configurations to my two domains (network1.local and network2.local) in /etc/bind/db.network1.local and db.network2.local. Btw, network1.local is on eth0, network2.local is on eth1.

I then went ahead and copied db.local to each of those two files and edited them to provide an A record for the nameserver itself, ns.network1.local.

However, I see nothing in the configuration that would prevent hosts on network1 from receiving DNS resolution for names on network2.local. What can I do to prevent this from occurring? Is there any way to bind BIND (ugh) to a single domain for each interface?

Perhaps a better question would be, should I do this? Or is there a better way of hosting two zones via each NIC? Should I use something other than BIND?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

I'm winging this off of something I set up for myself a few years ago, but you could use views to separate the domains you server. I used this so I could provide my RFC1918 addrs to my local clients and my public addresses to public clients, but I think it would work for what you want to do.

Something like this (assuming clients on network1.local are using 192.168.0.0/24 and clients on network2.local are using 192.168.1.0/24):

view "network1" {
  match-clients { 192.168.0.0/24; };
  zone "." { type hint; file "hints/named.root"; };
  zone "0.0.127.in-addr.arpa" { type master; file "zones/localhost.rev"; };
  zone "0.168.192.in-addr.arpa" { type master; file "zones/0.168.192.rev";
                       allow-transfer { 192.168.0.0/24; }; };
  zone "network1.local" { type master; file "zones/network1.local";
                       allow-transfer { 192.168.0.0/24; }; };
};


view "network2" {
  match-clients { 192.168.1.0/24; };
  zone "." { type hint; file "hints/named.root"; };
  zone "0.0.127.in-addr.arpa" { type master; file "zones/localhost.rev"; };
  zone "1.168.192.in-addr.arpa" { type master; file "zones/1.168.192.rev";
                       allow-transfer { 192.168.1.0/24; }; };
  zone "network2.local" { type master; file "zones/network2.local";
                       allow-transfer { 192.168.1.0/24; }; };
};

I can't remember if there's more to it than that but that should give you a toehold on it. Good luck.

share|improve this answer
    
This is pretty much what I was looking for, thanks! It also led me to this howto, which seems to be a simpler example of what you have: howtoforge.com/two_in_one_dns_bind9_views. +1 and accepted. –  romandas Aug 30 '11 at 13:15
    
Oh, and a comment for those who use that link I provided -- make sure all your zones are set up with views, including the localhost and rfc1918 ones. If you want to use views for some zones, you have to use them for all zones. Bind will error out if you don't. –  romandas Aug 30 '11 at 13:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.