LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Can't change ip address in Centos 6 (https://www.linuxquestions.org/questions/linux-newbie-8/cant-change-ip-address-in-centos-6-a-4175492249/)

rcmonroig 01-23-2014 01:23 AM

Can't change ip address in Centos 6
 
Trying to change my ip address from 10.0.2.23 to 192.168.105.22 on my centos 6 system.

I run
ip link set eth0 down
ip addr add 192.168.105.22 dev eth0
ip link set eth0 up
service network restart

Then I run ifconfig and the ip address
is 10.0.2.23 same as before -- no change
This should be pretty straight forward. Am I missing something here?

druuna 01-23-2014 03:23 AM

Quote:

Originally Posted by rcmonroig (Post 5103444)
Trying to change my ip address from 10.0.2.23 to 192.168.105.22 on my centos 6 system.

I run
ip link set eth0 down
ip addr add 192.168.105.22 dev eth0
ip link set eth0 up

service network restart

Then I run ifconfig and the ip address
is 10.0.2.23 same as before -- no change
This should be pretty straight forward. Am I missing something here?

After running the blue part the ip is changed, but the green part takes its input from ifcfg-eth0 to restart the network. ifcfg-eth0 still contains the original settings.

If you want to permanently change you ip you need to edit /etc/sysconfig/network-scripts/ifcfg-eth0:
Code:

service network stop
edit ifcfg-eth0
service network start


Gunjo 01-23-2014 04:46 AM

Quote:

Originally Posted by druuna (Post 5103496)
After running the blue part the ip is changed, but the green part takes its input from ifcfg-eth0 to restart the network. ifcfg-eth0 still contains the original settings.

If you want to permanently change you ip you need to edit /etc/sysconfig/network-scripts/ifcfg-eth0:
Code:

service network stop
edit ifcfg-eth0
service network start


Thanks for sharing.

jpollard 01-23-2014 11:59 AM

The first three commands likely did change the IP number...

but the "service network restart" wiped it out and loaded whatever was in the /etc/sysconfig/network-scripts/ifcfg-eth0"

myatthu 01-24-2014 08:31 PM

You might want to make sure ifcfg-ethX
NM_CONTROLLED=no

myatthu 01-24-2014 08:33 PM

Another thing is you want to change your setting permanently, for this distribution you need to change at ifcfg-ethx


All times are GMT -5. The time now is 04:14 AM.