Create DNS server in Ubuntu version

1) Install bind9
#aptitude install update
#aptitude install bind9 dnsutils

2)Configure local Network
 #sudo nano /etc/hosts

as below

127.0.0.1       [yourhostname]   localhost.localdomain   localhost
192.168.1.x     [yourhostname].[yourdomain]              [yourhostname]
 

eg:-

 127.0.0.1       ns1 localhost.localdomain   localhost
192.168.1.2      ns1.geoffke.be              ns1


3)Configure your firewall
#sudo ufw allow 53
#sudo ufw allow bind9
 #sudo ufw app list 

4)create the zone file 


#cd /etc/bind
#sudo nano db.geoffke.be


Replace geoffke.be with your domain name to become your zone file name. Here's an example

;
; BIND zone definition file for geoffke.be
;
geoffke.be.      IN      SOA      ns1.geoffke.be. admin.geoffke.be. (
                        2011072601; Serial
                        28800
                        3600
                        604800
                        38400
)

; Nameserver and mailserver (replace with your own hostnames):
geoffke.be.        IN     NS           ns1.geoffke.be.
geoffke.be         IN     MX     10    mail.geoffke.be

; IP addresses of local hosts (replace the lines with your own hosts):
router             IN     A     192.168.1.1
ns1                IN     A     192.168.1.2
www                IN     A     192.168.1.3
mediacenter        IN     A     192.168.1.4
laptop1            IN     A     192.168.1.5
workstation1       IN     A     192.168.1.6




 5. Create the reverse zone file:

#sudo nano rev.1.168.192.in-addr.arpa

Use the following example file and replace the hosts and domain name with your own, matching the ones in the zone file above:

;
; BIND reverse zone file for geoffke.be
;
@ IN SOA ns1.geoffke.be. admin.geoffke.be. (
                        2011072601; Serial
                        28800;
                        604800;
                        604800;
                        86400
)

; IP addresses of local hosts (replace the lines with your own hosts):
        IN      NS      ns1.geoffke.be.
1       IN      PTR     router.geoffke.be
2       IN      PTR     geoffke.be
3       IN      PTR     www.geoffke.be
4       IN      PTR     mediacenter.geoffke.be
5       IN      PTR     laptop1.geoffke.be
6       IN      PTR     workstation1.geoffke.be


6. Edit the named.conf.local file:

and add the following:

zone geoffke.be {
        type master;
        file "/etc/bind/db.geoffke.be";
};

zone 1.168.192.in-addr.arpa {
        type master;
        file "/etc/bind/rev.1.168.192.in-addr.arpa";
}; 


7. Configure your clients:

domain <yourdomain.ext>
search <yourdomain.ext>
nameserver <ip_of_dns_server_1>
nameserver <ip_of_dns_server_2>
nameserver <ip_of_dns_server_3>


 If you have only one DNS server, you could use the following example:

domain geoffke.be
search geoffke.be
nameserver 192.168.1.2
nameserver 192.168.1.1


8. Test your DNS server:
Be sure that all of your hosts DNS settings on your clients point to your new DNS server before testing! Reload bind to accept the changes:

sudo service bind9 reload

Test your server with:
Source code 
dig example.com 

If your server doesn't respond correctly, you can check the logs to see what is causing the problem.
Source code
tail -f /var/log/syslog

No comments:

Post a Comment

Start and Stop ssh-agent

Below is the bash script used to start and stop ss-agent #!/bin/bash ## in .bash_profile SSHAGENT=`which ssh-agent` SSHAGENTARGS="...