How to change CentOS IP Address

Posted by cikul | Posted in Linux | Posted on 19-08-2008-05-2008

7

To change centOS IP Address, you must know what network interface used with your linux installation, to check network interface, you can use this command :

root@server [/]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:E0:4D:7D:DE:D9
          inet addr:172.17.17.10  Bcast:172.17.17.15  Mask:255.255.255.248
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12317238 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13264360 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3501403361 (3.2 GiB)  TX bytes:1239051254 (1.1 GiB)
          Interrupt:21 Base address:0xd000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:269263 errors:0 dropped:0 overruns:0 frame:0
          TX packets:269263 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:166075105 (158.3 MiB)  TX bytes:166075105 (158.3 MiB)

at this example, the machine have interface eth0 that interface configured with IP 172.17.17.10.

To change IP for interface eth0, the simplest way is using ifconfig command itself, for example :

root@server [/home]# ifconfig eth0 172.17.17.9 netmask 255.255.255.248

After run that command, you can check your ip using ifconfig command again.

ifconfig command create temporary IP address change, if you reboot your server, you will see that your IP still not change. If you want make permanent ip change, you must edit files under /etc/sysconfig/network-scripts/

root@server [/]# cd /etc/sysconfig/network-scripts/
root@server [/etc/sysconfig/network-scripts]# ls
./          ifdown-bnep*   ifdown-isdn@    ifdown-sl*      ifup-eth*    ifup-isdn@   ifup-routes*    init.ipv6-global*
../         ifdown-eth*    ifdown-post*    ifdown-tunnel*  ifup-ippp*   ifup-plip*   ifup-sit*       net.hotplug*
ifcfg-eth0  ifdown-ippp*   ifdown-ppp*     ifup@           ifup-ipsec*  ifup-plusb*  ifup-sl*        network-functions
ifcfg-lo    ifdown-ipsec*  ifdown-routes*  ifup-aliases*   ifup-ipv6*   ifup-post*   ifup-tunnel*    network-functions-ipv6
ifdown@     ifdown-ipv6*   ifdown-sit*     ifup-bnep*      ifup-ipx*    ifup-ppp*    ifup-wireless*
root@server [/etc/sysconfig/network-scripts]# cat ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=172.17.17.10
NETMASK=255.255.255.248
ONBOOT=yes

on that example, you see that ifcfg-eth0 configure with IP 172.17.17.10, use can use text editor to change that IP, after make change you must restart your network to make your new IP active.
root@server [/]# /etc/init.d/network restart

or
root@green [/]# service network restart

Incoming search terms:

 centos ip address|  centos ip configuration|  centos change ip|  centos ip|  centos change ip address|  change ip centos|  centos ip config|  ip address centos|  change ip address centos|  ip centos

Comments posted (7)

This is cool!
Thanks!

Great!!!…thanks..

Thanks! But a queston – how to configure a second alias ip address on the same interface ?

thanks for information how to change address in CENTOS. Is this tutorial are same for other Linux Distro ?

GoPiano…

Megacool Blog indeed!… if anyone else has anything it would be much appreciated. Great website Enjoy!…

how many so…

tank u

Write a comment

*