LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-23-2014, 01:23 AM   #1
rcmonroig
Member
 
Registered: Mar 2007
Location: Chandler, AZ
Distribution: Fedora 10,12,and 14
Posts: 62
Blog Entries: 1

Rep: Reputation: 15
Question 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?
 
Old 01-23-2014, 03:23 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Quote:
Originally Posted by rcmonroig View Post
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
 
2 members found this post helpful.
Old 01-23-2014, 04:46 AM   #3
Gunjo
LQ Newbie
 
Registered: Sep 2012
Location: Maharashtra State, India
Distribution: Red Hat Enterprise Linux Server release 6.0 (Santiago)
Posts: 18

Rep: Reputation: Disabled
Thumbs up

Quote:
Originally Posted by druuna View Post
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.
 
1 members found this post helpful.
Old 01-23-2014, 11:59 AM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
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"
 
1 members found this post helpful.
Old 01-24-2014, 08:31 PM   #5
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

Rep: Reputation: 18
You might want to make sure ifcfg-ethX
NM_CONTROLLED=no
 
Old 01-24-2014, 08:33 PM   #6
myatthu
Member
 
Registered: Jan 2014
Distribution: CentOS, Fedora, Ubuntu
Posts: 108

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


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] CentOS second IP address mah454 Red Hat 7 05-30-2012 03:23 AM
How to change IP address on CentOS ? gaankdoank Linux - Server 3 01-10-2010 05:14 PM
CentOS 3.5 Enterprise Server -- I need to change my Local Static IP address. kexpert Red Hat 12 11-08-2009 05:33 AM
CentOS command-line Program to Randomly change my MAC address? kexpert Linux - Newbie 3 11-08-2009 12:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration