Tuesday 23 December 2014

DNS Records

In this post we are going to look at various DNS records which are frequently used.

1. A Record

The A (Address Record) record maps the domain name to the 32 bit IP address so for example 

www.mydomainname.com. A 192.168.1.1

The A record is also known as host record.

For the IPv6 you have AAAA record which directs the domain name to the 128 bit IP address. The structure is very much the same; it's just bit longer.

2. CNAME Record

The CNAME (canonical name) record makes one domain name an alias of another. This allows your machine to have multiple hostnames however each of those hostnames doesn't need an individual "A" record.

e.g. Let's say you want to create sub-domain ftp.mydomainname.com for your main domain www.mydomainname.com

The CNAME record will look like this

ftp.mydomainname.com. CNAME mydomainname.com

You don't need to create a separate A record for this sub-domain. It will use the IP address from A record of the main domain.

3. NS Record

NS (Name Server) maps a domain name to DNS servers that are authoritative for that particular domain. It determines which servers will communicate DNS information for the domain. You normally configure two NS record (as primary and backup) for you domain .

e.g.
mydomainname.com NS ns1.example.com.
mydomainname.com NS ns2.example.com.

4. MX Record

MX (Mail Exchange) record maps a domain name to list of mail servers for that domain. 

e.g.
mydomainname.com. 1800 IN MX 0 mail1.mydomainname.com. 
mail1.mydomainname.com. A 10.10.10.10

The MX record shows that all the emails @mydomainname.com will be routed to the mail server mail1.mydomainname.com. The A record shows that this mail server is located at 10.10.10.10.

Multiple MX records can also be defined for a domain with a different priority. If mail can't be delivered using the highest priority record, the second priority record is used.

5. PTR Record

PTR (Pointer) record maps an IPv4 address to a host name. It is generally used for reverse lookups.  

The way it works is that let's say www.mydomainname.com has the IP address 192.168.1.1 then the PTR record would look like

1.1.168.192.in-addr.arpa IN PTR mydomainname.com.

As we can see the IP Address is reversed and added with in-addr.arpa. This is generally used as an anti-spam measures where the mail server will do the reverse DNS lookup to check if the server is actually associated with the IP address from where the connection was initiated. 

Some incoming mail servers will not accept a message from an IP address which does not identify itself with a PTR record so it's advisable to setup the PTR record for your servers especially mail/smtp servers.

No comments:

Post a Comment