Adding new domains to DNS servers from the shell

Expertise level: Medium

This procedure is for Bind or named, two popular DNS servers.

To add a new domain, you need to edit two files related to Bind DNS server.

Adding an entry to Named.conf:

  1. Login with SSH as root.
  2. Open the file /etc/named.conf in any text editor.
  3. At the end of the file, add the zone entry for in the following format:
zone "" {
type master;
file "/var/named/";

Creating the DB Record:

/var/named/ is the path to the DB record file where you can add the Address records and MX records and all other DNS records related to

  1. Open the file /var/named/ for editing in a text editor.
  2. You can copy and paste the contents of the example below to the file (Edit each of the records according to what is needed for Replace the IP address with the  IP address)
  3. Save and exit the text editor.
  4. Type this command to reload DNS server:
rndc reload

Example of /var/named/ file:

; Zone file for
$TTL 14400   86400   IN      SOA   (
                                                2012031401 ;Serial Number
                                                86400 ;refresh
                                                7200 ;retry
                                                3600000 ;expire
                                                86400 ;minimum
        )   86400   IN      NS   86400   IN      NS   14400   IN      A

localhost       14400   IN      A   14400   IN      MX      0

mail    14400   IN      CNAME
www     14400   IN      CNAME
ftp     14400   IN      CNAME
webmail 14400   IN      A

For more information about how to manage the Bind DNS service, please consult the following links:


Article is closed for comments.
Powered by Zendesk