Este contenido no está disponible en el idioma seleccionado.
Chapter 20. Changing a hostname
The hostname of a system is the name on the system itself. You can set the name when you install RHEL, and you can change it afterwards.
20.1. Changing a hostname by using nmcli Copiar enlaceEnlace copiado en el portapapeles!
You can use the nmcli utility to update the system hostname. Note that other utilities might use a different term, such as static or persistent hostname.
Procedure
Optional: Display the current hostname setting:
nmcli general hostname
# nmcli general hostname old-hostname.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the new hostname:
nmcli general hostname new-hostname.example.com
# nmcli general hostname new-hostname.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow NetworkManager automatically restarts the
systemd-hostnamedto activate the new name. For the changes to take effect, reboot the host:reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, if you know which services use the hostname:
Restart all services that only read the hostname when the service starts:
systemctl restart <service_name>
# systemctl restart <service_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Active shell users must re-login for the changes to take effect.
Verification
Display the hostname:
nmcli general hostname
# nmcli general hostname new-hostname.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow
20.2. Changing a hostname by using hostnamectl Copiar enlaceEnlace copiado en el portapapeles!
You can use the hostnamectl utility to update the hostname.
By default, hostnamectl sets the following hostname types:
-
Static hostname: Stored in the
/etc/hostnamefile. Typically, services use this name as the hostname. -
Pretty hostname: A descriptive name, such as
Proxy server in data center A. - Transient hostname: A fall-back value that is typically received from the network configuration.
Procedure
Optional: Display the current hostname setting:
hostnamectl status --static
# hostnamectl status --static old-hostname.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the new hostname:
hostnamectl set-hostname new-hostname.example.com
# hostnamectl set-hostname new-hostname.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command sets the static and transient hostname to the new value. To set only a specific type, pass the
--static,--pretty, or--transientoption to the command.The
hostnamectlutility automatically restarts thesystemd-hostnamedto activate the new name. For the changes to take effect, reboot the host:reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, if you know which services use the hostname:
Restart all services that only read the hostname when the service starts:
systemctl restart <service_name>
# systemctl restart <service_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Active shell users must re-login for the changes to take effect.
Verification
Display the hostname:
hostnamectl status --static
# hostnamectl status --static new-hostname.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow