Cara Seting DNS Server di Ubuntu 14.04

Farihin Muhamad
0
#1--------Before you type any other code, first you need to log on as SU:
fm@fm-vm:~$ sudo su
[sudo] password for fm:

#2--------After that update your system by typing this:
root@fm-vm:/home/fm# apt-get update

#3--------Ubuntu will check & install for updates, after finished updating then install apache2:
root@fm-vm:/home/fm# apt-get install apache2

#4--------After that install bind9:
root@fm-vm:/home/fm# apt-get install bind9

#5--------After installing bind9, now configure the ip address:
root@fm-vm:/home/fm# nano /etc/network/interfaces
#---------We will create 3 IP Address. In the nano, write down this code:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.100.1
netmask 255.255.255.0
gateway 192.168.100.1
network 192.168.100.0
broadcast 192.168.100.255
dns-nameservers 192.168.100.1
dns-search farihin.com

auto eth0:1
iface eth0:1 inet static
address 192.168.100.2
netmask 255.255.255.0
gateway 192.168.100.1
network 192.168.100.0
broadcast 192.168.100.255
dns-nameservers 192.168.100.1
dns-search forum.farihin.com

auto eth0:2
iface eth0:2 inet static
address 192.168.100.3
netmask 255.255.255.0
gateway 192.168.100.1
network 192.168.100.0
broadcast 192.168.100.255
dns-nameservers 192.168.100.1
dns-search mail.farihin.com
#---------When finished modifying, hit CTRL+X, than hit Y, then hit ENTER

#6--------After that then restart the neworking, use this command:
root@fm-vm:/home/fm# sudo ifdown eth0 && sudo ifup eth0
root@fm-vm:/home/fm# sudo ifdown eth0:1 && sudo ifup eth0:1
root@fm-vm:/home/fm# sudo ifdown eth0:2 && sudo ifup eth0:2
#7------Or use this:
root@fm-vm:/home/fm# sudo service network-manager restart
#-------Now try to ping the 3 IP’s, you have to make sure all of it REPLAY.
#-------If one of them not replay then check your configuration.
#-------If your configuration was right, then restart your Ubuntu.

#8------After doing command above, configure the host file by typing:
root@fm-vm:/home/fm# nano /etc/hosts
#-------Write down this 3 lines script right under 127.0.1.1:
192.168.100.1        farihin.com
192.168.100.2        forum.farihin.com
192.168.100.3        mail.farihin.com

#9------Now go to “/etc/bind” directories and list the files, make sure you have named.conf.local file:
root@fm-vm:/home/fm# cd /etc/bind
root@fm-vm:/etc/bind# ls
bind.keys  db.empty    named.conf.default-zones  zones.rfc1918
db.0       db.local    named.conf.local
db.127     db.root     named.conf.options

#10------We need to modify named.conf.local files, so open it with nano:
root@fm-vm:/etc/bind# nano named.conf.local
#---------Our goal is to create 3 zone for “farihin.com”, “forum.farihin.com”, and “mail.farihin.com”. On nano write this script:
//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "farihin.com" {
type master;
file "/etc/bind/db.farihin";
};

zone "forum.farihin.com" {
type master;
file "/etc/bind/db.forumfarihin";
};

zone "mail.farihin.com" {
type master;
file "/etc/bind/db.mailfarihin";
};

zone "100.168.192.in-addr.arpa" {
type master;
file "/etc/bind/db.farihin.rev";
};
#--------When finished, hit CTRL+X, than hit Y, then hit ENTER

#11-----In this stage we will create a db files that we declare on our zone. First let’s create db.farihin file. Now copy the “db.local” file to “db.yourname” file:
root@fm-vm:/etc/bind# cp db.local db.farihin
#--------Then open the “db.yourname” file with nano:
root@fm-vm:/etc/bind# nano db.farihin
#--------On nano write this script:
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     farihin.com.     root.farihin.com. (
                                   2     ; Serial
                         604800     ; Refresh
                           86400     ; Retry
                       2419200     ; Expire
                         604800 )   ; Negative Cache TTL
;
@                            IN      NS      farihin.com.
@                            IN      A       192.168.100.1

farihin.com              IN      A       192.168.100.1
forum.farihin.com    IN     A       192.168.100.2
mail.farihin.com       IN     A       192.168.100.3

#12------Second we’ll create db.farihin.rev file. Now copy “db.yourname” to “db.yourname.rev”, and open it with nano:
root@fm-vm:/etc/bind# cp db.farihin db.farihin.rev
root@fm-vm:/etc/bind# nano db.farihin.rev
#--------On nano write this script:
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     farihin.com.     root.farihin.com. (
                                    2    ; Serial
                          604800    ; Refresh
                            86400    ; Retry
                        2419200    ; Expire
                         604800 )   ; Negative Cache TTL
;
100.168.192.in-addr.arpa.      IN      NS      farihin.com.
1                                              IN      PTR     farihin.com.
2                                              IN      PTR     forum.farihin.com.
3                                              IN      PTR     mail.farihin.com.

#13-------Third, we’ll create db.forumfarihin and db.mailfarihin by copying and modifying from db.farihin’s file:
root@fm-vm:/etc/bind# cp db.farihin db.forumfarihin
root@fm-vm:/etc/bind# nano db.forumfarihin
#----------Change line 5 (SOA), line 12 (NS), line 13 (A)
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     forum.farihin.com.     root.farihin.com. (
                                   2     ; Serial
                         604800     ; Refresh
                           86400     ; Retry
                       2419200     ; Expire
                         604800 )   ; Negative Cache TTL
;
@                            IN      NS     forum.farihin.com.
@                            IN      A       192.168.100.2

farihin.com              IN      A       192.168.100.1
forum.farihin.com    IN     A       192.168.100.2
mail.farihin.com       IN     A       192.168.100.3
--------------------------------------------------------------------------------------------------------------------
root@fm-vm:/etc/bind# cp db.farihin db.mailfarihin
root@fm-vm:/etc/bind# nano db.mailfarihin
#----------Change line 5 (SOA), line 12 (NS), line 13 (A)
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     mail.farihin.com.     root.farihin.com. (
                                   2     ; Serial
                         604800     ; Refresh
                           86400     ; Retry
                       2419200     ; Expire
                         604800 )   ; Negative Cache TTL
;
@                            IN      NS     mail.farihin.com.
@                            IN      A       192.168.100.3

farihin.com              IN      A       192.168.100.1
forum.farihin.com    IN     A       192.168.100.2
mail.farihin.com       IN     A       192.168.100.3

#14-----Now configure the “resolv.conf” file by opening it with nano:
root@fm-vm:/etc/bind# nano /etc/resolv.conf
#--------On nano write this script:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
domain farihin.com
search farihin.com
nameserver 192.168.100.1

#15--------Now restart the bind9:
root@fm-vm:/etc/bind# /etc/init.d/bind9 restart

#16--------After restarting, try to ping the domain and sub-domain:
root@fm-vm:/etc/bind# ping farihin.com
PING farihin.com (192.168.100.1) 56(84) bytes of data.
64 bytes from farihin.com (192.168.100.1): icmp_seq=1 ttl=64 time=0.014 ms

root@fm-vm:/etc/bind# ping forum.farihin.com
PING forum.farihin.com (192.168.100.2) 56(84) bytes of data.
64 bytes from forum.farihin.com (192.168.100.2): icmp_seq=1 ttl=64 time=0.015 ms

root@fm-vm:/etc/bind# ping mail.farihin.com
PING mail.farihin.com (192.168.100.3) 56(84) bytes of data.
64 bytes from mail.farihin.com (192.168.100.3): icmp_seq=1 ttl=64 time=0.014 ms

#17--------And the last do the nslookup:
root@fm-vm:/etc/bind# nslookup farihin.com
Server:        192.168.100.1
Address:    192.168.100.1#53

Name:    farihin.com

Address: 192.168.100.1



#--You now finished configuring DNS Server.
#--If there is REPLAY when you doing ping then your configuration was right, if it’s not then re-check your configuration. And if nslookup give a result you’re 100% DONE.
#--Another way to test the DNS Server go to your web browser and type farihin.com OR mail.farihin.com OR forum.farihin.com on the addressbar.

Post a Comment

0Comments

Post a Comment (0)