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

Re: Correct way to add multiple "secondary IPs"to one dev/interface in /etc/network/interfaces?



On Friday 21 December 2007 13:42, Adrian Levi wrote:
> On 22/12/2007, Jonathan Wilson <jw@mailsw.com> wrote:
> > Here's the most important example from the original post. It works as-is.
> > If I uncomment the commented "up" and "down" lines, everything breaks.
> > Yes, I have real numbers and not nnn in the real config file.:
> >
> > allow-hotplug eth0
> > iface eth0 inet static
> >         address nn.nnn.179.107
> >         netmask 255.255.255.224
> >         broadcast nn.nnn.179.127
> >         gateway nn.nnn.179.97
> >         up ip addr add nn.nnn.179.108/27 broadcast nn.nnn.179.127 label
> > eth0:1 dev eth0 
> > #        up ip addr add nn.nnn.179.109/27 broadcast 
> > nn.nnn.179.127 label eth0:2 dev eth0 
> > down ip addr del nn.nnn.179.108/27 
> > label eth0:1 dev eth0 
> > #        down ip addr del nn.nnn.179.109/27 label 
> > eth0:2 dev eth0
> > # dns-* options are implemented by the resolvconf 
> > package, if installed
> > dns-nameservers 192.168.0.8 192.168.0.16 
>
> Use a new stanza like this for each new interface you want to add to
> an existing interface, you really don't need to be playing with route.
>
> iface eth0:1 inet static
>        address nn.nnn.18.175
>        netmask 255.255.255.128
>        network nn.nnn.18.128/25
>        broadcast nn.nnn.18.255
>        gateway nn.nnn.18.129
>
> In the above example your chanding the routing information to an
> interface eth0:1 and eth0:2 that dosen't actually exist.
>
>
> Adrian

Hi Adrian,

"iface eth0:1 inet static" and so on is exactly the way I used to do it, but 
that creates IP aliases (like as you would when using "ifconfig' manually") 
instead of secondary ips (like when you do "ip addr add" manually".

In my above example, "eth0:1" and such are only labels. "man ip" says: 

"Each  address  may be tagged with a label string.  In order to preserve 
compatibility with Linux-2.0 net aliases, this
              string must coincide with the name of the device or must be 
prefixed with the device name followed by colon."

Are you sure this messes with the routing? I do not know, I'm not an expert. 
But I thought from examples on this page: 
http://www.debian.org/doc/manuals/reference/ch-gateway.en.html (see section 
10.2.2. and surrounding) that this is the right way to do it.

Thanks,

	JW

-- 

----------------------
System Administrator - Cedar Creek Software
http://www.cedarcreeksoftware.com


Reply to: