Salah satu aplikasi DNS server yang mudah kita pelajari adalah BIND. Tutorial cara installasi pun beragam ada yang sangat lengkap bahkan mungkin sudah level advanced. Tulisan saya kali ini mencoba memberikan installasi dan konfigurasi yang masih sangat dasar sekali agar mudah di ikuti dan di pahami.
Install DNS
Langkah pertama yang dilakukan adalah melakukan installasi paket BIND apabila belum terinstall di CentOS
yum -y install bind bind-utils
Setup BIND
Setelah installasi selesai, sebelum melakukan konfigurasi, lakukan backup file konfigurasi bind terlebih dahulu:
cp /etc/named.conf /etc/named.conf.default
Rubah isi file named.conf
vi /etc/named.conf
Rubah beberapa konfigurasi seperti berikut dan tambahkan konfigurasi domain yang hendak menggunakan DNS server. Disini saya mencontohkan domain linboxs.net
// // named.conf // // Provided by Red Hat bind package to configure the ISC BIND named(8) DNS // server as a caching only nameserver (as a localhost DNS resolver only). // // See /usr/share/doc/bind*/sample/ for example named configuration files. // options { # listen-on port 53 { 127.0.0.1; }; # listen-on-v6 port 53 { ::1; }; listen-on-v6 {None;}; directory "/var/named"; dump-file "/var/named/data/cache_dump.db"; statistics-file "/var/named/data/named_stats.txt"; memstatistics-file "/var/named/data/named_mem_stats.txt"; allow-query { any; }; recursion yes; dnssec-enable yes; dnssec-validation yes; dnssec-lookaside auto; /* Path to ISC DLV key */ bindkeys-file "/etc/named.iscdlv.key"; managed-keys-directory "/var/named/dynamic"; }; logging { channel default_debug { file "data/named.run"; severity dynamic; }; }; zone "." IN { type hint; file "named.ca"; }; zone "linboxs.net" IN { type master; file "linboxs.net"; allow-update {none;}; }; include "/etc/named.rfc1912.zones"; include "/etc/named.root.key";
Ini adalah tambahan konfigurasi untuk domain linboxs.net
zone "linboxs.net" IN { type master; file "linboxs.net"; allow-update {none;}; };
Setiap domain yang ada di DNS maka harus dibuat file forward zone seperti berikut:
vi /var/named/linboxs.net
Isi dari file forward zone untuk domain linboxs.net:
$TTL 86400 @ IN SOA ns1.linboxs.net. root.linboxs.net. ( 2013042201 ;Serial 3600 ;Refresh 1800 ;Retry 604800 ;Expire 86400 ;Minimum TTL ) ; Specify our two nameservers IN NS ns1.linboxs.net. ; Resolve nameserver hostnames to IP, replace with your two droplet IP addresses. ns1 IN A 192.168.1.112 ; Define hostname -> IP pairs which you wish to resolve @ IN A 192.168.1.112 @ IN MX 10 mail.linboxs.net. www IN A 192.168.1.112 mail IN A 192.168.1.112
Simpan isi file di atas, kemudian start service bind:
/etc/init.d/named start
Set agar services start otomatis pada saat booting
chkconfig named on
Agar dapat mengenali domain linboxs.net, maka tambahkan nameserver server DNS di dalam file berikut:
vi /etc/resolv.conf
Isi resolv.conf:
nameserver 192.168.1.112
Lakukan pengecekan menggukan perintah nslookup
nslookup linboxs.net
Server: 192.168.1.112 Address: 192.168.1.112#53 Name: linboxs.net Address: 192.168.1.112
Lakukan pengecekan menggunakan perintah dig
# dig linboxs.net ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> linboxs.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44907 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1 ;; QUESTION SECTION: ;linboxs.net. IN A ;; ANSWER SECTION: linboxs.net. 86400 IN A 192.168.1.112 ;; AUTHORITY SECTION: linboxs.net. 86400 IN NS ns1.linboxs.net. ;; ADDITIONAL SECTION: ns1.linboxs.net. 86400 IN A 192.168.1.112 ;; Query time: 1 msec ;; SERVER: 192.168.1.112#53(192.168.1.112) ;; WHEN: Wed Mar 5 10:39:47 2014 ;; MSG SIZE rcvd: 81
Lakukan pengecekan menggunakan perintah ping
# ping linboxs.net PING linboxs.net (192.168.1.112) 56(84) bytes of data. 64 bytes from linboxs.net (192.168.1.112): icmp_seq=1 ttl=64 time=0.045 ms 64 bytes from linboxs.net (192.168.1.112): icmp_seq=2 ttl=64 time=0.058 ms 64 bytes from linboxs.net (192.168.1.112): icmp_seq=3 ttl=64 time=0.078 ms ^C --- linboxs.net ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2557ms rtt min/avg/max/mdev = 0.045/0.060/0.078/0.015 ms
Jreng jreng… Server nya sudah bisa dimanfaatkan sebagai DNS server 😀
Sekian, semoga bermanfaat.
Salam,
Linboxs