Unix and Linux network configuration. Multiple network interfaces. Bridged NICs. High-availability network configurations.


Reviews of latest Unix and Linux software. Helpful tips for application support admins. Automating application support.


Disk partitioning, filesystems, directories, and files. Volume management, logical volumes, HA filesystems. Backups and disaster recovery.


Distributed server monitoring. Server performance and capacity planning. Monitoring applications, network status and user activity.

Commands & Shells

Cool Unix shell commands and options. Command-line tools and application. Things every Unix sysadmin needs to know.

Home » Networking

Red Hat: Changing Hostname and IP

Submitted by on August 31, 2011 – 1:47 pm 3 Comments

Changing hostname and IP is frequently required when a server is being moved from testing or development to production. The process is a fairly simple one, but steps must be performed in a certain order to avoid complications. Before making any changes you must confirm that the new IP is available and that your server – physical or VM – can access the new network. You will also need to have console access to the server.

For our example, we are changing hostname from to The IP address is changing from to on interface eth0. The first step is to create backups of the files we are going to modify:

for i in /etc/hosts /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network
     mkdir /etc/backups
     /bin/cp -p "${i}" /etc/backups/

Now open the /etc/hosts file and modify/add a line with your server’s new IP, fully-qualified DNS name, and short hostname:     srv-prd-01

The next step is to edit the configuration file for the eth0 network interface: /etc/sysconfig/network-scripts/ifcfg-eth0. At the very least, you will need to check the IP address, the netmask and the MAC address of the network interface card.


Now we need to modify /etc/sysconfig/network to change the hostname and default gateway information:


As the final step, you may run the hostname command to set the hostname for the current session and restart network services:

/etc/init.d/network restart

Make sure you can ping the default gateway, the DNS server and any other critical servers (NIS, LDAP, NFS, etc.) At this point it would be a good idea to reboot the server to make sure there are no unexpected issues with the hostname change.

Print Friendly, PDF & Email


  • mavis24 says:

    I am working as a broadband internet field engineer. In windows 98 or xp i can easily put ip, subnett, dns, gateway in my network places>view network con.>local area connection>properties>TCP/IP.but i dont know where i put ip address in LINUX, please help me step by step to give u best answer.

  • Victoria T says:

    I have an internet connection with a dynamic ip address, and the usb modem is attached to my wifi router, i want to host my website from vmware, from linux servers, i have installed ubuntu server, centos, red hat and more, but how do i host the website from these? I have a dynamic ip address and I dont want to open port 80 for my whole computer, only for the virtual machine, most preferably i will use ubuntu server, please give me proper instructions, and my isp wont give me a static ip, and i cant change my isp as well.

  • Alina Elliott says:

    I am in college and wanted to know if my IP address on the school computers would be different than my own Macbook. I use the same log in info to connect to wi fi that I use to access a school computer, thanks!

Leave a Reply

%d bloggers like this: