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
- Choose your DNS provider
- You can use your hosting provider’s DNS or a third-party service like Cloudflare, Google DNS, or OpenDNS.
- 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.
- 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).
- Test the DNS configuration
- Use tools like:
- nslookup mysite.com
- dig mysite.com
- Wait for propagation (may take 24–48 hours).
- Use tools like:
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.