How to Configure DNS on a VPS

Table of Contents
How to Configure DNS on a VPS

What are DNS?

DNS (Domain Name System) translates domain names (like mysite.com) into IP addresses that computers understand.

Without correctly configured DNS, your site won’t be accessible to visitors.

Steps to Configure DNS on a VPS

  1. Choose your DNS provider
    • You can use your hosting provider’s DNS or a third-party service like Cloudflare, Google DNS, or OpenDNS.
  2. Create DNS records
    Key records include:
    • A Record: points your domain to the VPS IP address.
      Example:

      A mysite.com -> 123.45.67.89

       

    • CNAME: redirects a subdomain to another domain.
      Example:

      CNAME www.mysite.com -> mysite.com

       

    • MX Record: sets up email for your domain.
    • TXT Record: for SPF, DKIM, or domain verification.
  3. Configure VPS to accept the domain
    • In Apache or Nginx, add a virtual host for your domain.
    • Make sure the VPS firewall allows HTTP/HTTPS traffic (ports 80 and 443).
  4. Test the DNS configuration
    • Use tools like:
      • nslookup mysite.com
      • dig mysite.com
    • Wait for propagation (may take 24–48 hours).

Best Practices

  • Enable DNSSEC to prevent DNS spoofing.
  • Use short TTL when changing DNS to speed up propagation.
  • Backup your DNS records before making changes.
Kamga Orelien

Kamga Orelien

Author at Nolimit Hostinger, passionate about web technologies and hosting.