Reasons to Change the Default VPS Hostname – Guide

hostnamevps

I'm configuring a VPS that I recently subscribed to and I follow other devs' blogposts to help me setting my own up. I often see them changing the VPS hostname. The default VPS hostname doesn't look very pretty (e.g. vps-1343-8332.myvpsprovider.cloud), so they change it to their domain name. For instance:

hostnamectl set-hostname --static www.yourdomainname.com

However, to my understanding, as long as DNS is resolving the domain names to the correct IPs, hostname has no influence at all on the hosted domain name.

Then I wonder, for what reasons do fellow devs change their default VPS hostname?

Best Answer

Changing the hostname assigned by the hosting provider to something matching your own organisation's naming convention is usually a good idea.

Predictable and memorable host names help humans remember and identify systems much more easily than the ip-address and will likely help prevent mistakes.

From a branding perspective you usually also want your servers to identify themselves as part of your domain, not the hosting providers.

  • Keep in mind that a hostname must uniquely identify a specific server and a server can (should) have only one hostname.

    • The forward DNS entry for the hostname should exist and the FQDN should point to the servers main ip-address. (Also see this Q&A)
      That also implies that you usually use a domain that you actually own, not something you make up.
    • The name of the host does not need to be the same as the service running on that host.
      I.e. avoid the situation where a single web server is hosting multiple websites and that has the hostname www.example.com. You can spend hours checking and finding nothing wrong with that website before realizing that the issue is with "www other-site" running on www.example.com
    • You want to avoid recycling hostnames, it gets annoying fast when you need to distinguish individual hosts by "the old www.example.com" and "the new www.example.com" and similar such non-sense.

    • The hostname will be used in system prompts, banners, error messages , log files etc.
      When you have for instance a cluster of web servers all with the same hostname www.example.com identifying the specific misbehaving node is unnecessarily difficult.

    • With forward DNS you can point an unlimited number of different and unrelated host and domainnames to a server's ip-address, but for reverse DNS you can effectively only map the ip-address to a single hostname. Align the reverse DNS record with the hostname set in the server.