ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

Creating DNS Server with Ubuntu Linux - Primary DNS Server with Bind9

Updated on November 17, 2009
DNS Server with BIND9
DNS Server with BIND9

Creating Primary DNS Server with Bind9

This little tutorial will go through the steps of creating a DNS (domain name system) server on your ubuntu server machine. I recently setup a dns server to host some of my internal and public domains and found many tutorials confusing or caused problems.

For this example I will go through the steps for setting up a private domain name for a private network, the instructions will apply if you have decided to host a dns server for your domain name.

The bind9 dns server was tested on ubuntu server 8.04,8.10 and 9.04

Bind9 - Configuring Zone Files

A primary master server using Bind9 is setup to serve DNS records (groups of records referred to as zones) for a fictitious domain name which is restricted to a private network.

The first step is to boot up your ubuntu server system and ensure you have root privledges

sudo su

Once in root mode you can enter the main directory for bind9 /etc/bind

The first file you will need to modify is "named.conf.local" , this file is where we will be referencing our forward and reverse zone files for your domain names.

The below code shows the basic format for your named.conf.local file inside the /etc/bind directory. it specifies the domain which in this case is ubuntu.com, classified it as a master server and specified the location of the file which will store all information relating to that zone.

The reverse zone file is your ip address backwards e.g (192.170.68.7 becomes 68.170.192)

named.conf.local

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

Reverse Zone File

zone "68.170.192.in-addr.arpa" {
        type master;
        notify no;
        file "/etc/bind/db.192";
};

Creating the (SOA) Start of Authority Record

Db.ubuntu.com domain zone files contains all the regular DNS information for a (SOA) or Start of Authority Record which defines global parameters for the zone (domain).

The db.ubuntu.com zone file contains many different values and its important to know what each does for future reference.

name - The 'root name' of the zone. Most commonly written as @ or Origin Value.

ttl - Standard TTL values apply (range 0 to 2147483647 clarified by RFC 2181). The slave (Secondary) DNS does not use the the TTL value but various parameters defined within the SOA. set by an authoritative nameserver for a particular resource record.

name-server - Any name server that will respond authoritatively for the domain.

refresh - Signed 32 bit time value in seconds. Indicates the time when the slave will try to refresh the zone from the master

retry - Signed 32 bit value in seconds. Defines the time between retries if the slave (secondary) fails to contact the master when refresh (above) has expired. Typical values would be 180 (3 minutes) to 900 (15 minutes) or higher

expiry - Signed 32 bit value in seconds. Indicates when the zone data is no longer authoritative. Used by Slave or (Secondary) servers only.

Serial - The serial value is in the format YYYYMMDDSS for example 2009101101 , year 2009 10th month 11th day serial 01, remember the serial needs to be incremented by 1 every time a change is made in order for secondary dns server/slave to registry it.

db.ubuntu.com

$TTL    604800
@       IN      SOA     ns.ubuntu.com. root.ubuntu.com. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.ubuntu.com.
@       IN      A       192.170.68.7
box     IN      A       192.170.68.7

Apply changes in Bind9

Remember to restart the naming service whenever you make any changes to your zones using

/etc/init.d/bind9 restart

remember to be in root mode

The reverse zone file is also created with similar format to db.ubuntu.com

db.192

db.192

;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns.ubuntu.com. root.ubuntu.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.
10      IN      PTR     ns.ubuntu.com.

Testing and Troubleshooting

Once you have modified the files , named.conf.local, db.ubunt.com and db.192

and restarted the naming service /etc/init.d/bind9 restart

You can test your domain name but before you do that you should set your linux systems DNS resolvers to point to the dns server you just created on 192.170.68.7

open up the file /etc/resolv.conf using vim /etc/resolv.conf

and enter your domain name information

domain ubuntu.com

search ubuntu.com

nameserver 192.170.68.7

once the DNS resolvers have been setup inside /etc/resolv.conf

you can test your dns server using

ping ubuntu.com , dig ubuntu.com or named-checkzone ubuntu.com /etc/bind/db.ubuntu.com

Troubleshooting

For any trouble shooting problems first consult the system logs using ,

/var/log/syslog 
to check for errors otherwise feel free to ask questions or let me know if i've made any mistakes.

working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)