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

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



Note: this email is purposely NOT word-wrapped butcause 
I'm having trouble with a conf file, 
and don't want word-wrapping in the wrong place adding confusion)


Does anyone know the correct way to add multiple secondary IPs 
(in other words, a base device IP, and 2 or more additional IPs) 
to one device interface, in this case, eth0.

I've many variations and can't get it. 
The commands that work on the command line, manually, 
don't seem to work right when placed into /etc/network/interfaces
There is no clear documentation on this anywhere in the Debian.org docs that I can find. 

I can get ONE secondary IP to work using the following, 
for example (the "n" is a numeric place holder, I have real, 
working numbers in the conf, of course):

# The primary network interface
allow-hotplug eth0
iface eth0 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
        up ip addr add nn.nnn.18.137/25 broadcast nn.nnn.18.255 label eth0:1 dev eth0
        down ip addr del nn.nnn.18.137/25 label eth0:1 dev eth0
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 206.123.64.245 206.123.69.4


As I mentioned, this configuration DOES work, I get the following output from "ip addr show":

# ip addr show
1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 100
    link/ether 00:13:72:57:92:1b brd ff:ff:ff:ff:ff:ff
    inet 12.171.179.107/27 brd 12.171.179.127 scope global eth0
    inet 12.171.179.108/27 brd 12.171.179.127 scope global secondary eth0:1
    inet6 fe80::213:72ff:fe57:921b/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 100
    link/ether 00:13:72:57:92:1c brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.50/24 brd 192.168.0.255 scope global eth1
    inet6 fe80::213:72ff:fe57:921c/64 scope link
       valid_lft forever preferred_lft forever
4: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit 0.0.0.0 brd 0.0.0.0


And everything functions normally.

Here's another example that DOES work:

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


The problem comes when I try to add a third IP (a second secondary IP).


# The primary network interface
allow-hotplug eth0
iface eth0 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
        up ip addr add nn.nnn.18.137/25 broadcast nn.nnn.18.255 label eth0:1 dev eth0
        up ip addr add nn.nnn.18.138/25 broadcast nn.nnn.18.255 label eth0:2 dev eth0
        down ip addr del nn.nnn.18.137/25 label eth0:1 dev eth0
        down ip addr del nn.nnn.18.138/25 label eth0:2 dev eth0
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 206.123.64.245 206.123.69.4

-- 

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


Reply to: