Properly configuring DNS (Domain Name System) host records is crucial for ensuring that your domain resolves correctly to web servers, mail servers, and other internet services. This guide will walk you through setting up various types of DNS records, using practical examples.
DNS host records tell the internet how to find your domain and its services (like websites or email). Each record maps a hostname (like @ or www) to a value (like an IP address or another domain name).
Each DNS record has:
@, www, mail).Maps a domain or subdomain to an IPv4 address.
RECORD_TYPE: A
HOSTNAME: @
VALUE: 10.30.21.11
TTL: 300
@ means the root domain (e.g., example.com).example.com to the IPv4 address 10.30.21.11.Another example:
RECORD_TYPE: A
HOSTNAME: mail
VALUE: 10.30.21.11
TTL: 300
mail.example.com to the same server.Maps a domain or subdomain to an IPv6 address.
RECORD_TYPE: AAAA
HOSTNAME: @
VALUE: 2001:b07:5d2e:6e67:552a:ae40:7e9d:f47
TTL: 300
example.com to use the given IPv6 address.Maps a subdomain to another domain name. This is often used for aliasing.
RECORD_TYPE: CNAME
HOSTNAME: www
VALUE: @
TTL: 300
www.example.com an alias for example.com.Another set of examples:
RECORD_TYPE: CNAME
HOSTNAME: mail1
VALUE: mail
MX_PREF: 10
TTL: 300
RECORD_TYPE: CNAME
HOSTNAME: mail2
VALUE: mail
MX_PREF: 20
TTL: 300
mail1.example.com and mail2.example.com both point to mail.example.com, possibly for mail server redundancy. While CNAME records technically shouldn’t have MX preferences, this might be misused or misunderstood. Typically, you'd use MX records instead for mail routing.Holds arbitrary text data, often used for email authentication like SPF, DKIM, or DMARC.
RECORD_TYPE: TXT
HOSTNAME: mail
VALUE: v=spf1 mx -all
TTL: 300
mail.example.com.-all means all others are not authorized to send mail.Your data includes MX preferences in CNAME records, which is incorrect.
Proper MX records should look like:
RECORD_TYPE: MX
HOSTNAME: @
VALUE: mail.example.com
MX_PREF: 10
TTL: 300
MX_PREF sets the priority (lower is higher priority).Here's a combined example that sets up web and email services for a domain:
RECORD_TYPE,HOSTNAME,VALUE,MX_PREF,TTL
A,@,10.30.21.11,,300
AAAA,@,2001:b07:5d2e:6e67:552a:ae40:7e9d:f47,,300
CNAME,www,@,,300
A,mail,10.30.21.11,,300
MX,@,mail.example.com,10,300
TXT,mail,v=spf1 mx -all,,300
example.com and www.example.com point to a server via IPv4 and IPv6.mail.example.com is set up as the mail server.mail.example.com.TTL defines how long a DNS record is cached by resolvers.
300 (5 minutes), 3600 (1 hour), 86400 (1 day)dig, nslookup, or online DNS checkers).