How to Configure DNS for a VPS? Print

  • 0

Configuring DNS (Domain Name System) for a VPS ensures your domain points to your server, making your website or application accessible. This guide provides a concise, step-by-step process to set up DNS for a VPS, with references to VPS.DO’s features for clarity.

Prerequisites

  • A VPS with a public IP (e.g., VPS.DO’s 1H2G plan with 1 IPv4).
  • A registered domain name from a registrar (e.g., Namecheap, GoDaddy).
  • Access to your domain registrar’s DNS management panel.
  • Root or sudo access to your VPS, manageable via VPS.DO’s SolusVM control panel.

Step-by-Step Configuration

1. Log in to Your VPS

Connect to your VPS via SSH. For VPS.DO users, use the credentials from your SolusVM dashboard:

ssh root@your_vps_ip

2. Verify Your VPS IP

Confirm the public IP assigned to your VPS. Run:

ip addr show

Note the IP (e.g., 192.0.2.1). VPS.DO provides this in the SolusVM panel under your VPS details.

3. Update Your Domain’s DNS Records

Log in to your domain registrar’s DNS management panel and configure the following records:

A Record (Address)

  • Name: @ or your domain (e.g., example.com)
  • Value: Your VPS’s public IP (e.g., 192.0.2.1)
  • TTL: Set to 3600 seconds (or default).

A Record for Subdomains (Optional)

For subdomains like www:

  • Name: www
  • Value: Your VPS’s public IP (e.g., 192.0.2.1)
  • TTL: 3600 seconds.

MX Record (Mail Exchange, Optional)

If hosting email:

  • Name: @
  • Value: mail.example.com (or your mail server)
  • Priority: 10
  • TTL: 3600 seconds.

CNAME Record (Optional)

For aliases like www pointing to the main domain:

  • Name: www
  • Value: example.com
  • TTL: 3600 seconds.

4. Install and Configure a Web Server (Optional)

To test DNS, ensure a web server (e.g., Apache or Nginx) is running on your VPS. For example, install Apache:

sudo apt update
sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2

Verify by visiting http://your_vps_ip. If DNS is set, http://example.com should load the same page after propagation.

5. Check DNS Propagation

DNS changes may take 1–48 hours to propagate. Test with:

nslookup example.com

Or use online tools like dnschecker.org. The response should show your VPS’s IP (e.g., 192.0.2.1).

6. Secure Your VPS

  • Configure a firewall (e.g., UFW) to allow DNS, HTTP, and HTTPS traffic:
sudo ufw allow 53
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
  • Monitor your VPS resources via VPS.DO’s SolusVM panel to ensure stability.

7. Troubleshooting

  • DNS not resolving: Double-check your A record and IP. Ensure no conflicting records exist.
  • Propagation delay: Wait up to 48 hours or use a lower TTL before changes.
  • VPS issues: Contact your provider’s support. VPS.DO offers 24/7 ticket-based assistance for quick resolution.

Conclusion

Proper DNS configuration connects your domain to your VPS, enabling website or app accessibility. With VPS.DO’s dedicated IPv4 and SolusVM panel, managing your VPS is straightforward. Test your setup thoroughly and secure your server to ensure reliable performance.


Was this answer helpful?

« Back