How to Change IP Address in CentOS via Command Line

 

  1. Log in to the server via SSH as the "root" user using SSH access (on Windows you can SSH to Linux servers with Putty).
  2. To change the IP, you need to edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file on your server with your favorite editor, such as nano.
vi /etc/sysconfig/network-scripts/ifcfg-eth0

Or edit with nano

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

3. You need to change the lines "IPADDR", "GATEWAY" and "NETMASK". You will receive all this information from Radib emails.

Buy a quality virtual server with 24/7 support Click

4. You also need to edit/check the /etc/hosts file and change your old IP to the new one (if needed).

5. Then restart the network using the following command:

ifdown eth0 && ifup eth0

If it causes you problems, restart the device.
If the problem persists, please let us know and we will fix it as soon as possible.

 

Was this answer helpful? 51 Users Found This Useful (51 Votes)