How To Pointing Domain To Server

This tutorial will show you how to pointing The Domain Name you have purchased to your Virtual or Dedicated hosting server. We’ll be using Bind9 which is a free DNS management software available for most Operating System including Unix-based OS.

Step One — Installing BIND9

To install BIND9, type this command on your SSH console

sudo apt-get install bind9 dnsutils

After successfully installing BIND9 and DNSutils, start BIND9 service by inserting this command:

sudo service bind9 start

You’ll see this message

* Starting domain name service... bind9      [OK]

Step Two — BIND9 Configuration

So you have installed BIND9 on your server. It is time to show you a basic configuration how to setup your domain to resolve to your server. Here’s what I did. Type following command then hit Enter on your keyboard:

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

Nano editor screen will appear. Type the codes below to the named.conf.local

zone "domain.com"{
    typemaster;
    file"/etc/bind/zones/master/db.nonsensecreativity.com";
};
zone "0.168.192.in-addr.arpa"{
    typemaster;
    file"/etc/bind/zones/master/rev.0.168.192.in-addr.arpa";
};

Again, in any command in this page you’ll need to replace “nonsensecreativity.com” with your own domain name and corresponding TLD.

Also, you have to replace 0.168.192 with Reverse IP address of your server. If your IP address is 162.234.199.225 then it will be  225.199.234.in-addr.arpa, without the first part.

After editing the file, hit CTRL+X to close and Y to save.

Now, we will need to create two files which we already defined in the /etc/bind/named.conf.local/ which are

/etc/bind/zones/master/db.nonsensecreativity.com
/etc/bind/zones/master/rev.0.168.192.in-addr.arpa

First, the zones/master directory may not exists in your server, so you’ll need to create the directory first with this command:

sudo mkdir /etc/bind/zones/master

Once you created the directory, create a new file with nano editor.

sudo nano /etc/bind/zones/master/db.nonsensecreativity.com

In this file insert the codes below:

;
; BIND data file for nonsensecreativity.com
;
$TTL    14400
@       IN      SOA     ns1.nonsensecreativity.com. host.nonsensecreativity.com. (
201006601 ; Serial
7200 ; Refresh after 3 hours
120 ; Retry in 120seconds
2419200 ; Expire after 1 week
604800) ; Default TTL
;
nonsensecreativity.com.  IN      NS      ns1.nonsensecreativity.com.
nonsensecreativity.com.  IN      NS      ns2.nonsensecreativity.com.

nonsensecreativity.com.  IN      MX      10      mail.nonsensecreativity.com.
nonsensecreativity.com.  IN      A       192.168.0.10
ns1             IN      A         192.168.0.10
ns2             IN      A         192.168.0.10
mail            IN      A         192.168.0.10
www             IN      CNAME     nonsensecreativity.com.
ftp             IN      CNAME     nonsensecreativity.com.
mail            IN      TXT       "v=spf1 a -all"
nonsensecreativity.com.  IN      TXT     "v=spf1 ip192.168.0.10 a mx ~all"

If you have two IPs, you can replace “ns2 IN A xxx.xxx.xxx.xxx” with your second IP address. Otherwise simply use the same IP. After changing the file, Hit CTRL+X and Y to save.

Note: The host.nonsensecreativity.com, It’s the value of your hostname which is FQDN ( Fully Qualified Domain Name ) you owned. So if your hostname isn’t FQDN you owned please change it.

Hostname, can be change in where you can setup your server OS, etc. for example in digitalocean.com it will be located in droplets > droplet name > settings > rename. If you’re using VPSdime which I’m using right now you can easily change it in the service menu for your package. Hostname can use sub-domain or Top Level Domain you owned.

The next file is used to define reverse DNS lookup. So let’s dig in to it:

sudo nano /etc/bind/zones/rev.0.168.192.in-addr.arpa

The content will be:

@ IN SOA nonsensecreativity.com. host.nonsensecreativity.com. (
2010081401;
28800;
604800;
604800;
86400 );
 
IN NS ns1.nonsensecreativity.com.
4 IN PTR nonsensecreativity.com.

Step Three — Update resolv.conf

This will be the last thing you need to edit, now open the file with nano editor

sudo nano /etc/resolvconf/resolv.conf.d/base

Add these codes below:

search nonsensecreativity.com
nameserver 8.8.8.8
nameserver 8.8.4.4

Save the file with CTRL+X then Y.

Updating resolv.conf file with

sudo resolvconf -u

This will updating the /etc/resolv.conf file, which you can see with

sudo cat /etc/resolv.conf

The file will be containing the codes you just insert into resolv.conf.d/base, now restart bind service with:

sudo /etc/init.d/bind9 restart

or

sudo service bind9 restart

Step Four — Update Domain NS

Personal DNS Server / Child Nameserver / Custom Nameserver / Glue Record

Setting up nameserver can be confusing at first. The problem is this feature can be vary to each domain registrar. Some use the term Child nameserver, other use the term personal DNS / Name server.

Like in namecheap.com, they used the term Personal DNS Server, for the user to add it’s own unique nameserver. Or in godaddy.com, they use the term Custom Nameserver. And in the domain registrar that I used to bought nonsensecreativity.com, they call it Child Nameserver. At gandi.net they call it Glue Record.

If you haven’t setting up this Custom Nameserver, it’s likely that your domain won’t pointing to your server no matter how good the setup is.

You need to create Custom Nameserver. For example, ns1.nonsensecreativity.com and ns2.nonsensecreativity.com ( you need at least two ). Then assign your host IP address into them. If you have two different IP address ( recommended ), set it to each nameserver.

After the custom nameserver are registered, you still need to update your Nameserver assigned to your domain, this one is almost the same in many domain registrar, by assigning your custom ns1.nonsensecreativity.com and ns2.nonsensecreativity.com to your domain Nameserver.

Below is example on namecheap.com and the other domain registrar that I used:

register-custom-ns-namecheap register-custom-ns-domainesia

That’s it Folks!! Now you wait until the hostname have been resolve to your domain name. then you can acess your domain via browser. Sometime this thing need to wait up to 24 hours mostly faster. You can check your domain status via intodns.com

Note: If you have issue about Reverse DNS / PTR in intodns.com. This is actually caused by your ISP or Server provider. Some server need you to submit a support ticket for updating your RDNS ( VPSdime ) and some server will automatically update your RDNS based on your hostname value ( digitalocean ).

Second Note: If you want to add second domain, just add the new db.domainname.com file and update the zones in named.conf.local, the NS will be pointing to your first domain ns. Eq:

$TTL    14400
@       IN      SOA     ns1.nonsensecreativity.com. host.nonsensecreativity.com. (
201006601 ; Serial
7200 ; Refresh after 3 hours
120 ; Retry
2419200 ; Expire after 1 week
604800) ; Default TTL
;
second-domain.com.      IN      NS      ns1.nonsensecreativity.com.
second-domain.com.      IN      NS      ns2.nonsensecreativity.com.
second-domain.com.      IN      MX      10      mail.second-domain.com.
second-domain.com.      IN      A       192.168.0.10
mail                    IN      A       192.168.0.10
www                     IN      CNAME   nonsensecreativity.com.
ftp                     IN      CNAME   second-domain.com.
nonsensecreativity.com. IN      TXT     "v=spf1 ip192.168.0.10 a mx ~all"
mail                    IN      TXT     "v=spf1 a -all"

Leave a Reply

Your email address will not be published. Required fields are marked *