Ubuntu second static IP, ifconfig, /etc/network/interfaces

ifconfiginterfaceipnetworkingUbuntu

I would like to add a second static IP to my local Ubuntu 11.10 desktop machine and have it automatically available after rebooting. So far I am successfully using ifconfig to to temporarily set up an alias for my primary network interface:

# ifconfig eth1:0 192.168.178.3 up
# ifconfig
eth1      Link encap:Ethernet  HWaddr c8:60:00:ef:a3:d9  
          inet addr:192.168.178.2  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::ca60:ff:feef:a3d9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:61929 errors:0 dropped:0 overruns:0 frame:0
          TX packets:64034 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:45330863 (45.3 MB)  TX bytes:28175192 (28.1 MB)
          Interrupt:42 Base address:0x4000 

eth1:0    Link encap:Ethernet  HWaddr c8:60:00:ef:a3:d9  
          inet addr:192.168.178.3  Bcast:192.168.178.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:42 Base address:0x4000

However, when I add the following to /etc/network/interfaces, the alias is not up and running as expected after a reboot:

# vi /etc/network/interfaces
auto eth1:0
iface eth1:0 inet static
    address 192.168.178.3
    netmask 255.255.255.0

I would like to know what to configure to get this to work. As a side note, I am running gnome shell.

Best Answer

Is Network Manager managing the interface? I have configured network manager not to touch the interfaces that I manage through /etc/network/interfaces by having the following in /etc/NetworkManager/NetworkManager.conf:

[ifupdown]
managed=false

When Network Manager is disabled for sure we can take a look at /etc/network/interfaces. Interface aliases are no longer recommended, but ip(8) can add more than one address to one interface. This can be done in /etc/network/interfaces as follows:

auto eth1
iface eth1 inet static
        address 192.168.178.2
        netmask 255.255.255.0
        gateway 192.168.178.1
        up ip addr add 192.168.178.3/24 dev eth1
        down ip addr del 192.168.178.3/24 dev eth1

Read the manpage of interfaces(5) and ip(8) for more information.