How to Point a Domain Name to VPS

How to Point a Domain Name to VPS

To use a custom 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 hosting using two methods:

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

Locating Details

Make sure to complete the initial setup of your VPS and buy a domain name before proceeding.

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.

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


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

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

Creating Custom Nameservers

Start by creating new child nameservers for your domain. Each entry needs to point to the VPS dedicated IP address. On hPanel, you can do it via Domains DNS / NameserversChild nameservers.

The child nameservers tab in hPanel's Domains settings

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:


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
$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

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 "" {
       type master;
       file "/etc/bind/zones/";

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 /etc/bind/zones/

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

DNS zone checkup using named-checkzone command

Lastly, 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. You can point your domain to Hostinger through their 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 again. 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.


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. In case you have any questions, suggestions, or cool tips, make sure to share them in the comments below!

The author

Domantas G.

Domantas leads the content and SEO teams forward with fresh ideas and out of the box approaches. Armed with extensive SEO and marketing knowledge, he aims to spread the word of Hostinger to every corner of the world. During his free time, Domantas likes to hone his web development skills and travel to exotic places.