I am renting a server, running Ubuntu 16.04 at a company, let's name it company.org.
Currently, my server is configured like this:
- hostname:
server737263
- domain name:
company.org
Here's my FQDN:
user@server737263:~ $ hostname --fqdn
server737263.company.org
This is not surprising.
I am also renting a domain name, let's name it domain.org
. What I would like to do would be to rename my server as server1.domain.org
.
This means configuring my hostname as server1
and my domain name as domain.org
.
How can I do it correctly?
Indeed, the manpage for hostname
is not clear. To me at least:
HOSTNAME(1)
[...]
SET NAME
- When called with one argument or with the --file option, the commands set the host name or the NIS/YP domain name. hostname uses the sethostname(2) function, while all of the three domainname, ypdomainname and nisdomainname use setdomainname(2). Note, that this is effective only until the next reboot. Edit /etc/hostname for permanent change.
[...]
THE FQDN
- You cannot change the FQDN with hostname or dnsdomainname.
[...]
So it seems that editing /etc/hostname
is not enough? Because if it really changed the hostname, it would have changed the FQDN. There's also a trick I read to change the hostname with the command sysctl kernel.hostname=server1
, but nothing says whether this is the correct way or an ugly trick.
So:
What is the correct way to set the hostname?
What is the correct way to set the domain name?