Networking Forums  

Go Back   Networking Forums > Networking Newsgroups > Linux Networking

Adding Virtual IP Address

Reply
 
Thread Tools Display Modes
  #1  
Old 05-24-2004, 03:05 PM
Default Adding Virtual IP Address



Hi,

I have a problem in shutting down an already added virtual ip thru
ifconfig. Consider this snippet below :

/sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
/sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
/sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up

I am adding three virtual ip address on eth0 interface. Now if I try
to down, for example, 192.168.220.2 , i don't have problems. But If I
try to down the IP, 192.168.220.1, I see that all the other virtual
ips 192.168.220.2 and 192.168.220.3 are also gone. I am not able to
ping any of the other ips also.

Now, just change the order of the snippet below :
/sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
/sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
/sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up

Now If down the virtual ip 192.169.220.2, the other vips are also
gone.

Put simply, whenever i down the first virtual ip , all the other vips
also goes down.

Why is it so ? Am i missing something ?

Thanks,
Vijay.


Vijay
Reply With Quote
  #2  
Old 05-24-2004, 07:37 PM
David Efflandt
Guest
 
Posts: n/a
Default Re: Adding Virtual IP Address

On 24 May 2004 07:05:53 -0700, Vijay <(E-Mail Removed)> wrote:
> Hi,
>
> I have a problem in shutting down an already added virtual ip thru
> ifconfig. Consider this snippet below :
>
> /sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
> /sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
> /sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up
>
> I am adding three virtual ip address on eth0 interface. Now if I try
> to down, for example, 192.168.220.2 , i don't have problems. But If I
> try to down the IP, 192.168.220.1, I see that all the other virtual
> ips 192.168.220.2 and 192.168.220.3 are also gone. I am not able to
> ping any of the other ips also.


What happens if you down the alias _interface_ instead of the IP, ie,
'ifconfig eth0:1 down'? BTW the first alias is eth0:0, but it does not
matter if you skip it or start at any other number.

--
David Efflandt - All spam ignored http://www.de-srv.com/
Reply With Quote
  #3  
Old 05-24-2004, 08:54 PM
Cameron Kerr
Guest
 
Posts: n/a
Default Re: Adding Virtual IP Address

Vijay <(E-Mail Removed)> wrote:

> /sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
> /sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
> /sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up


So what's assigned to eth0? (no alias)

--
Cameron Kerr
(E-Mail Removed) : http://nzgeeks.org/cameron/
Empowered by Perl!
Reply With Quote
  #4  
Old 05-25-2004, 11:07 AM
Vijay
Guest
 
Posts: n/a
Default Re: Adding Virtual IP Address

Cameron Kerr <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Vijay <(E-Mail Removed)> wrote:
>
> > /sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
> > /sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
> > /sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up

>
> So what's assigned to eth0? (no alias)


eth0 has my machine IP (original ipaddress). I also tried shutting
down the interface using the following command as u mentioned, but in
vain.

'ifconfig eth0:1 down'

Thanks,
Vijay.
Reply With Quote
  #5  
Old 05-25-2004, 12:18 PM
Vijay
Guest
 
Posts: n/a
Default Re: Adding Virtual IP Address

Cameron Kerr <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Vijay <(E-Mail Removed)> wrote:
>
> > /sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
> > /sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
> > /sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up

>
> So what's assigned to eth0? (no alias)


Phew !!! I have configured the vips using the netmask as 255.255.255.0
and not 255.255.255.255 as mentioned in this mail. u ppl might have
helped, but for the typo. I m sorry. It works now.

Thanks for all ur efforts.

Vijay.
Reply With Quote
  #6  
Old 05-25-2004, 04:36 PM
P Gentry
Guest
 
Posts: n/a
Default Re: Adding Virtual IP Address

(E-Mail Removed) (Vijay) wrote in message news:<(E-Mail Removed) om>...
> Cameron Kerr <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> > Vijay <(E-Mail Removed)> wrote:
> >
> > > /sbin/ifconfig eth0:1 192.168.220.1 netmask 255.255.255.255 up
> > > /sbin/ifconfig eth0:2 192.168.220.2 netmask 255.255.255.255 up
> > > /sbin/ifconfig eth0:3 192.168.220.3 netmask 255.255.255.255 up


Of course, you know that there is no "real" /32 network -- wonder if
that is also part of the gotcha? See below ...

> > So what's assigned to eth0? (no alias)

>
> eth0 has my machine IP (original ipaddress). I also tried shutting
> down the interface using the following command as u mentioned, but in
> vain.
>
> 'ifconfig eth0:1 down'
>
> Thanks,
> Vijay.


You may be running into a shortcoming of ifconfig -- all things ip in
Linux run through the ip command. ifconfig uses ip for relatively
simple tasks but has not been re-written to interface with ip to
handle "aliases" very well.

With the extensive re-working of the IP stack in 2.2.?? links
(interfaces) and ip addresses are treated independently -- adds
greater flexibility to the configuration and routing code, etc.

Currently, with your approach, it _seems_ the first ip address you
assign is a "primary" address, the following are "secondary"
addresses. ip behavior is that if you delete the primary, the
secondaries will also be deleted. The details are not well documented
and I don't understand all the ramifications myself -- another gotcha
is that interfaces are referenced by index # in the code and
_sometimes_ the order of configuration matters (like here?). Not sure
just how ifconfig uses ip, but your netmask of /32 would be the
"right" approach with ip -- all primaries -- but the alias naming
causes a hiccup ...?

You should have a copy of ip-cref on your machine, or try here for an
html version:
http://linux-ip.net/gl/ip-cref/
There is a script -- ifcfg -- at the end that may help or shed light
....

This thread is not a full discussion, but may get you started ...
http://www.uwsg.iu.edu/hypermail/lin...10.3/0003.html
note: I was too busy to chase down the start

Have you tried adding/deleting the addresses with ip instead of
ifconfig? The "best" way may also depend on how/why you're using the
addresses.

Working through qdiscs can seem simple compared to some of the quirks
of ip/ifconfig ;-(

hth,
rpg
email above disabled
Reply With Quote
Reply

Tags
adding, address, virtual

Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump


All times are GMT. The time now is 03:11 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.