5.1.2 How to change IP for a mail domain, PTR and Hostname for dedicated IP

Banner Proper configuration of the IP address and DNS records is a necessary condition for the stable operation of the mail server and ensuring uninterrupted delivery of emails. The IP address is a unique identifier that allows servers and clients to find each other on the Internet. The mail server must have a correctly configured IP address associated with your mail domain.

In addition to configuring the IP address, it is also important to properly configure the DNS records for your mail domain. This includes MX records, which point to the mail server, A records that bind the domain to the IP address, and SPF records that help prevent spam. Proper configuration of these records allows other servers to find your mail server and deliver mail without delays.

Proper configuration of the IP address, Hostname, and DNS records is a key step to ensuring stable and efficient operation of the mail server.

Changing the IP address for the mail domain

If you have ordered an additional IP address, you can assign it to your mail domain. Depending on the type of service, this can be done in different ways:

1. For virtual hosting services, this can be done via the graphical interface of the control panel, in the E-MailMail Domains section.

Control Panel

2. For virtual/dedicated server services with the ISPManager4 Lite control panel, you need to make the change via SSH. You need to connect to the server and execute the following commands:

  1. echo "domain.com:;" >> /etc/exim4/domainips
  2. update-exim4.conf
  3. /etc/init.d/exim4 restart

Note: you need to substitute your domain and your IP address. We use the domain domain.com and IP as an example only.

These commands will change the IP address for the mail domain domain.com to, since by default, the server’s main IP is used if the exim4 mail server is installed.

If you are using the postfix mail server, add a similar line to /etc/postfix/domainips and restart postfix with the command:

  1. /etc/init.d/postfix restart

Note: If you have previously changed the IP address for the mail domain using the above method, be sure to go to the /etc/exim4/domainips file and delete the old line binding the mail domain to the additional IP.

When changing the IP address of the mail domain, you should follow the recommendations for setting up DNS records.

Example: correct configuration of DNS records
Record Type Value
mail A Main_server_ip
pop A Main_server_ip
smtp A Main_server_ip
Main_domain. MX mail
Main_domain. MX mail
Main_domain. TXT v=spf1 ip4:main_server_ip ip4:additional_mail_domain_ip a mx ~all

When setting up DNS records, it is important to pay attention to the presence or absence of a dot (.) at the end of the record name. Rules for using a point in the following cases:

  • For the main domain, only a value with a dot is allowed, example example.com.
  • For subdomains, the following values ​​are allowed: www, mail, smtp (without dots at the end), the main domain will be automatically added to such values ​​and in DNS will have the general form: www.example.com., mail .example.com., smtp.example.com..

Below is an example where the main server IP and the additional IP for mail are used. DNS records should be configured following this principle.

Настройка DNS

Changing the PTR for a dedicated IP

Important: when setting PTR (Reverse DNS) for an IP address, it is recommended to specify a domain name that physically works with this IP address. The best option would be to use the main domain name, for example yourdomain.com.

Although some mail service providers also accept PTR records with subdomains like mail.yourdomain.com, there are some risks that such records may be filtered as potential spam on some mail servers. Therefore, to avoid any problems with mail delivery, it is recommended to use a simple main domain name without a subdomain.

For hosting services, changing the PTR is possible only in case of ordering a dedicated IP address. On some tariffs, a dedicated IP address is provided automatically:

  • Hosting – a dedicated IP must be ordered separately, otherwise a shared PTR for the server will be used.
  • Premium hosting – dedicated IPs are provided automatically for tariffs starting from Advanced.
  • Reselling hosting – a personal IP is available for any tariff.

To change the PTR record (Reverse DNS) on hosting with a dedicated IP, use the control panel ISPManager:

Change PTR

The way to change the PTR record may differ depending on the type of service you use. You can learn more about setting up PTR records in our instructions.

Changing the Hostname for a server

Changing the Hostname is only available for virtual and dedicated server services, and you must have root access.

You can change the Hostname value in the ISPManager control panel, in the Server Settings → Server Parameters section, in the Server Name field.

Changing Hostname

You can also change the Hostname via SSH. Connect to the server and execute the following command:

  1. sudo hostnamectl set-hostname your_hostname.com

The value your_hostname.com must be replaced with your domain.

Next, you can check the set value with the command:

  1. hostnamectl

Important: For stable operation of the domain mail, specify your mail domain or any domain pointing to this IP as the PTR and Hostname, on which you will create mailboxes. The PTR and Hostname updates take place within 6-24 hours.