Set up Forward DNS zone on your VPS


  • VPS installed with CentOS
  • Registered domain name

1. Access the VPS via SSH

2. Install bind and dnsutils, which will allow us to use the dig command later on

Centos or Fedora: yum install bind dnsutils

Ubuntu ir Debian: apt-get install bind9 dnsutils

3. Create a DNS zone file for the domain that will use the name servers. If the domain is called, here is a sample zone file for the domain. The zone file will be called Save this zone file in /var/named. I will assume your server IP is This file will help map your domain name to the IP.

; BIND data file for
$TTL    3h
@       IN      SOA (
                          1        ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day
@       IN      NS
@       IN      NS    IN      MX      10    IN      A
ns1                     IN      A
ns2                     IN      A
www                     IN      CNAME
mail                    IN      A
ftp                     IN      CNAME

4. Whta you need for your site to go online is a forward DNS as the one we have created above. Now, Update the BIND configuration file. Note that, at this point, you should have the following file


Now, simply open the Bind configuration file using your favourite editor.

vim /etc/named.conf

Then add the following code. Remeber to change to your domain name

zone “” {

type master;

file “/var/named/”;


5. Lastly, add an IP address of a stable DNS server in your /etc/resolv.conf file. For example, if you wish to add google’s DNS server, comment our the content of /etc/resolv.conf and add the following line:


Was this article helpful?

Leave A Comment?