Quick Setting Bind on FreeBSD 8.1

I’m big fan of djbdns and I already write some post about djbdns and dnscache in the past.

Today, my friend ask me to install or configure bind for his FreeBSD that run 8.1 version. I ask him to follow FreeBSD manual but he said he already follow the guide but still face error.

I agree to help him set quick dns server using bind on his FreeBSD box. I think I have to test it first before give another suggestion and maybe I’ll need it in the future.

Lets get start!

Target : domain example.com will be resolved to

1. Enable bind on start up by add this line in /etc/rc.conf


2. Change a few things on /etc/namedb/named.conf

– Listen to ip

//      listen-on       {; };
listen-on       {; };

– Set forwarders to ip address of router / isp dns

forwarders {;

– Add zone for example.com

zone “example.com”{
type master;
file “/etc/namedb/master/example.com”;

3. Add zone file content (for example.com)

ee /etc/namedb/master/example.com

add fill this lines:

$TTL 3600        ; 1 hour default TTL
example.com.    IN      SOA      ns1.example.com. admin.example.com. (
2006051501      ; Serial
10800           ; Refresh
3600            ; Retry
604800          ; Expire
300             ; Negative Response TTL

; DNS Servers
IN      NS      ns1.example.com.
IN      NS      ns2.example.com.

; MX Records
IN      MX 10   mx.example.com.
IN      MX 20   mail.example.com.

IN      A

; Machine Names
localhost       IN      A
ns1             IN      A
ns2             IN      A
mx              IN      A
mail            IN      A
www             IN      A
@               IN      A

save the file.

4. Add the address to /etc/resolv.conf

echo ‘nameserver’ >> /etc/resolv.conf

5. Restart dns server

# /etc/rc.d/named restart

Stopping named.
Waiting for PIDS: 2130.
Starting named.

6. Testing resolver

# dig example.com

; <<>> DiG 9.6.2-P2 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26178
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 2

;example.com.           IN      A

example.com.    3600    IN      A

example.com.    3600    IN      NS      ns1.example.com.
example.com.    3600    IN      NS      ns2.example.com.

ns1.example.com. 3600   IN      A
ns2.example.com. 3600   IN      A

;; Query time: 0 msec
;; WHEN: Sun Jun 19 23:19:07 2011
;; MSG SIZE  rcvd: 121

Beautiful, quick and dirty way to get working dns server 🙂

Tips :

always watch /var/log/messages for error message(s).

in Unix | 391 Words