Follow by Email

How To Setup An Interal DNS Server On Ubuntu Easiest Way | Bind9 DNS server

Bind9 is used all across the internet for DNS. Over 70% of DNS servers on the internet use Bind.
In this tutorial we will setup a Bind9 DNS server for your home network with caching.
Running a caching DNS server it will cache DNS locally so sites you visit often will not have to make a DNS query until the DNS record has expired.
This will help improve your internet speed as well as reduce bandwidth.

Before we begin make sure you have an Ubuntu server running and configured with a static IP address

Installing Bind9 on Ubuntu

Open Terminal on Ubuntu server or Login via SSH

sudo apt-get install bind9

And then type "Y" to confirm

Bind Configuration

The next step is to configure the forwards addresses for bind.

This tell bind where to look if it doesn't know the IP address of a domain.
In this example we will use Google's Public DNS servers for the forward DNS servers.
Google's DNS servers are fast, and free.
If you want you can use your ISP provider's DNS servers.

sudo nano /etc/bind/named.conf.options

then press enter
Configure Forwarders As shown is Above Picture
Exit it out of nano by hitting CTRL + X.
Enter Y to confirm saving changes.

Configuring internal domain

The next step is to edit /etc/bind/named.conf.local
In this example we will setup an internal domain with tne name linux.lix.
If you want to use something else just make sure you replace linux.lix in the following steps with your internal domain name.
The internal domain can be whatever you want.

sudo nano /etc/bind/named.conf.local

then press enter
We will need to figure out our IP address range of our internal network so we can build the correct reverse zone lookup file.

Most home networks will have a 192.168.1.X or 192.168.0.X type of IP address. In my case I have a 192.168.0.X IP address network.

When looking at our IP address the part we care about is the first three sets of octets ( = three sets 192.168.0) 

Then we just reverse them - 192.168.0 => 0.168.192

Replace linux.lix with the internal domain name you picked and replace 0.168.192  with your IP address scheme.

and make note of the names because we will need to build these files in the next few steps. 

zone "linux.lix" {
             type master;
             file "/etc/bind/db.linux.lix";

zone "" {
        type master;
        notify no;
        file "/etc/bind/db.192";

Hit CTRL + X to exit out of nano
Enter Y to confirm saving changes

Building Your DNS Forward Zone

The first file we need to build is the forward zone file (db.linux.lix)

sudo cp /etc/bind/db.local /etc/bind/db.linux.lix

This will copy default zone to our zone

Now lets Edit our Zone db.linux.lix

sudo nano /etc/bind/db.linux.lix

The three most common types of DNS records are Address (A Record), Canonical Name (CNAME), and Mail Exchanger (MX). We will focus on A Record

A Record: Defines a mapping of a hostname to an IP address. This is the most common
CNAME: Defines that the domain name is an alias of another name.
MX: Defines mail servr
NS: Name Server

Replace linux.lix with internal domain name you picked
shahid.linux.lix with your internnal domain name example - user.yourdomain.ext
Change DNSserver. to your UbuntuServer Host name and put "." in end of host name as shown in above picture.

Put " ; " in front of  like these
;@      IN      A
;@      IN      AAAA    ::1

Now Maping Domain Name to IP

@      IN       A
In my case  is My internal webserver.

Now Building Reverse Lookup

sudo cp /etc/bind/db.127 /etc/bind/db.192

This will copy default reverse lookup file to our database

Now edit the file
sudo nano /etc/bind/db.192

Replace linux.lix as with internal domain name you picked as Mention Earlier
Make sure you have a "." at the end of the names.

IN is defining it as an Internet address.
PTR is a pointer record. This defines what name will be called when an IP address is looked up.

Now lets save our reverse zone file by hitting CTRL + X
Enter "Y" to confirm saving the file.

Now Start Your DNS Server

sudo service bind9 start

Now Test The DNS server

Now open Internet Protocol Version 4 properties in Windows7 or 8 or10
located in - Control Panel\Network and Internet\Network and Sharing Center
then click on Local area Connection Status then - > properties -> Internet Protocol Version 4

And then Put your Ubuntu Server Ip address to Preferred DNS server Box and click ok

Now Open CMD in Windows

Type ping linux.lix
Now open you Browser type linux.lix in url You will get your Web server - Web Page

For Any one Who Join Your Local Area connection can get the DNS server By puttion Your Ubuntu Server IP address to your Router DNS setting

Now you Have Your own Domain Name and Server

If You Find This Helpful Share On Social Medias

How To Setup An Interal DNS Server On Ubuntu Easiest Way | Bind9 DNS server How To Setup An Interal DNS Server On Ubuntu Easiest Way | Bind9 DNS server Reviewed by Shahid on September 02, 2016 Rating: 5

No comments: