Hostname in Fedora 17
September 24, 2012 1 Comment
How can you change the hostname of your server running Fedora 17? The answer may not be as easy as it initially seems.
The two places where you need to have your hostname present are /etc/hosts and /etc/sysconfig/network files.
In /etc/hosts you need to have a line with the following format:
126.96.36.199 shorthostname.myexampledomain.com shorthostname
In /etc/sysconfig/network you need to have a line with the following format:
Here you need to provide the FQDN, not just a short hostname, according to the Fedora 17 documentation.
After making the change in /etc/sysconfig/network run the following command and then log out and log back in to see the change.
su -c 'systemctl restart NetworkManager.service'
After going through this process you need to make sure your hostname is now correct. So you run
hostname command. But wait! Instead of showing you shorthostname it shows shorthostname.mydomainexample.com. And you get the same output if you run
hostname --fqdn. Why is that? Does Fedora treat an FQDN as hostname now? Is there no difference anymore?
The mystery is solved by looking at the manpage for
hostname. If you use
hostname --short it’ll give you shorthostname and
hostname --domain will give you mydomainexample.com. In this situation if
hostname gives the FQDN by default then that should be just fine, as long as us users understand the difference.