Changing the hostname in CentOS

Background: I made a tar backup of one system and wanted to untar that onto different hardware. A bit like cloning. However I needed to make sure the hostname and network settings were those of the new machine and not the cloned machine. So for future reference …

Change the Hostname

vi /etc/hosts

Change the Network Settings

To change the IP of a CentOS/Red Hat machine amend the following files:

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

A reboot will pick up the changes but if you want to avoid this:

hostname -v yourhostname

Restart networking:

/etc/init.d/network restart

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>