Set hostname on CentOS/RHEL
July 25, 2007 – 14:37 by Hannes Van de VelCheck
hostname
uname -n
or
hostname
Change hostname
If your IP address is assigned to you by a DHCP server, then /etc/hosts is configured as follows:
127.0.0.1 mybox.mydomain.com localhost.localdomain localhost mybox
If you have a static IP address, then /etc/hosts is configured as follows:
127.0.0.1 localhost.localdomain localhost
192.168.0.10 mybox.mydomain.com mybox
If you have a static IP address, then /etc/sysconfig/network is configured as follows:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"
...