November 25, 2019
4min Read
Domantas G.

To use a domain name with a VPS, you will first need to make a few DNS changes. In this guide, we’ll show you how to point a domain name to a virtual private server using two methods:
Firstly, you’ll need to find the IP address of your virtual server. On Hostinger panel, you may locate all VPS related information under the Servers section.
The highlighted area under SSH Details shows your virtual server’s dedicated IP address.
The following method is a pretty straightforward solution. It would involve changing your current A record in the authoritative DNS zone. This means that the A record switch must be carried out at the DNS zone where your nameservers are currently pointing.
If you choose this option, your DNS zone file with all other existing entries (CNAME, MX, NS and other records) will remain with the current provider. The approach may be easier for beginners or those who do not wish to alter the location of their DNS zone.
If you’re not sure where your domain name is pointing at the moment, you may use DNS lookup tools or utilize the dig command to locate the NS records. Executing the following command via terminal will do the trick:
dig NS +short hostinger-tutorials.xyz
Now that you know where your domain is pointed, navigate to the provider and open up your domain’s DNS zone.
There are two approaches to choose from at this point:
Both of these options will provide you with the same result. Start by finding the current A record value and replace it with the dedicated IP address located earlier. Below, you’ll find a demonstration of how the entries should look like in your DNS zone.
| Name | TTL | Type | Address |
| example.com | 14400 | A | 153.92.211.25 |
| www.example.com | 14400 | A | 153.92.211.25 |
| Name | TTL | Type | Address |
| example.com | 14400 | A | 153.92.211.25 |
| www.example.com | 14400 | CNAME | example.com |
After pointing the domain to your VPS, it’s time to check whether the records were added correctly. Keep in mind that DNS propagation can take up to 24 hours, thus you may have to wait at least a few hours before everything starts working. However, most DNS checkup tools provide instant results. You may also do this using the dig command via terminal:
dig A +short hostinger-tutorials.xyz
If the output shows your VPS dedicated IP address as the A record, everything was done correctly! The remaining part is waiting for the DNS to fully propagate worldwide. To speed up the process, you may flush DNS and clear browser cache. Once the DNS is fully active, you will see a default loading page when visiting your domain via browser.
Pointing a domain to VPS via custom nameservers is a bit trickier, as you will need to set up a new DNS zone on the virtual server. This method will switch the location of your DNS zone to the VPS, which means that all future DNS-related changes will have to be made through the newly created zone.
Start by creating new child nameservers for your domain. Each entry needs to point to the VPS dedicated IP address. On Hostinger, you may easily do it using the domain management panel.
The next step is setting up a DNS zone for your domain on the virtual server. Connect to your VPS via SSH and go to:
cd /etc/bind
Then, create a separate folder for your DNS zone files:
mkdir -p zones
Access the newly created directory:
cd zones
Using the nano command, create a new zone file for your domain:
nano hostinger-tutorials.xyz
Use the following example and replace all IP address and domain instances with your actual domain name and the dedicated IP of your VPS:
;
; BIND data file for hostinger-tutorials.xyz
;
$TTL 3h
@ IN SOA ns1.hostinger-tutorials.xyz. admin.hostinger-tutorials.xyz. (
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 ns1.hostinger-tutorials.xyz.
@ IN NS ns2.hostinger-tutorials.xyz.
hostinger-tutorials.xyz. IN MX 10 hostinger-tutorials.xyz.
hostinger-tutorials.xyz. IN A 153.92.211.25
ns1 IN A 153.92.211.25
ns2 IN A 153.92.211.25
www IN CNAME hostinger-tutorials.xyz.
mail IN A 153.92.211.25
ftp IN CNAME hostinger-tutorials.xyz.Save the file by pressing CTRL+X and confirm the changes. The next task is inserting it in the default bind configuration:
cd /etc/bind nano named.conf.local
Add the following lines in the bottom and make sure to edit the file name with the real values:
zone "hostinger-tutorials.xyz" {
type master;
file "/etc/bind/zones/hostinger-tutorials.xyz";
};It is also recommended to use a stable DNS forwarder. In this demonstration, we’ll use Google Public DNS by editing the named.conf.options file:
nano named.conf.options
Locate the following lines:
// forwarders {
// 0.0.0.0;
// };Edit them and according to this example:
forwarders {
8.8.4.4;
};Now, all necessary values have been added. Double check if DNS zone file syntax is correct by executing:
named-checkzone hostinger-tutorials.xyz /etc/bind/zones/hostinger-tutorials.xyzIf the task was done correctly, the output should be similar to:
Lastly, restart the DNS bind service and make sure it’s running:
/etc/init.d/bind9 restart /etc/init.d/bind9 start
Since all pieces of the puzzle have been gathered, the last step is changing the nameservers of your domain to the newly created ones. On Hostinger, you may do it through the domain management panel.
Keep in mind that DNS propagation may take up to 24 hours, thus you’ll have to wait at least an hour or two before everything is fully operational. To speed things up, you may flush DNS and clear browser cache. You may also use online DNS checkup tools to confirm the functionality of your newly created zone. Once the DNS finishes propagating, you will see a default loading page while accessing your domain through the browser.
In some cases, you may be required to set up a reverse DNS record. Hostinger simplifies this process with an inbuilt tool at the bottom of your server management panel.
Once added, keep in mind that it can take a few hours to propagate before the record is fully active.
In this tutorial, we’ve learned two different methods of pointing a domain name to a virtual private server. It’s also important to remember that DNS changes can take at least a few hours to propagate worldwide.
Once the domain starts working with your VPS, the real journey begins. A good place to start is creating a virtual host and installing LAMP.
In case you have any questions, suggestions, or cool tips, make sure to share them in the comments below!
August 03 2019
there is no bind folder in etc folder ....
March 24 2020
Great stuff indeed. No doubt DNS propagation is a time-consuming process. I checked the tool that you mentioned for the DNS Propagation, as I was Googling for more tool, So I came across a handy online tool https://dnschecker.org/, that provides 300+ DNS servers for lookup comparing to other tools. I shared the tool for the better help of the users.
Gaurav
Replied on August 03 2019
Its in lib64