Jump to Navigation

155 - Permanent hostname change on RedHat

RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot.
This is set using the init script /etc/rc.d/rc.sysinit.

* Edit /etc/sysconfig/network

NETWORKING=yes
HOSTNAME="server1.mydomain.com"
GATEWAY="192.168.17.1"
GATEWAYDEV="eth0"
FORWARD_IPV4="yes"

* After the change, restart the network server.

# service network restart   (or /etc/init.d/network restart)

So in order to preserve your change on system reboot edit this file and enter the appropriate name using the HOSTNAME
variable. Use sysctl to change the hostname.

* Edit /etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.17.1 server1.mydomain.com server1
#::1    localhost.localdomain   localhost       server1

* To read the current hostname

$ sysctl kernel.hostname

kernel.hostname = server0.mydomain.com

* Change the host name

$ sysctl kernel.hostname="NEW_HOSTNAME"

 



Main menu 2

Story | by Dr. Radut