Bind9 – Caching only DNS Server with Logging

Sometimes there is the need to have an forwarding only name server.

  1. named.conf
  2. /etc/resolv.conf
  3. Docker enviroments

named.conf

controls { 
    net 127.0.0.1 allow { localhost; } keys { "rndc-key"; }; 
}; 

key "rndc-key" { 
    algorithm "hmac-md5"; 
    secret "somesecret-for-rndc"; 
}; 

options { 
    directory "/etc/named.d"; 
    listen-on { 127.0.0.1; }; 
    
    max-cache-ttl 600; 
    max-ncache-ttl 300; 
    forward only; 
    forwarders { 
        <IP of SERVER1>; 
        <IP of SERVER2>; 
    }; 

    channel queries_log {
          file "/var/named/log/queries" versions 600 size 20m;
          print-time yes;
          print-category yes;
          print-severity yes;
          severity info;
     };
     channel query-errors_log {
          file "/var/named/log/query-errors" versions 5 size 20m;
          print-time yes;
          print-category yes;
          print-severity yes;
          severity dynamic;
     };

    category queries { queries_log; };
    category query-errors {query-errors_log; }
}; 

zone "." in { 
    type hint; 
    file "db.cache"; 
}; 

zone "0.0.127.in-addr.arpa" in { 
    type master; 
    file "db.127.0.0"; 
    allow-update { none; }; 
}; 

zone "localhost" in { 
    type master; 
    file "db.localhost"; 
    allow-update { none; }
};

/etc/resolv.conf

domain <localdomain> 
search <localdomain> 
nameserver 127.0.0.1 
nameserver <IP of SERVER1> 
nameserver <IP of SERVER2>

Docker enviroments

I personally would setup an docker environment with a bind9 cach server running on the host.

This would require to change the named.conf so that the containers can query the server.

options {  
    listen-on { 127.0.0.1; <IPADDRESS OF DOCKER INTERFACES>; };
}   

This would need to be reflected in the docker daemon config.

/etc/docker/daemon.json

 { "dns" : [ "<IPADDRESS OF DOCKER INTERFACES>" , "<IP of SERVER1>", "<IP of SERVER2>" ] } 

This will at least provide inside to the dns requests on container level/ip address.

One Reply to “”

Comments are closed.