Install DNS Server in FreeBSD

 

Last night, i help pak cancer install DNS server for Disduk ( Dinas kependudukan).He is NOC in dinas Kependudukan. Since all server change to FreeBSD so everything must build from beginning so the DNS. i have long time not install DNS. I dont have any documentation about it also. so today i will write down step by step installing DNS server using Bind9. Just incase if I forget, i can see this manual. Oke..lets begin….

Bismillahirohmanirohim……

1. INSTALL APPLICATION

install bind94
NS1#cd /usr/ports/dns/bind94
NS1#make install clean

cd /etc/named
ee named.conf

—————-begin—————————–
options {
// Relative to the chroot directory, if any
directory “/etc/namedb”;
pid-file “/var/run/named/pid”;
dump-file “/var/dump/named_dump.db”;
statistics-file “/var/stats/named.stats”;
allow-recursion { any; }; —————-> add this line euy
allow-query { any; }; —————-> add this line euy
allow-query-cache { any; }; —————-> add this line euy
listen-on { any; }; —————-> add this line euy

———-edit this line————————————–

forward only; ——–> use this

// forwarders { —————-> disable this line
// 127.0.0.1; —————-> disable this line

};

———————–close here———————————–

and also delete unnecesary configuration or example config

move named.root original
NS1#mv named.root named.root.asli

download new named.root
NS1#wget ftp://internic.net/domain/named.root
if you cant download it, you can create manually your named.root from http://internic.net/domain/named.root

make file for zona localhost
NS1#sh make-localhost

edit file zona localhost
NS1#pwd
/usr/named/
NS1#cd master

NS1#ee localhost.rev
#—————-begin————————————-
$TTL 3600

@ IN SOA localhost. localhost. (
20070303 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.

#———————-end of file——————————

save the file.

make a zone for localhost

for the zone, we can copy file from localhost.rev to db.localhost then edit,
NS1#cp localhost.rev db.localhost
NS1#ee db.localhost

#—————-begin————————————-
$TTL 3600

@ IN SOA localhost. root.localhost. (
20070303 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS localhost.
IN A 127.0.0.1

#———————-end of file——————————

save the zone, and continue with the next step.

now, put localhost zone into named.conf

NS1#cd /etc/namedb
NS1#ee named.conf

add this line
##———-begin————-
zone “localhost” IN {

type master;

file “master/db.localhost”;

};
##————-stop———–

save the file.

***make an rndc.conf file

for the next step, makes an rndc.conf file by using rndc-confgen.
the result always different with yours.
NS1#rndc-confgen

—————–begin file———————-
# start of rndc.conf

key “rndc-key” {

algorithm hmac-md5;

secret “68p7glMULOP2NWn9oBOPSg= =”;

};

options {

default-key “rndc-key”;

default-server 127.0.0.1;

default-port 953;

};

# end of rndc.conf

# key “rndc-key” {

# algorithm hmac-md5;

# secret “68p7glMULOP2NWn9oBOPSg= =”;

# };

#

# controls {

# inet 127.0.0.1 port 953

# allow { 127.0.0.1; } keys { “rndc-key”; };

# };

————————-end of file———————

create your rndc.conf
NS1#ee rndc.conf
and put this line ( from rndc-confgen)

key “rndc-key” {

algorithm hmac-md5;

secret “68p7glMULOP2NWn9oBOPSg= =”;

};

options {

default-key “rndc-key”;

default-server 127.0.0.1;

default-port 953;

};

now, lets edit named.conf
NS1#ee named.conf
and put this line ( from rndc-confgen)

—————–begin file———————-
key “rndc-key” {

algorithm hmac-md5;

secret “68p7glMULOP2NWn9oBOPSg= =”;

};

controls {

inet 127.0.0.1 port 953

allow { 127.0.0.1; } keys { “rndc-key”; };
};

————————-end of file———————
then, save the file and run the BIND.
NS1# /usr/local/bin/named
or
NS1# /usr/sbin/named
(depends named location)

check the application already running or not,
NS1# ps ax | grep named
490 ?? Ss 15:21.76 named
64091 p0 R+ 0:00.00 grep named

oke sip. its running.
now, lets edit our dns IP in our server,
NS1#ee /etc/resolv.conf

nameserver 127.0.0.1

save it.
now, lets test it.
NS1# host localhost
localhost has address 127.0.0.1

NS1#host 127.0.0.1
1.0.0.127.in-addr.arpa domain name pointer localhost

sip. our DNS already running well.


2. MAKES zONE DOMAIN

for example, we have a domain using bohongan.net, and delegated to our dns, so we should do this step:

NS1#ee named.conf
add this line

zone “bohongan.net” {
type master;
file “master/db.bohongan”;
};

now makes file db.bohongan

NS1#ee master/db.bohongan

#—————-begin————————————-
$TTL 3600

@ IN SOA ns1.bohongan.net. admin.bohongan.net. (
20070303 ; Serial
3600 ; Refresh
900 ; Retry
3600000 ; Expire
3600 ) ; Minimum
IN NS ns1.bohongan.net.
IN NS ns2.bohongan.net.
IN MX 10 mail.bohongan.net.
IN A 123.567.89.1 —————> fill with your IP
ns1 IN A 123.567.89.1 —————> fill with your IP
mail IN A 123.567.89.1
www IN A 123.567.89.1
#———————-end of file——————————

save and restart our DNS

NS1#rndc reload

Test domain

# dig -t ns bohongan.net

; <<>> DiG 9.3.0 <<>> -t ns bohongan.net
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38978
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;bohongan.net. IN NS

;; ANSWER SECTION:
bohongan.net. 3269 IN NS ns2.bohongan.net.
bohongan.net. 3269 IN NS ns1.bohongan.net.

;; Query time: 16 msec
;; SERVER: 202.134.0.155#53(202.134.0.155)
;; WHEN: Fri Aug 11 21:22:23 2006
;; MSG SIZE rcvd: 79

if show this, its mean our domain already resolve and running. so internet already known it.

 

This entry was posted on Wednesday, February 4th, 2009 at 12:15 pm and is filed under FreeBSD. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

4 Responses to “Install DNS Server in FreeBSD”

 
  1. cancer Says:

    tengkyu so much 4 ur explaination

  2. blogging tips Says:

    nice tutorial.. thanks!

  3. ferry Says:

    gan, itu tutorial kalo saya baca installasinya pada satu mesin ya? (123.567.89.1), ga harus 2 mesin kan (ns2), soale selama ini saya berasumsi kalo install ns (bind) itu harus ada 2 mesin. trims ya.. tutor nya sangat membantu.

    regards.

  4. admin Says:

    mas ferry, tutorial yang saya tulis hanya untuk 1 DNS, jika mas ferry ingin ada 2 DNS, berarti harus di set master dan slave

Leave a Reply