LinuxQuestions.org
Register a domain and help support LQ
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 09-23-2010, 05:25 AM   #1
view
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Rep: Reputation: 0
add second ip to server


hello


how to add second ip to my new centos server?
 
Old 09-23-2010, 05:36 AM   #2
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
#vi /etc/sysconfig/network-scripts/ifcfg-eth0:0

Quote:
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
BROADCAST=192.168.XX.XX
IPADDR=192.168.XX.XX
NETMASK=255.255.255.0
NETWORK=192.168.XX.XX
ONBOOT=yes
 
Old 09-23-2010, 05:56 AM   #3
leejohnli
Member
 
Registered: Sep 2010
Posts: 66

Rep: Reputation: 2
Quote:
Originally Posted by kirukan View Post
#vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
Don't forget to create the file on it using touch command.
touch ifcfg-eth0:0 on /etc/sysconfig/network-scripts/
 
Old 09-23-2010, 06:10 AM   #4
view
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Original Poster
Rep: Reputation: 0
In SSh putty i log as root and type this:

vi /etc/sysconfig/network-scripts/ifcfg-eth0:0

and get this

http://i52.tinypic.com/33w48li.gif

I push enter and get this

http://i51.tinypic.com/f2msk0.gif

and nothing...

what is wrong?
 
Old 09-23-2010, 06:14 AM   #5
leejohnli
Member
 
Registered: Sep 2010
Posts: 66

Rep: Reputation: 2
Meaning, you have already an opened session running editing process e.g vi, vim,etc.
Just delete ".swp" file on it and it should work. To check use ls -al on the current directory to look for .swp file
 
Old 09-23-2010, 06:14 AM   #6
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Nagpur, India
Distribution: Cent OS 5/6, Ubuntu Server 10.04
Posts: 4,629

Rep: Reputation: Disabled
The first screen shot says that someone may already be updating the file. That means the file is already open. Or that it has not been cleanly closed and hence the swap file remains.
Now when you open it in vi forcefully, it opens and now you can edit it and save it.
Just copy the contents kirukan has given, edit them to your needs and save the file. It should be done.
 
Old 09-23-2010, 07:18 AM   #7
jmc1987
Member
 
Registered: Sep 2009
Location: Oklahoma
Distribution: Debian, CentOS, windows 7
Posts: 872

Rep: Reputation: 112Reputation: 112
Just a note what i do

cp /etc/sysconfig/network-scripts/ifcfg0 /etc/sysconfig/network-scripts/ifcfg0:0

then just edit the ifcfg0:0 to your needs. also you can add more ips by creating files like this

ifcfg0:1
ifcfg0:2
ifcfg0:3

so that how to add more IPs to eth0.

On your vi issue like they said delete the swap file if you know nobody else is in the file. if you used ctrl+c and then try to vi into the file again you will get the issue. so aways use some close command like

ZZ to save
:q to quit
:q! to quit with out save modifications.

man vim for more options
 
Old 09-23-2010, 10:57 AM   #8
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by leejohnli View Post
Don't forget to create the file on it using touch command.
touch ifcfg-eth0:0 on /etc/sysconfig/network-scripts/
#vi editor will create and edit the file ifcfg-eth0:0, As you said no need touch and then edit the file
 
Old 09-23-2010, 11:11 AM   #9
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by jmc1987 View Post
Just a note what i do

cp /etc/sysconfig/network-scripts/ifcfg0 /etc/sysconfig/network-scripts/ifcfg0:0

then just edit the ifcfg0:0 to your needs. also you can add more ips by creating files like this

ifcfg0:1
ifcfg0:2
ifcfg0:3
I am not pretty sure, but if it is ethernet interface the name format as ifcfg-eth0, loop backup interface ifcfg-lo and if it is point to point protocol ifcfg-ppp0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
add ip to linux server thok Linux - Newbie 5 10-24-2007 09:47 AM
How to add hosts to Solaris server pranavojha Solaris / OpenSolaris 2 10-19-2007 09:12 AM
How to add second mail server in RHEL 3 c_mahalingam Linux - Enterprise 7 09-11-2006 03:48 AM
Add new resolutions to X server librano MEPIS 4 07-22-2005 09:02 PM
add a printer through print server feetyouwell Linux - Software 4 05-26-2005 04:44 PM


All times are GMT -5. The time now is 12:54 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration