How to set/Change DNS in Linux? DNS Servers Setup Guide


Everyone in the world has a first name and a last, or family, name. The same thing is true in the DNS world: A family of Web sites can be loosely defined as a domain. For example, the domain has a number of children, such as and for the Web and mail servers, respectively. There are 13 root authoritative DNS servers (super-duper authorities) that all DNS servers query first. These root servers know all the authoritative DNS servers for all the main domains – .com, .net, and the rest. This layer of servers keeps track of all the DNS servers that Web site systems administrators have assigned for their sub domains.

How to set DNS in Linux? DNS Servers Setup Guide

For example, when you register your domain, you are actually inserting a record on the .com DNS servers that point to the authoritative DNS servers you assigned for your domain. As a service, DNS is critical to the operation of the Internet. When you enter in a Web browser, it’s DNS that takes the www host name and translates it to an IP address. Without DNS, you could be connected to the Internet just fine, but you ain’t goin’ nowhere. Not unless you keep a record of the IP addresses of all of the resources you access on the Internet and use those instead of host/domain names.


There are three main reasons for which you need to set up a DNS server:

Internet Domain Support: If you have a domain name and you’re operating Web, e-mail, FTP, or other Internet servers, you’ll use a DNS server ro respond to resolution queries so others can find and access your server(s)

Local Name Resolution: Similar to the above scenario, this type of DNS server would resolve the hostnames of systems on your LAN. Typically in this scenario there is one DNS server and it does both jobs.

Internet Name Resolution: LAN workstations and other desktop PCs need to send Internet domain name resolution queries to a DNS server. The DNS server most often used for this is the ISP’s DNS servers. These are often the DNS servers you specify in your TCP/IP configuration. You can have your own DNS server respond to these resolution queries instead of using your ISP’s DNS servers.

A DNS server is just a Debian system running a DNS application. The most widely used DNS application is BIND (Berkeley Internet Name Domain) and it runs a daemon called named that, among other things, responds to resolution queries. We’ll see how to install it after we cover some basics.

Had a server run on the Windows based system (not that there are no DNS servers running such an interface but we are preferring the hard way round) it would have been pretty simple to configure the same (because of the fancy Graphical interfaces that these windows guys tend to put on everything. )but with the Linux around there is bound to be a lot of understanding and programming involved.

DNS Servers Setup Guide:

Here is our helping hand in the matter a step by step descriptive guide that helps you set up and change your DNS server:

But before going down to the steps let us try to see exactly what we are trying to do here. All the mapping in the server is done using three types of records:

An A (Address) record is a “host record” and it is the most common type. It is simply a static mapping of a hostname to an IP address. A common hostname for a Web server is ‘www’ so the A record for this server gives the IP address for this server in the domain.

An MX (Mail eXchanger) record is specifically for mail servers.

A CNAME (Canonical Name) record is an alias record. It’s a way to have the same physical server respond to two different hostnames.

NS (Name Server) records specify the authoritative DNS servers for a domain.

So after knowing all this, the only thing that you need to do is prepare a zone file for your server which will contain all these records.

Here is an example zone file to help you learn the basics:

$TTL 86400    IN     SOA \ {

2004011522     ; Serial no., based on date

21600     ; Refresh after 6 hours

3600     ; Retry after 1 hour

604800     ; Expire after 7 days

3600     ; Minimum TTL of 1 hour


;Name servers

debns1                                IN     A   IN     A

@                                     IN     NS      debns1          IN     NS

;Mail servers

debmail1                                  IN     A IN     A

@                                     IN     MX      10 debmail1          IN     MX      20

;Aliased servers

debhp                                     IN     A  IN     A

www                                   IN     CNAME   debhp      IN     CNAME

Take a note of the syntax used for the different web servers. This is not the record you need to paste in your server but you will have to prepare one similar to this for your server as well. So create a similar zone file to the one above and place it in the /var/named directory. With these configuration files in place, we have now completed the setup of the server portion of BIND and can now start the name service on the DNS server with: # /etc/rc.d/init.d/named start.

So there it is guys noe you are ready with a configures DNS server you can modify the records and follow up to modify your server settings.