Showing posts with label Notes on BIND. Show all posts
Showing posts with label Notes on BIND. Show all posts

Saturday, July 25, 2020

Installation and Configuration of Master and Caching DNS Server on Ubuntu 18.04 LTS (Bionic Beaver)

1.  Download and install BIND9 software

#apt-get install bind9

By default, the BIND9 software will start running after a successful installation.  If your objective is just to set up a "Caching DNS Server," then your installation is complete already and you can proceed to testing the functionality of the DNS server in Step No. 5.  The succeeding steps below will configure the BIND9 software as a "Master DNS Server".


2.  Configure file "/etc/bind/named.conf.local" by adding the following entries:

//forward
zone "rasul.ph" IN { // Domain name
     type master; // Primary DNS
     file "/etc/bind/forward.rasul.ph.db"; // Forward lookup file
     allow-update { none; }; // Since this is the primary DNS, it should be none.
};

//reverse
zone "0.16.172.in-addr.arpa" IN { //Reverse lookup name, should match your network in reverse order
     type master; // Primary DNS
     file "/etc/bind/reverse.rasul.ph.db"; //Reverse lookup file
     allow-update { none; }; //Since this is the primary DNS, it should be none.
};


3.  Create entries in the zone and reverse lookup files (Forward & Reverse)


3.1  Create the following entries in the Zone lookup file "/etc/bind/forward.rasul.ph.db"

$TTL    604800
@       IN      SOA     ns1.rasul.ph. root.rasul.ph. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
;@      IN      NS      localhost.
;@      IN      A       127.0.0.1
;@      IN      AAAA    ::1

;Name Server Information
@        IN      NS      ns1.rasul.ph.

;IP address of Name Server
ns1     IN      A       172.16.0.1

;Mail Exchanger
rasul.ph.   IN     MX   10   mail.rasul.ph.

;A – Record HostName To Ip Address

www     IN       A      172.16.0.1
mail    IN       A      172.16.0.2

clem    IN      A       172.16.0.2
mike    IN      A       172.16.0.1

rasul.ph.       IN      A       172.16.0.1

;CNAME record
;ftp     IN      CNAME   www.rasul.ph.


3.2  Create and add entries in the Reverse lookup file "/etc/bind/reverse.rasul.ph.db"

$TTL    604800
@       IN      SOA     rasul.ph. root.rasul.ph. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
;@      IN      NS      localhost.
;1.0.0  IN      PTR     localhost.

;Name Server Information

@       IN      NS     ns1.rasul.ph.

;Reverse lookup for Name Server
;1      IN      PTR    ns1.rasul.ph.

;PTR Record IP address to HostName

1     IN      PTR    www.rasul.ph.
2     IN      PTR    mail.rasul.ph.


4.  Check bind configuration syntax by issuing the command

# named-checkconf


5.  Test the DNS response from a client utility using nslookup or host as follows:


5.1  On the client computer, make changes to the name resolution resolver file "/etc/resolv.conf"

# cd /etc
# vi resolv.conf

nameserver 172.16.0.1

172.16.0.1 is the IP address of the nameserver where BIND9 is installed


5.2  Test the name resolution using nslookup

$nslookup www.rasul.ph

The response should indicate 172.16.0.1

$ nslookup 172.16.0.1

The response should indicate www.rasul.ph


5.3  Alternatively, you can also test name resolution using host command

$ host www.rasul.ph

The response should indicate 172.16.0.1

$ host 172.16.0.1

The response should indicate www.rasul.ph

At this point, your master DNS server installation is complete. 


6.  On occasions, there may be a need for you to restart, stop and start the BIND9 software.  This can be achieved by issuing the following command:

To restart the server, issue the command

# systemctl restart bind9.service


To stop the server, issue the command

# systemctl stop bind9.service


To start the server, issue the command

# systemctl start bind9.service


7.  The BIND9 software runs under the process called "named".  To see if the process is running, issue the command

# ps ax | grep named

You should be able to see the "named" process as running as follows:

11305 ?        Ssl    0:00 /usr/sbin/named -f -u bind
11313 pts/0    S+     0:00 grep --color=auto named


If the process is not running, display will just be as follows:

11219 pts/0    S+     0:00 grep --color=auto named


8.  Should there be a need for you to uninstall the BIND9 software, issue the command after stopping the BIND9 service as follows:

# systemctl stop bind9.service
# apt-get remove bind9

This will uninstall the BIND9 software.




Thursday, April 16, 2009

Installing BIND on Ubuntu

To install BIND on Ubuntu 8.10, issue the command:

#apt-get install bind9

Tuesday, February 17, 2009

Setting up a Master DNS Server

These are my notes on setting up a master DNS server. DNS is short for Domain Name System. The DNS is responsible for translating computer addresses in the form of numbers into human understandable convention like "www.google.com".

First, my system. The operating system that I am installing to is a CentOS 5.0 Linux box. If you are not familiar with the CentOS Linux distribution, CentOS is generally a "Red Hat Enterprise Product" distribution intended for production deployments without the branding and support of Red Hat. It is in many ways the same as the Red Hat Enterprise Linux product and is related to the Fedora distribution.

Setting up the master DNS server requires the following steps:

Step 1:
Download and install the BIND software. BIND is short for Berkeley Internet Name Domain. I am assuming that you are connected to the Internet. The command to do that is:


# yum install bind
# yum install bind-utils



Step 2:
Create the configuration file "named.conf" in the directory "/etc". The file "named.conf" should read as follows:



zone "0.0.127.in-addr.arpa" {
type master;
file "mylocalhost";
};

zone "bse.deped.gov.ph" {
type master;
notify no;
file "bse.deped.gov.ph";
};

zone "126.126.222.in-addr.arpa" {
type master;
notify no;
file "222.126.126";
};



Step 3:
Create the file "mylocalhost" in the directory "/var/named". The "mylocalhost" file should read as follows:



$TTL 3D
@ IN SOA ns.bse.deped.gov.ph. hostmaster.bse.deped.gov.ph. (
1 ; serial
8H ; Refresh
2H ; Retry
4W ; Expire
1D) ; Minimum TTL

NS ns.bse.deped.gov.ph.

1 PTR localhost.




Step 4:
Create the zone file for the domain like "bse.deped.gov.ph" in the directory "/var/named". The file "bse.deped.gov.ph" should read as follows:




$TTL 3D
@ IN SOA ns.bse.deped.gov.ph. hostmaster.bse.deped.gov.ph. (
19980214 ; serial
8H ; refresh
2H ; retry
4W ; expire
1D) ; minimum TTL

NS ns
MX 10 mail01.bse.deped.gov.ph.
20 mail02.bse deped.gov.ph.

localhost A 127.0.0.1
www A 222.126.126.211

ns A 222.126.126.211
mail01 A 222.126.126.211
mail02 A 222.126.126.212



Step 5:
Create the reverse domain file such as "222.126.126" in the directory "/var/named". The file "222.126.126" should read as follows:



$TTL 3D
@ IN SOA ns.bse.deped.gov.ph. hostmaster.bse.deped.gov.ph. (
19980214 ; serial
8H ; Refresh
2H ; Retry
4W ; Expire
1D ) ; Minimum TTL

NS ns.bse.deped.gov.ph.

211 PTR www.bse.deped.gov.ph.



Step 6:
Start the server as follows:



# /etc/rc.d/init.d/named start
Starting named: [ OK ]


If there are no errors proceed to the next step. If there are errors, double check on the contents of the setup files.

Step 7:
Check the name resolution functionality of your server by using the "nslookup" utility that comes with the "bind-utils" package as follows:



# nslookup www.bse.deped.gov.ph
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: www.bse.deped.gov.ph
Address: 222.126.126.211

# nslookup 222.126.126.211
Server: 127.0.0.1
Address: 127.0.0.1#53

211.126.126.222.in-addr.arpa name = www.bse.deped.gov.ph.