How to Point a Domain Name to VPS

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:

  • Changing A record in the current DNS zone
  • Setting up a new DNS zone with custom nameservers

Locating Details

Firstly, you’ll need two find the IP address of your virtual server. On Hostinger panel, you may locate all VPS related information under the Servers section.

VPS server management section on Hostinger

The highlighted area under SSH Details shows your virtual server’s dedicated IP address.

VPS dedicated IP address location

Method 1 – Pointing Domain to VPS via A record

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

Nameserver lookup using dig command

Now that you know where your domain is pointed, navigate to the provider and open up your domain’s DNS zone.

Adding DNS entries

There are two approaches to choose from at this point:

  1. Using two A records – one for the www subdomain and another for the domain itself.
  2. Using A record for the domain and CNAME for the www subdomain.

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.

Option 1 – Using two A records


Option 2 – Using A record and CNAME

www.example.com14400CNAME example.com

Performing DNS Lookup

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

Performing domain's A record lookup using the dig commandIf 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.

Default Ubuntu loading page which signals that domain is successfully pointed to VPS

Method 2 – Pointing Domain to VPS via Custom Nameservers

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.

Looking for a better way to host your website?

Transfer your website to the fastest web hosting platform with 24/7 dedicated support.

Creating Custom Nameservers

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.

Creating child nameservers on Hostinger

Setting Up a DNS Zone on VPS

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
ns1                     IN      A
ns2                     IN      A
www                     IN      CNAME   hostinger-tutorials.xyz.
mail                    IN      A
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 {
// };

Edit them and according to this example:

forwarders {

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.xyz

If the task was done correctly, the output should be similar to:

DNS zone checkup using named-checkzone commandLastly, restart the DNS bind service and make sure it’s running:

/etc/init.d/bind9 restart
/etc/init.d/bind9 start

Changing Nameservers

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.

Applying custom nameservers to a domain registered on Hostinger

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.

Bonus – Setting Up Reverse DNS

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.

Adding a reverse PTR record on Hostinger

Once added, keep in mind that it can take a few hours to propagate before the record is fully active.

Final Word

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!

Add Comment

Click here to post a comment

Join thousands of subscribers worldwide

and get awesome deals & the newest tutorials to your email

Please wait...

Thank you for sign up!

More in DNS, VPS
How to Make a TeamSpeak 3 Server – The Complete Guide