Change IP address on CentOS VPS Server

In this tutorial, we'll give you a step by step description on how to change your server's IP address on CentOS 5/6. Remember that you need to be root user or have root privileges to perform this commands.

1. Confirm your current IP address:

 

ifconfig eth0

 

You should have an output like this:

 

eth0 	Link encap:Ethernet HWaddr 00:16:3C:2A:76:60
 	inet addr:10.10.10.39 Bcast:10.10.10.63 Mask:255.255.255.224
 	inet6 addr: fe80::216:3cff:fe2a:7660/64 Scope:Link
 	UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
 	RX packets:3287516 errors:0 dropped:0 overruns:0 frame:0
 	TX packets:1961807 errors:0 dropped:0 overruns:0 carrier:0
 	collisions:0 txqueuelen:1000
 	RX bytes:1048333886 (999.7 MiB) TX bytes:2596365984 (2.4 GiB)

 

Pay special attention to the values of inet addr, Bcast and Mask. This reflects your current IP addressing.

 

2. Change the values with the new IP address

You need to edit the ifcfg-eth0 interface in order to change the IP address and the corresponding networking values.

 

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

 

Edit the values of IPADDR, GATEWAY, NETMASK

 

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=10.10.10.39
GATEWAY=10.10.10.33
NETMASK=255.255.255.224

 

Save the file

 

3. Restart the network service:

 

service network restart

 

4. Confirm the changes:

 

ifconfig eth0

 

You should see the inet addr, Bcast and Mask values updated.

 

Thank you!

 

Test on a Miami VPS Now

or

Deploy on a Miami Dedicated Server

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