Hostnamectl: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 34: Line 34:
{{Warn|Note that changing the host name with <tt>hostnamectl set-hostname</tt> does not update <tt>/etc/hosts</tt> so you may want to review <tt>/etc/hosts</tt> and change the mapping of the host's network interface addresses to the new name.}}
{{Warn|Note that changing the host name with <tt>hostnamectl set-hostname</tt> does not update <tt>/etc/hosts</tt> so you may want to review <tt>/etc/hosts</tt> and change the mapping of the host's network interface addresses to the new name.}}


==If the Name is Publicly Resolved by DNS==


<font color=red>TODO http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-hostname.html</font>


==/etc/sysconfig/network HOSTNAME==


 
Setting HOSTNAME in <tt>/etc/sysconfig/network</tt> as shown in the following example
 
 
<font color=red>
Add or edit HOSTNAME in <tt>/etc/sysconfig/network</tt>:


<pre>
<pre>
...
NETWORKING=yes
NETWORKING=yes
GATEWAY=192.168.0.1
GATEWAY=192.168.0.1
Line 50: Line 50:
</pre>
</pre>


may interfere with network configuration script and change the host name.


</font>
{{Warn|This is '''NOT''' the preferred way of changing the host name, <tt>hostnamectl</tt> is.}}
 
==If the Name is Publicly Resolved by DNS==


<font color=red>TODO http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/set-hostname.html</font>


=Setting the Name=
=Setting the Name=

Revision as of 02:20, 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.

If the Name is Publicly Resolved by DNS

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

/etc/sysconfig/network HOSTNAME

Setting HOSTNAME in /etc/sysconfig/network as shown in the following example

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

may interfere with network configuration script and change the host name.


This is NOT the preferred way of changing the host name, hostnamectl is.


Setting the Name

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