You were never here, you didn't see anything..

Gentoo and caching DNS server


I recently moved my server from Slackware to Gentoo. There were several reasons for this move to which I may write something up later, however I am pleased with the results so far. Of the services my server provided, DNS for the local network was among them. I ran a caching DNS server which on Slackware is the default configuration for BIND. On Gentoo it is close to the same, only needing a few minor edits to fill the task.

The steps to get things going were rather simple. First, install BIND:

emerge -aq bind

With BIND installed a few edits tot he config file:

vim /etc/bind/named.conf

I only made two edits to the default file. Edit 1:

In the section for ‘acl “trusted”‘ I added a line for the local network:

10.2.2.0/24

And in the section for ‘options’ I told it to listen on the local network interface by adding the following right under the localhost ip:

listen-on {10.2.2.4; };

Start up the name server:

/etc/init.d/named start

Then confirm it works with a query. I used dig, which had to be installed first and is part of the “bind-tools” port:

emerge -aq bind-tools

andarius@photon : dig google.com

; <<>> DiG 9.8.1 <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5976
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 4, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             300     IN      A       74.125.45.105
google.com.             300     IN      A       74.125.45.106
google.com.             300     IN      A       74.125.45.147
google.com.             300     IN      A       74.125.45.99
google.com.             300     IN      A       74.125.45.103
google.com.             300     IN      A       74.125.45.104

;; AUTHORITY SECTION:
google.com.             172153  IN      NS      ns2.google.com.
google.com.             172153  IN      NS      ns1.google.com.
google.com.             172153  IN      NS      ns4.google.com.
google.com.             172153  IN      NS      ns3.google.com.

;; Query time: 13 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jan  2 00:59:56 2012
;; MSG SIZE  rcvd: 196

The key line to check is ";; SERVER: 127.0.0.1#53(127.0.0.1)" which is the IP (localhost in this case of course) which answered our query. As the test was successful named is added to the default run-level:

rc-update add named default

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This blog is kept spam free by WP-SpamFree.

Most who fail…

Most who fail have yet to really try!