In this tutorial you will learn how to set / change server’s Fully Qualified Domain Name (FQDN) on Ubuntu 20.04 Focal Fossa Linux server or desktop.
In this tutorial you will learn:
- How to change or set FQDN via
/etc/hosts
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Installed Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
How to change FQDN ( domain name ) on Ubuntu 20.04 step by step instructions
The FQDN (Fully Qualified Domain Name) of the system is the name that the resolver(3) returns for the host name, such as, ursula.example.com. It is usually the hostname followed by the DNS domain name (the part after the first dot). You can check the FQDN using
hostname --fqdn
or the domain name using dnsdomainname
.
You cannot change the FQDN with hostname
or dnsdomainname
.
The recommended method of setting the FQDN is to make the hostname server1
as retrieved in the previous step be an alias for the fully qualified name using /etc/hosts
, DNS, or NIS.
- First, check your current hostname:
$ hostname server1 $ hostname --fqdn server1
At this point both, the hostname and FQDN is set to
server1
.Optionally, change your hostname before proceeding to the next step.
- As an example now we will define hostname
server1
as retrieved in the previous step to be an alias for the fully qualified domain namewww.linuxconfig.org
on the IP address1.2.3.4
. To do so edit the/etc/hosts
file by using thesudoedit /etc/hosts
command and add the following line:1.2.3.4 www.linuxconfig.org server1
NOTE
The order is important! The FQDNwww.linuxconfig.org
must precede the hostnameserver1
. - All done and no reboot required. Check your FQDN by using the
hostname
command:$ hostname --fqdn www.linuxconfig.org
Alternatively, also check your domain name:
$ dnsdomainname linuxconfig.org