Unmetered Dedicated ServerDedicated Server SupportDedicated Server Live Help

How to Change an IP Address on Linux CentOS

 

How do I configure the Internet Protocol version 4 (IPv4) for a network connection with a static IP address on servers running Linux? How do I configure static IP address for  Redhat / RHEL / Fedora / Redhat Enterprise Linux server

1. You can change the ip-address of the server temporarily using ifconfig command For example, the following changes the ip-address of the server on eth0 interface to 67.105.23.17

#      ifconfig eth0 to 67.105.23.17

 

2. You can change the IP Address permanently under the /etc/sysconfig/network-scripts directory, you’ll see file for every network interface on your system. For example, if your interface is “eth0″, you’ll see ifcfg-eth0 file under this directory.

Modify the ifcfg-eth0 file with your favorite text editor (a lot of people prefer to use vi or nano) and change the IPADDR field accordingly as shown below to change the ip-address.

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


Change the IP address to the correct IP, make sure that the Netmask and Gateway are configured correctly as well and save.

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

      DEVICE="eth0"

      BOOTPROTO=none

      ONBOOT=yes

      TYPE="Ethernet"

      IPADDR="67.105.23.17"

      NETMASK="255.255.255.0"

      GATEWAY="67.105.23.1"

After you save the the ifcfg-eth0 you will have to restart the network. You can restart the network with the following command.

#      service network restart