[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: virtual interfaces not routing properly.



Gareth Walters (2K Australia) wrote:
> But its not working out side the same subnet (i.e. routing is wrong) 

What is wrong about it?  Can you show the routing table and identify
what is incorrect?  Since you don't show the problem there isn't a way
to guess.

> /etc/network/interfaces
> auto lo eth0 eth0:0 eth0:1 eth0:2
> iface eth0 inet static
>         address 10.25.48.140
>         netmask 255.255.255.0
>         network 10.25.48.0
>         gateway 10.25.48.254

It would be good to remove the 'network' line.  It isn't needed.  It
will be calculated from the netmask.  Less likely to make a mistake if
you let the program calculate it.  Simpler is better.

> iface eth0:0 inet static
>         address 10.25.48.141
>         netmask 255.255.255.0
> 
> iface eth0:1 inet static
>         address 10.25.48.142
>         netmask 255.255.255.0
> 
> iface eth0:2 inet static
>         address 10.25.48.145
>         netmask 255.255.255.0

That is rather an old-style way of setting up the aliases on the
network.  It basically mirrors the 'ifconfig' usage.  But slowly over
time the ifconfig usage is being phased out and replaced with the
newer 'ip' usage.  (And likewise 'iw' is replacing 'iwconfig'.)  This
is reflecting Linux kernel interface changes because Linux now treats
aliased virtual interfaces differently than before.  This is causing
the changes to ripple down.

As ifupdown transitions from one way to the other way the result has
been a little unstable.  I think it is mostly fixed now, I haven't
looked at it in a couple of months.  I am sure it will be stable for
Wheezy.  But there have been some problems in the transition in Sid
from 'ifconfig' to 'ip'.

The problem I see with the above style of doing things is that eth0:X
is dependent upon eth0 but is treated as if it isn't.  Is it possible
to bring one up without the other?  It's a design issue.

Instead I prefer setting up the dependent aliased virtual interfaces
to be explicitly brought up and down when the main interface is
brought up and down.  I think this simplifies the configuration
significantly and reduces problems.

This method is documented here among other places.  Look at the very
bottom of the page under "Multiple IP addresses on One Interface".

  http://wiki.debian.org/NetworkConfiguration

You might want to try this configuration instead.

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
        address 10.25.48.140
        netmask 255.255.255.0
        gateway 10.25.48.254
	up   ip addr add 10.25.48.141/24 dev eth0 label eth0:0
	down ip addr del 10.25.48.141/24 dev eth0 label eth0:0
	up   ip addr add 10.25.48.142/24 dev eth0 label eth0:1
	down ip addr del 10.25.48.142/24 dev eth0 label eth0:1
	up   ip addr add 10.25.48.145/24 dev eth0 label eth0:2
	down ip addr del 10.25.48.145/24 dev eth0 label eth0:2

With the above there is the main interface eth0.  When it is brought
online it will bring the listed aliased virtual interfaces online.
And it will bring them down before bringing down the interface.  The
set is tightly coupled.  They won't get out of sync with each other.

Hope that helps,
Bob

Attachment: signature.asc
Description: Digital signature


Reply to: