Change hostname and IP address of Linux server without rebooting server

You can change option in third line in /etc/hosts file on Linux server without rebooting;

/etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.1 server.seimaxim.com seimaxim

You can change all of the following options in /etc/sysconfig/network without reboot.

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=server.seimaxim.com
GATEWAY=192.168.0.1

Similarly options in /etc/sysconfig/network-scripts/ifcfg-eth0 can also be changed.

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.1
NETMASK=255.255.255.0

Hostname of server can be changed with;

hostname server.seimaxim.com

Restart network with;

systemctl restart network

Leave a Reply