0

I am trying to do ip aliasing on my ubuntu 12.04 guest and it was not working.

host
11.x.11.2

guest 
11.x.11.3

guest is using bridge networking with host.

on guest specified

auto eth0
iface eth0 inet static
    address 11.x.11.2
    netmask 255.255.255.0
    network 11.x.11.0
    broadcast 11.x.11.255
    gateway 11.x.11.1

auto eth0:0
iface eth0:0 inet static
    address 11.x.11.3
    netmask 255.255.255.0
    network 11.x.11.0
    broadcast 11.x.11.255
    gateway 11.x.11.1

after network restart it was showing Failed to bring up eth0:0. .Even reboot also didnt work.

But when changed order in configuration and a network restart fixed the issue

auto eth0
iface eth0 inet static
address 11.x.11.3
netmask 255.255.255.0
network 11.x.11.0
broadcast 11.x.11.255
gateway 11.x.11.1

auto eth0:0
iface eth0:0 inet static
address 11.x.11.2
netmask 255.255.255.0
network 11.x.11.0
broadcast 11.x.11.255
gateway 11.x.11.1

But what difference this can make,

Blue Gene
  • 635
  • 1
  • 5
  • 10

1 Answers1

5

Interface aliases are seriously deprecated. The same effect can be achieved with a single stanza and an ip addr command (which is what modern ifupdown is using anyway):

auto eth0
iface eth0 inet static
    address 11.x.11.3
    netmask 255.255.255.0
    network 11.x.11.0
    broadcast 11.x.11.255
    gateway 11.x.11.1
    up ip addr add 11.x.11.2/24 dev eth0
    # no need for down, ifupdown flush all addresses on stop.

Now see the output of ip addr, and look how you don't need interface aliases to add several addresses to an interface. And forget about the deprecated ifconfig

BatchyX
  • 902
  • 4
  • 7
  • wow that is a good trick,i havent even heard of it. but how can we see signed ip,its not listing in ifconfig. – Blue Gene Mar 05 '13 at 09:42
  • 2
    @BlueGene: This is already explained in the answer: forget about the old deprecated `ifconfig` from 1999, and use `ip addr` instead. `ip addr` without any options will list the interfaces and addresses. – BatchyX Mar 05 '13 at 09:53
  • You don't need to call `ip addr` from an `up` directive. It's cleaner to just define a second `iface` stanza for `eth0`: https://wiki.debian.org/NetworkConfiguration#iproute2_method – AGWA Jun 26 '14 at 19:04