Configure the PTR record on the DNS server

It was necessary to somehow configure the Reverse DNS zone for the mail server, since some servers did not want to receive mail from it.

Let’s assume our domain mail.example.com located on the IP address 192.168.1.100, and 192.168.1.1 – the server of the Internet provider.

You can check from Windows with commands (where 192.168.1.100 for example is the address of our mail server, and 192.168.1.1 DNS on which the request is sent):

nslookup mail.example.com
nslookup 192.168.1.100
nslookup 192.168.1.100 192.168.1.1

In response, the first command will be 192.168.1.100, and in response the second one is nothing (it should be mail.example.com), since the PTR record is not configured in DNS.

From Linux, you can check:

dig -x 192.168.1.100

At the registrar of domain names in DNS we will add the NS-server of the Internet provider ns1.example.com 192.168.1.1.

On the provider’s server (on the test I use Bind9 on Ubuntu Server), open the DNS configuration file for example in the nano editor (CTRL+X for exit, y/x and Enter for saving or canceling changes):

sudo nano /etc/bind/named.conf

And add the following lines:

zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/1.168.192.in-addr.arpa";
};

The first line indicates which zone we will manage, the second type – the main one (this DNS will manage it), the third one – in which file the configuration for this zone will be registered.

Open a new file for zone settings:

sudo nano /etc/bind/1.168.192.in-addr.arpa

And add to it:

$TTL 3600
@          IN SOA ns1.example.com. admin.example.com. (
              2016112301       ; Serial
              21600             ; refresh
              3600              ; retry
              3600000           ; expire
              86400 )           ; minimum

        IN  NS ns1.hosting.com.
        IN  NS ns2.hosting.com.

$ORIGIN 1.168.192.in-addr.arpa.
100      IN PTR  mail.example.com.

admin.example.com – the contact address of the person responsible for the zone, the @ symbol is not indicated.
Serial – this is the serial number of the zone file version, it should change to the big side with each change, it is usually written in the form of the year month the number is the number of the change, according to it other DNS determine that it is necessary to update the information.
Refresh – the time interval in seconds through which the secondary server will check whether the information needs to be updated.
Retry – the time interval in seconds through which the secondary server will retry calls on failure.
Expire – the time interval in seconds through which the secondary server will consider the information it has obsolete.
Minimum – the interval of information lifetime on caching servers.
ns1.hosting.com and ns2.hosting.com this is the DNS of this domain.
The number 100 in the last line means the end of IP address 192.168.1, similarly you can specify entries for other domains, for example 101 IN PTR … for 192.168.1.101, etc.

Restart the DNS server to apply the changes.
Bind9 can be commanded by:

sudo /etc/init.d/bind9 restart

Done.

See also:
Configuring Reverse DNS (PTR) in Hetzner

2 thoughts on “Configure the PTR record on the DNS server”

  1. Здравствуйте. Если у вас один почтовый сервер, то попросите своего интернет-провайдера добавить эту запись у себя, если будете еще запускать почтовые сервера, то настраивайте свой DNS сервер и добавляйте на нем записи, например как описано в статье.

  2. Привет из Болгарии. Очен рад что есть такие люди как Вас, которие помогают новичкам.
    У меня такая проблема – настроил сервер убунту 16.04 с мейл сервером на него. У меня реальний IP адрес скажем 151.227.227.3 а для для DNS адрес 151.227.227.1. Помогите пожалуйста как настроить PTR record для DNS serverа, чтоб вся почта принималась нормально. Пока не ставил BIND9. Просто не знаю откуда и с чем начать. Можете мне помочь?

Leave a Reply