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:
dig +short server1.example.comIt 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
sudo hostnamectl set-hostname server1.example.com
hostnamectlOn 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 server1This 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
- Log in to the client area, go to Services and open your server.
- Click Open Control Panel.
- Find the reverse DNS setting for your IP address and enter
server1.example.com. - 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
dig +short -x 203.0.113.25
dig +short server1.example.comThe 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) orsudo 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.
