FAQ VPS & Servers

How to set your server hostname and rDNS

Setting the hostname is one command; reverse DNS has to be set by whoever owns the IP address, which for a VPS means asking your host.

Updated 5 min read Beginner

Set the hostname itself with hostnamectl set-hostname, which you can do yourself in one command. Reverse DNS (rDNS) is different — it is controlled by whoever owns the IP address, which on a VPS is your host, so that has to be requested from them rather than set locally.

Setting the hostname

sudo hostnamectl set-hostname web1.yourdomain.com

Confirm it took effect:

hostnamectl

Some older tools and scripts also read /etc/hosts directly, so update that file to match:

sudo nano /etc/hosts
127.0.1.1   web1.yourdomain.com   web1

A fully qualified hostname like web1.yourdomain.com is generally the better choice over a bare name, particularly if the server sends email — many spam filters check that a server's hostname resembles a real domain rather than a generic default.

Why reverse DNS is different

Forward DNS answers "what IP address does this name point to?" and you control that through your own domain's DNS. Reverse DNS answers the opposite question — "what hostname does this IP address point to?" — and that record lives in DNS zones controlled by whoever owns the IP address block, not by you. On a VPS, that is your hosting provider, so you cannot set it yourself no matter what you change on the server.

Requesting rDNS

Contact your host and ask for a PTR record to be set for your VPS's IP address, pointing at the hostname you have configured on the server — for example, requesting that 203.0.113.10 resolves in reverse to web1.yourdomain.com. Contact us with your server's IP and the hostname you want if this applies to your VPS.

Match the forward and reverse records

Ideally, the hostname your host sets in reverse DNS should also resolve forward, via a normal A record on your own domain, back to the same IP address. Mail servers in particular check for this match, and a mismatch is a common, avoidable reason legitimate outgoing mail gets treated with suspicion.

When this actually matters

  • Sending email from the server. Missing or mismatched rDNS is one of the most common reasons a mail server's outgoing messages are marked as spam or rejected outright.
  • Running any service that logs or displays the connecting hostname to identify itself to others.
  • General good practice — a server with a real, matching hostname is easier to identify in logs, monitoring, and your own inventory once you are managing more than one.

If the server is purely serving a website and not sending mail directly, a mismatched or default rDNS entry is unlikely to cause a visible problem — it matters most for anything sending outbound email or identifying itself by hostname to another system.

Related reading