Hostnamectl: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 49: Line 49:
HOSTNAME=not500.localdomain
HOSTNAME=not500.localdomain
</pre>
</pre>
Update <tt>/etc/hosts</tt> as follows:
<pre>
127.0.0.1  not500.localdomain not500 localhost localhost.localdomain ...
::1        not500.localdomain not500 localhost localhost.localdomain ...
</pre>
Optionally you could resolve the name to the IP address of the primary network interface.
Run <tt>[[hostname]]</tt> to set the name for the current session. You may also want to run <tt>[[hostnamectl]]</tt> to update <tt>/etc/hostname</tt>.





Revision as of 02:16, 4 April 2017

External

Internal

Overview

Change the Host Name

The preferred way to change a host name is with hostnamectl as follows:

hostnamectl set-hostname <name>

Example:

hostnamectl set-hostname docker-server.local

This commands changes all the hostnames (static, pretty and transient) of the system.

hostnamectl set-hostname and /etc/hosts


Note that changing the host name with hostnamectl set-hostname does not update /etc/hosts so you may want to review /etc/hosts and change the mapping of the host's network interface addresses to the new name.




Add or edit HOSTNAME in /etc/sysconfig/network:

NETWORKING=yes
GATEWAY=192.168.0.1
...
HOSTNAME=not500.localdomain


If the Name is Publicly Resolved by DNS

TODO http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-hostname.html

Setting the Name

hostnamectl [--static|--pretty|--transient] set-hostname blah