Records Explained: A, CNAME, NS, MX, and PTR
DNS records are crucial for defining how your domain behaves on the internet. Below is a detailed explanation of the most commonly used DNS records: A, CNAME, NS, MX, and PTR.
A Records (Address Records)
An A record directs a hostname to a numerical IP address. This allows your domain name to resolve to a specific server.
Example:
If you want mycomputer.yourdomain.com
to point to your home computer with the IP address 192.168.0.3
, you would create an A record like this:
Important:
- Always put a period after the hostname (e.g.,
mycomputer.yourdomain.com.
). - Do not add a period after the IP address.
CNAME Records (Canonical Name Records)
A CNAME record allows one hostname to point to another, essentially creating an alias. This is helpful when you want multiple subdomains to resolve to the same domain.
Example:
If you want ftp.yourdomain.com
, mail.yourdomain.com
, and ssh.yourdomain.com
to all point to yourdomain.com
, you would create the following CNAME records:
ftp.yourdomain.com. CNAME yourdomain.com.
mail.yourdomain.com. CNAME yourdomain.com.
ssh.yourdomain.com. CNAME yourdomain.com.
This way, visitors can access your server through different subdomains, such as ftp.yourdomain.com
, without needing a separate A record for each.
Entering a CNAME Record
If you wanted home.site-helper.com
to point to site-helper.com
, you could enter the record in two ways:
-
Method 1:
Simply enter the subdomain name without a period at the end.home.site-helper.com CNAME site-helper.com
-
Method 2:
Enter the full hostname, including a period at the end.home.site-helper.com. CNAME site-helper.com.
Both methods achieve the same result, but method 2 ensures a fully qualified domain name (FQDN).
NS Records (Nameserver Records)
NS records specify the authoritative nameservers for a domain. These are critical for determining which DNS servers are responsible for managing a domain’s DNS records.
Important:
Changing NS records can cause your site to stop working if not done correctly. It is often unnecessary to change them unless you are switching to a new DNS provider or hosting service.
MX Records (Mail Exchange Records)
MX records are responsible for directing email traffic for your domain. They define the mail servers that should handle incoming mail for your domain.
Example:
If you want your domain to use a third-party email service like mail.example.com
, you would set an MX record like this:
yourdomain.com. MX 10 mail.example.com.
The priority (e.g., 10
) indicates the order in which mail servers should be tried if there are multiple records. Lower numbers have higher priority.
Important:
Changing MX records may stop your current email services (e.g., POP3, autoresponders, etc.) from working unless reconfigured properly.
PTR Records (Pointer Records)
PTR records are used for reverse DNS lookups, allowing an IP address to resolve to a domain name. For example, if you want the IP address 192.168.0.1
to resolve to www.yourdomain.com
, you would create a PTR record:
1.0.168.192.in-addr.arpa. PTR www.yourdomain.com.
Important:
- PTR records are only effective if your site has its own dedicated IP address.
- Setting PTR records typically requires root access to the DNS server or assistance from your hosting provider.
Conclusion
Each DNS record plays a vital role in directing internet traffic to the correct destination. Understanding A, CNAME, NS, MX, and PTR records allows you to efficiently manage your domain and its services.
If you are unsure about any DNS settings, it's always recommended to check your existing DNS records for guidance or reach out to your hosting provider for further assistance.