Hostnamectl: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 21: | Line 21: | ||
</pre> | </pre> | ||
<font color=red> | |||
Add or edit HOSTNAME in <tt>/etc/sysconfig/network</tt>: | |||
<pre> | |||
NETWORKING=yes | |||
GATEWAY=192.168.0.1 | |||
... | |||
HOSTNAME=not500.localdomain | |||
</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>. | |||
</font> | |||
==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:02, 4 April 2017
External
- http://man7.org/linux/man-pages/man1/hostnamectl.1.html
- http://man7.org/linux/man-pages/man8/systemd-hostnamed.8.html
Internal
Overview
Change the Host Name
The preferred way to change a host name is with hostnamectl as follows:
Add or edit HOSTNAME in /etc/sysconfig/network:
NETWORKING=yes GATEWAY=192.168.0.1 ... HOSTNAME=not500.localdomain
Update /etc/hosts as follows:
127.0.0.1 not500.localdomain not500 localhost localhost.localdomain ... ::1 not500.localdomain not500 localhost localhost.localdomain ...
Optionally you could resolve the name to the IP address of the primary network interface.
Run hostname to set the name for the current session. You may also want to run hostnamectl to update /etc/hostname.
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