Networking & DNS

Set your server hostname and reverse DNS

Change the server's hostname, point DNS records at your IP, set reverse DNS in the control panel and check that forward and reverse lookups match.

IntermediateLinux server2 min read

Your server comes with an automatic hostname such as node-linux-1234.example.com. You can give it your own name, and set reverse DNS (a PTR record) so the IP address points back to that name. Reverse DNS matters most if the server sends email.

We use server1.example.com as the example. Use a name under a domain you control.

1. Point the name at your server (forward DNS)

At your domain's DNS provider, create an A record for server1.example.com with your server's IPv4 address. If your server has IPv6, add an AAAA record too. Check it from your computer or the server:

Bash
dig +short server1.example.com

It should print your server's IP. DNS changes can take a while to appear, depending on the record's TTL.

2. Change the hostname on the server

Bash
sudo hostnamectl set-hostname server1.example.com
hostnamectl

On Ubuntu and Debian, also update the 127.0.1.1 line in /etc/hosts so local tools resolve the new name:

127.0.1.1 server1.example.com server1

This changes the name the operating system uses. It does not create or change any DNS records.

Note: If your image uses cloud-init, it may set the hostname back on reboot. If that happens, add preserve_hostname: true to /etc/cloud/cloud.cfg.

3. Set reverse DNS in the control panel

  1. Log in to the client area, go to Services and open your server.
  2. Click Open Control Panel.
  3. Find the reverse DNS setting for your IP address and enter server1.example.com.
  4. Save. Reverse DNS is published by the network that owns the IP, so it can take some time to show.

Set the forward record (step 1) first. A PTR that points to a name that does not resolve back to the same IP is not useful. If you do not see a reverse DNS option for your service, open a support ticket with the IP and the name you want.

4. Check both directions

Bash
dig +short -x 203.0.113.25
dig +short server1.example.com

The first should return server1.example.com. and the second your IP. When both match, you have forward-confirmed reverse DNS, which mail servers check.

Troubleshooting

  • dig: command not found: install it with sudo apt install -y dnsutils (Ubuntu/Debian) or sudo dnf install -y bind-utils (AlmaLinux/Rocky).
  • Reverse lookup still shows the old name: resolvers cache answers. Wait for the old record's TTL to expire and query again.
  • Shell prompt still shows the old name: log out and back in.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.