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.

We've some domain (mydom.tld) and in the svn subdomain we have the Subversion server.

This server resides in the main office, and must be accessed inside this office as well as outside it.

So, now we have to edit the /etc/hosts file each time we enter the office, and re-edit when we go outside to make it work.

I've configured the DNS server (bind9 under Ubuntu) so we can use it as I described above, but the problem is that it manages the whole mydom.tld domain, when I only want it to manage the subdomain.

Desired behavior:

  • mydom.tld -> no answer
  • asdf.mydom.tld -> no answer
  • svn.mydom.tld -> 192.168.1.X

Can someone give a solution based on the file /etc/bind/named.conf.local and similar ones?

share|improve this question

2 Answers 2

You can use the view feature of bind with this named.conf :

view "internal" {
 match-clients { 192.168.1.0/24; }; // your network
  recursion yes;
  // required zone for recursive queries
  zone "." {
   type hint;
   file "root.servers";
  };
  zone "sub.mydom.tld" {
   type master;
   // private zone file including local hosts
   file "view/master.sub.mydom.tld.internal";
  };
  // required local host domain
  zone "localhost" in{
   type master;
   file "master.localhost";
   allow-update{none;};
  };
  // localhost reverse map
  zone "0.0.127.in-addr.arpa" in{
   type master;
   file "localhost.rev";
   allow-update{none;};
  };
}; // end view

// external hosts view
view "external" {
 match-clients {"any"; }; // all other hosts
  // recursion not supported
  recursion no;
 zone "mydom.tld" {
   type master;
     // only public hosts
   file "view/master.example.com.external";
  };
}; // end view
share|improve this answer
    
Ok, so I've done what you've proposed, and my view/master.sub.mydom.tld.internal file is this: link, but doesn't work at all... –  Rubén T.F. May 15 '12 at 14:47

Getting no answer for mydom.tld is easy. I suspect what you want is for it to give the correct answer.

i.e.

Outside the office you get this:

  • mydom.tld -> 10.0.0.1
  • asdf.mydom.tld -> NXDOMAIN
  • svn.mydom.tld -> 10.0.0.2

Inside, you get this:

  • mydom.tld -> 10.0.0.1
  • asdf.mydom.tld -> NXDOMAIN
  • svn.mydom.tld -> 192.168.1.1

The easiest way I can see is to copy your production Bind config down to your Office Bind server and edit just that one entry. You could set this up in a daily cron job so that any changes to production are reflected in the office 24 hours later. (Details of this are up to you - hourly cron job, SVN checkout, etc.)

If you aren't running Bind in production or you are using a third-party service such as your registrar's DNS service, then you could use a zone transfer instead. (AXFR)

share|improve this answer
    
No, really I want to get no answer, because any DNS server (ie Google) will give a correct DNS answer. mydom.tld is a domain managed by my registrar, and I only want to manage the svn subdomain. –  Rubén T.F. May 15 '12 at 15:12
    
If your clients ask your office DNS server for mydom.tld and it gives them no answer, the clients will wait for a timeout period before going off to ask public DNS. This will cause delays whenever trying to use your domain from within your office. Giving an authoritative NXDOMAIN answer (which is probably what it's doing now.) means that the clients won't ever go off to public DNS and will assume that mydom.tld has no A records. Serving the correct answer from your office DNS is quick and works. –  Ladadadada May 15 '12 at 15:20
    
Hmmm... I get your point, any resource on how to configure AXFR?? –  Rubén T.F. May 15 '12 at 15:24

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.