Skip to Content

2 ways to check DNS PTR Record in Linux

DNS PRT record is short for pointer record. It is one of the common Domain Name System (DNS) records. It resolves an IP address to a domain or hostname. It is also called DNS reverse record. The following commands can be used to check PTR record in Linux.

  • dig -x 8.8.8.8
  • nslookup 8.8.8.8

 

What is PTR record in DNS

PTR records are mainly used to check if the server name is actually associated with the IP address from where the connection was initiated.

Some applications require reverse DNS records (PTR records) to resolve IP addresses to domain names. For example, applications that use SMTP require a PTR record that points to the domain from which an email is being sent. Without that record, spam filters can mark emails with low reputation, which causes email to end up in spam folders or not be sent at all.

Get Your Free Linux training!

Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!

Example of DNS PTR Record in Linux

Here is the PTR record for IP 185.230.63.186. It points to the domain name unalocated.63.wixsite.com.

% dig -x 185.230.63.186
; <<>> DiG 9.10.6 <<>> -x 185.230.63.186
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37914
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 6, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;186.63.230.185.in-addr.arpa. IN PTR
;; ANSWER SECTION:
186.63.230.185.in-addr.arpa. 0 IN PTR unalocated.63.wixsite.com.

Check PTR Record in Linux with dig command

The best Linux command to check PTR record is dig command.  It queries DNS servers for information about domains and records. Open the terminal and type dig -x ip address. It will return the PTR record for this ip.

To perform a reverse lookup for the relevant IP address, we can use the following dig command:

dig -x 8.8.8.8 +short
dns.google.

Check PTR record in Linux with nslookup command

we can check the DNS PTR with Nslookup as well. The outputs for both methods will show which hostname does this IP address belongs to. A sample is shown below:

% nslookup 8.8.8.8
Server: 64.104.76.247
Address: 64.104.76.247#53
Non-authoritative answer:
8.8.8.8.in-addr.arpa name = dns.google.

How to create a PTR record

PTR record is configured and controlled by the IP block owners. Often the reverse DNS host name is configured to indicate the netblock owner, such as ISP or web hosting provider.

If we are hosting a server with a dedicated IP address and would like to have PTR DNS configured (required if we are running an Internet mail server), the PTR record will usually be configured through our IP block hosting provider (usually the server hosting company).

If we own the DNS server on our own, we need to create a reverse DNS zone. The hostname for the zone has to be in a very specific format. It starts with a portion of our IP address written backward followed by .in-addr.arpa.

For exmaple,

we need to create .63.230.185.in-addr.arpa.zone file and add 186 record to point to unalocated.63.wixsite.com.

 

Tips for optimizing DNS PTR record

  • Make sure your PTR record is pointing to the correct IP address.
  • Keep your reverse lookup zone up to date with any changes in hostname or IP addresses.
  • Check for duplicate records and remove them if necessary.
  • Use a valid DNS server that’s authoritative for your domain name.

 

how to use DNS PTR records in Linux

One of the most common issues with DNS PTR records is an incorrect IP address. This can be caused by a number of things, such as a change in IP address or a typo in the IP address. If you’re having trouble creating or using a DNS PTR record, make sure that the IP address is correct.

Another common issue is email problem. This can cause problems when trying to send or receive email, since many mail servers will refuse to communicate with servers that do not have reverse DNS configured properly. If you’re having trouble sending or receiving email, make sure that your reverse DNS is set up correctly.

PTR Record and Email service

If a domain has no PTR record, or if the PTR record contains the wrong domain, email services may block all emails from that domain.

PTR records provide trust that the given hostname or a domain are connected to the IP address. The PTR records are a must-have for outgoing mail servers because most of the mail providers reject or mark as spam messages received by mail servers without valid reverse DNS configuration (missing PTR or mismatch A record for the hostname).

This has become standard so to say as all mail providers try to keep the spam out of their clients’ Inbox. The proper Reverse DNS configuration is always a good idea to avoid any potential email filtrations.

Related: