Wednesday, July 14, 2010

Ubuntu - How to set DNS server

apt-get install bind9
/etc/init.d/bind9 stop

edit 3 files.

* /etc/bind/named.conf.local
* /etc/bind/named.conf.options
* /etc/resolv.conf

create 2 files.

* /etc/bind/zones/mydomain.com.db
* /etc/bind/zones/rev.0.168.192.in-addr.arpa
--------------------------------------------------------------------------------------------

vi /etc/bind/named.conf.local

# Our domain zone

zone "abs.com.my" {
type master;
file "/etc/bind/zones/abs.com.my.db";
};

# For reverse DNS
zone "137.223.203.in-addr.arpa" {
type master;
file "/etc/bind/zones/rev.137.223.203.in-addr.arpa";
};

--------------------------------------------------------------------------------------------

vi /etc/bind/named.conf.options

options {
// directory "/var/named";
// dump-file "/var/named/data/cache_dump.db";
// statistics-file "/var/named/data/named_stats.txt";
directory "/var/cache/bind";

// If there is a firewall between you and nameservers you want
// to talk to, you might need to uncomment the query-source
// directive below. Previous versions of BIND always asked
// questions using port 53, but BIND 8.1 and later use an unprivileged
// port by default.

query-source address * port 53;

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
203.223.137.124;
};
// include "/etc/rndc.key";
// We are the master server for server.example.com


//zone "abs-mail.abs.com.my" {
// type master;
// file "abs-mail.abs.com.my";


// auth-nxdomain no; # conform to RFC1035
// listen-on-v6 { any; };
};

--------------------------------------------------------------------------------------------

vi /etc/resolv.conf

search abs.com.my
nameserver localhost
nameserver 203.223.137.126
nameserver 210.19.197.110
nameserver 203.223.137.124
nameserver 203.121.65.30

--------------------------------------------------------------------------------------------


mkdir /etc/bind/zones
vi /etc/bind/zones/mydomain.com.db
$TTL 3D
@ IN SOA abs-mail.abs.com.my. root (
2007062001
28800
3600
604800
38400
);

abs.com.my. IN NS abs-mail.abs.com.my.
abs.com.my. IN MX 10 abs-mail.abs.com.my.
abs-mail IN A 203.223.137.86

--------------------------------------------------------------------------------------------

vi /etc/bind/zones/rev.137.223.203.in-addr.arpa

$TTL 3D
@ IN SOA abs-mail.abs.com.my. root (
2007062001
28800
604800
604800
86400
)
IN NS abs-mail.abs.com.my.
86 IN PTR abs-mail.abs.com.my.


--------------------------------------------------------------------------------------------

/etc/init.d/bind9 restart

--------------------------------------------------------------------------------------------


1. go to other computers, point it's dns server to this new dns server
2. open  terminal/cmd prompt

          dig jaring.my
        ; <<>> DiG 9.6.1-P2 <<>> jaring.my
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55222 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0 ;; QUESTION SECTION: ;jaring.my. IN A ;; ANSWER SECTION: jaring.my. 359962 IN A 192.228.128.20 ;; AUTHORITY SECTION: jaring.my. 86362 IN NS NS6.jaring.my. jaring.my. 86362 IN NS NS5.jaring.my. jaring.my. 86362 IN NS dns1.jaring.my. jaring.my. 86362 IN NS dns2.jaring.my. ;; Query time: 1 msec ;; SERVER: 203.223.137.86#53(203.223.137.86) ;; WHEN: Wed Jul 14 14:25:00 2010 ;; MSG SIZE rcvd: 117


nslookup jaring.my

Server: 203.223.137.86     <-------it's using new dns server  Address: 203.223.137.86#53 Non-authoritative answer: Name: jaring.my Address: 192.228.128.20



root--- jaring.my ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9011ms
rtt min/avg/max/mdev = 186.559/295.523/416.053/68.948 ms

:~# ping jaring.my -c 10
PING jaring.my (192.228.128.20) 56(84) bytes of data.
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=1 ttl=56 time=218 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=2 ttl=56 time=358 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=3 ttl=56 time=257 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=4 ttl=56 time=383 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=5 ttl=56 time=289 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=6 ttl=56 time=186 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=7 ttl=56 time=252 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=8 ttl=56 time=286 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=9 ttl=56 time=416 ms
64 bytes from dns2.jaring.my (192.228.128.20): icmp_seq=10 ttl=56 time=307 ms


--- jaring.my ping statistics ---
10 packets transmitted, 10 received, 0% packet loss, time 9011ms
rtt min/avg/max/mdev = 186.559/295.523/416.053/68.948 ms
root@fLufyz-laptop:~# 

done.

if error, check log file at  /var/log/syslog

No comments: