Learn how to Point a Domain Name to VPS

access_time

hourglass_empty

person_outline

To utilize a domain name with a VPS, you will very first need to make a few DNS adjustments. In this guide, we’ll show you the best way to point a domain name to a virtual private server using two methods:

  • Changing A record in the current DNS zone
  • Making a new DNS area with custom nameservers

Locating Details

Firstly, you’ll have to find the IP address of your virtual server. On Hostinger panel, you may locate all VPS related info 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 – Directing Domain to VPS via A report

The following method is a pretty straightforward solution. It would involve modifying your current A record in the authoritative  DNS zone . This means that the A record switch must be carried out on 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 method may be easier for beginners or people who do not wish to alter  the location of the DNS zone.

If you’re not sure where your domain name is usually 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 NATURSEKT +short hostinger-tutorials. xyz  

Nameserver lookup using dig command

Since you know where your domain is usually pointed, navigate to the provider and open your domain’s DNS zone.

Adding DNS entries

There are two approaches to pick from at this point:

  1. Using two A records – one particular for the  www subdomain and another for your domain itself.
  2. Utilizing 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 worth and replace it with the dedicated IP address located earlier. Below, you will find a demonstration of how the entries should look like in your DNS zone.

Option 1 – Using two A records

Name TTL Type Address
example. com 14400 A 153. 92. 211. 25
www.example.com 14400 A 153. 92. 211. 25

Option 2 – Using A record and CNAME

Name TTL Type Address
example. com 14400 A 153. 92. 211. 25
www.example.com 14400 CNAME   instance. com

Performing DNS Lookup

After pointing the domain to your VPS, it’s time to verify whether the records were added properly. 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 , the majority of DNS checkup tools provide instant results. You may also do this using the  dig control via terminal:

  dig A +short hostinger-tutorials. xyz  

Performing domain's A record lookup using the dig command When the output shows your  VPS devoted IP address as the A record, almost everything was done correctly! The remaining part is waiting for the DNS to fully propagate worldwide. To speed up the procedure, you may flush DNS  and apparent browser cache. Once the DNS is certainly 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 two – Pointing Domain to VIRTUAL PRIVATE SERVER via Custom Nameservers

Pointing a domain to VPS via custom nameservers is a bit more difficult, as you will need to set up a new DNS zone on the virtual server. This technique will switch the location of your DNS zone to the VPS, which means that just about all future DNS-related changes will have to be produced through the newly created zone.

Creating Custom Nameservers

Start by creating new child nameservers for your domain. Each admittance 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 Area on VPS

The next step is setting up a DNS zone for your area on the virtual server. Connect to your VPS via SSH and visit:

  cd /etc/bind  

Then, create a separate file for your DNS zone files:

  mkdir -p zones  

Access the newly made directory:

  cd specific zones  

Using the nano command word, create a new zone file for your own domain:

  nano hostinger-tutorials. xyz  

Use the following example and change all IP address and domain instances with your actual domain name and the dedicated IP of the VPS:

 ;
; BIND data file for hostinger-tutorials. xyz
;
$TTL 3h
@ IN SOA ns1. hostinger-tutorials. xyz. admin. hostinger-tutorials. xyz. ( 1; Serial 3h; Refresh right 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.
@ WITHIN 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 THE 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 particular file by pressing CTRL+X  and confirm the particular changes. The next task is placing it in the default bind configuration:

  cd /etc/bind
nano named. conf. local

Add the following lines in the bottom level 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 demo, we’ll use Google Public DNS by editing the  named. conf. options  file:

  nano named. conf. choices  

Locate the following ranges:

  // forwarders 
// 0.0.0.0;
// ;

Edit them plus according to this example:

  forwarders  8.8.4.4; ;  

At this point, all necessary values have been added. Double check if DNS zone file syntax is correct by performing:

     named-checkzone     hostinger-tutorials. xyz     /etc/bind/zones/    hostinger-tutorials. xyz        

If the job was done correctly, the output ought to 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 reboot
/etc/init. d/bind9 start

Changing Nameservers

Considering that all pieces of the puzzle have already been gathered, the last step is changing the nameservers of your domain towards 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 distribution may take up to twenty four hours , thus you’ll have to wait a minimum of 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 recently created zone. Once the DNS coatings propagating, you will see a default launching page while accessing your domain name through the browser.

Bonus – Setting Up Reverse DNS

In some cases, you may be required to set up the 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 couple of hours to propagate before the record is certainly 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 essential 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 digital host and installing LAMP.

In case you have any questions, suggestions, or cool tips, make sure to discuss them in the comments below!

Posted by Editor