Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have configured multiple IP addresses on a ubuntu box, but when I run ifconfig it shows just one of them. I am able, however, to ping all other adresses assigned to this machine.

/etc/network/interface contents:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
     address 192.168.202.11
     netmask 255.255.255.0
     network 192.168.202.0
     broadcast 192.168.202.255
     gateway 192.168.202.1

# dns-* options are implemented by the resolvconf package, if installed   
dns-search idil.dz1.da

auto eth0:1    
iface eth0:1 inet static
     address 192.168.202.12   
     netmask 255.255.255.0

auto eth0:2
iface eth0:2 inet static
     address 192.168.202.13
     netmask 255.255.255.0

auto eth0:3
iface eth0:3 inet static
     address 192.168.202.14
     netmask 255.255.255.0

auto eth0:4
iface eth0:4 inet static
     address 192.168.202.15
     netmask 255.255.255.0

auto eth0:5
iface eth0:5 inet static
     address 192.168.202.16   
     netmask 255.255.255.0

However, the output of the ifconfig is only:

192.168.202.11

share|improve this question
    
ifconfig -a display everything? –  axlroden Dec 10 '12 at 9:12
    
it is showing only eth0 ip address..:( –  pankaj sharma Dec 10 '12 at 9:14
1  
Which Ubuntu release are you running? Please add your information to bug #921280 too. –  jdthood Dec 10 '12 at 11:52

2 Answers 2

ifconfig is essentially deprecated, although there are no plans that I am aware of to get rid of it. The replacement is the ip command. The modern equivalent of ifconfig on its own is ip address list.

Why has ifconfig been replaced with ip? Much new functionality has been added to Linux networking in the decades since ifconfig was written. This involved an entirely new API (netlink) for the userspace tool to speak to the kernel to configure the network. It was far more practical to write a new tool to better map the new functionality through the netlink API and down to the command line, then to try and adapt the old ifconfig tool. Check out the ip(8) manpage for all the cool new stuff that you can do now.

The kernel API used by ifconfig and the ifconfig tool itself remains for backwards compatibility, but this interface is blind to anything that does not easily map to the old model.

The reason that ifconfig doesn't show you the IP aliases is that it looks like they are being added by Debian's ifupdown (the package that handles /etc/network/interfaces) using a different mechanism that does not add the labels :1, :2, etc. So the ifconfig tool is blind to them, since the old API mandated these labels, and so the extra addresses do not map to the old API. From the ip-address(8) manpage:

          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.

The bugs linked in maggotbrain's answer seem to be focused around adding support to ifconfig to read addresses without labels. Another approach might be to arrange for ifupdown to create the addresses with labels, such that ifconfig will be able to see them without modification.

share|improve this answer

This is most likely a bug in the net-tools package and ifconfig specifically.

See the launchpad bugs here and here for additional information.

If you enter your interfaces manually, from the command line using ifconfig like this(following your above configuration):

sudo ifconfig eth0:1 192.168.202.12 netmask 255.255.255.0
sudo ifconfig eth0:2 192.168.202.13 netmask 255.255.255.0
sudo ifconfig eth0:3 192.168.202.14 netmask 255.255.255.0
sudo ifconfig eth0:4 192.168.202.15 netmask 255.255.255.0
sudo ifconfig eth0:5 192.168.202.16 netmask 255.255.255.0

You will have those interfaces show up, as expected, when running ifconfig.

These changes will not show up in your /etc/network/interfaces, however. So, you will need to add them in both places.

Note: This is also not persistent across interface resets, so you will need to re-run the commands upon restarting the interface/machine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.