Thursday, July 3, 2014

Configure/change IP in CentOS/Linux

From command line run following command:

ifconfig
e.g. ifconfig 10.10.10.10 eth0

This will immediately assign the IP to the system. But this will be removed after reboot.

To make it permanent, edit below file:

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


DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=yes
IPADDR=10.10.10.10
NETMASK=255.255.255.0
ONBOOT=yes
.....

Now define gateway in file:

/etc/sysconfig/network

NETWORKING=yes
HOSTNAME=manutablet
GATEWAY=192.168.1.254
 ..

Once these are defined, restart network services:
service network restart

Note: Do not stop/start service. Only restart it otherwise after stop you will lose your connection and you will need to go to the server and start the services from console.

 

Blogger news

Blogroll