LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-17-2005, 05:13 PM   #1
SupaDucta
LQ Newbie
 
Registered: Oct 2004
Location: Zagreb, Croatia
Distribution: CentOS 4.4
Posts: 24

Rep: Reputation: 15
CentOS 4.2: Multiple IPs on a single NIC


Hi guys,

I need to setup 2 additional IPs on a single NIC. Since this is a live box to which I presently have SSH access only, I need to be really careful doing this, so I thought I'd better ask.

CentOS 4.2.

What I have learned until now (correct me if wrong) is that

eth0 ---> remains as is, with the main IP and with /etc/sysconfig/network-scripts/ifcfg-eth0 staying as is with settings:

DEVICE=eth0
BOOTPROTO=static
BROADCAST=BOX.BROAD.CAST.ADDRESS
HWADDR=00:10:2E:61:8B:AA
IPADDR=MAIN.BOX.IP.ADDRESS
NETMASK=255.255.255.0
NETWORK=NET.WORK.IP.ADDRESS
ONBOOT=yes
TYPE=Ethernet
, and

eth0:0 with /etc/sysconfig/network-scripts/ifcfg-eth0:0 and
eth0:1 with /etc/sysconfig/network-scripts/ifcfg-eth0:1

for additional (aliased) IPs, with the difference in only the DEVICE= and IPADDR= lines.

Do I create the virtual interfaces using the

ifconfig eth0:0 IP.ADDRESS.NUMBER.2 \ netmask 255.255.255.0 up and
ifconfig eth0:1 IP.ADDRESS.NUMBER.3 \ netmask 255.255.255.0 up commands?

I have checked the kernel's .config, the ip_alias wasn't compiled in, so I believe I would have to load it? Do I need it? If needed, how to load it and make it load on boot?

Do I need to set the routes up like:

/sbin/route add -net 127.0.0.0
/sbin/route add -net MAIN.BOX.IP.ADDRESS dev eth0
/sbin/route add -host MAIN.BOX.IP.ADDRESS dev eth0
/sbin/route add -host IP.ADDRESS.NUMBER.2 dev eth0:0
/sbin/route add -host IP.ADDRESS.NUMBER.3 dev eth0:1
/sbin/route add default gw GATE.WAY.BOX.IP
?

Is this correct? What needs to be changed/corrected/omitted/done?

Please be kind and give me a hand, I have read several different HOWTOs and I am still not sure what to do?
 
Old 12-17-2005, 05:19 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you shouldn't need to directly mess with your routing table, just the additional icfg files should be required. infact you don't need to do that to test if it works or not, just use ifconfig to add additional IP's. "ifconfig eth0:1 192.168.0.2/24" etc... if that works then firm it up with the persistent config files.
 
Old 12-17-2005, 05:35 PM   #3
SupaDucta
LQ Newbie
 
Registered: Oct 2004
Location: Zagreb, Croatia
Distribution: CentOS 4.4
Posts: 24

Original Poster
Rep: Reputation: 15
Thanks acid_kewpie, I have just tested this on my local CentOS box I am connecting to from the other box with SSH. Entered ifconfig as you proposed, pinged from the other box... working perfectly. Added the ifcfg-eth0:1, rebooted, works perfectly.

So simple...

Thanks a lot, you have helped me a lot!
 
  


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
Multiple IPs on one NIC - How to use them all? MG-Cloud Linux - Networking 4 10-03-2005 03:28 AM
Max # of IPs on a single NIC Risc91 Red Hat 3 03-14-2005 04:32 PM
multiple IPs, one nic v4lu3s Linux - Networking 4 02-07-2004 11:52 AM
binding multiple IPs to single NIC? lok1 Linux - Networking 2 11-16-2003 03:58 PM
2 live/public ips for single NIC ehpserver Linux - Networking 3 10-08-2003 08:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:13 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