ifconfig not showing all IPs bound to the machine
Solution 1:
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, than 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.