On CentOS (5.x) I have a VPS that has hostname set to "olddomain.com", at least this is the domain I am getting when typing "hostname" command.
I want to change it to 'localhost.localdomain' because I think it is more generic and reliable.
localhost.localdomain already exists in these files: /etc/sysconfig/network AND /etc/hosts
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
GATEWAY=95.xx.xx.xx
AND
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
So next I tried these commands:
hostname localhost.localdomain
AND
hostname -v localhost.localdomain
"hostname" command now returns this new value. But after restart it changes back to olddomain.com or at least this is the "hostname" command returns.
Anything else to edit?
Best Answer
Add the following lines into your
/etc/sysctl.conf
configuration file.And execute the command
sysctl -p /etc/sysctl.conf
to read and apply the changes of your/etc/sysctl.conf
configuration file.