Web lists-archives.com

No ifconfig




Christian Seiler:

From my personal experience, the following two things are features I'm actually using regularly and that don't work with it:

  1. IPv6 doesn't really work properly (as explained elsewhere by other people in this thread)

  2. Can't add multiple IP addresses to the same interface and (worse) even if multiple IP addresses are assigned to the same interfaces it only shows the primary address

(2) is really bad, especially the part where it does not show all of the IPs that were assigned by other tools, for example NetworkManager, or Debian's own ifupdown via /etc/network/interfaces.


Your second point is a conflation of two things.  One is right, but the other is wrong.  Here is what actually happens.  Starting with this basis:

jdebp % ifconfig lo|head -n 4
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          inet6 addr: ::2/128 Scope:Compat
jdebp % ip address show lo|fgrep -A 1 inet
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.53.53.1/8 scope host secondary lo:0
       valid_lft forever preferred_lft forever
    inet6 ::2/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
jdebp %

ifconfig cannot see additional addresses assigned by the likes of ip in its simplest fashion, as here:

jdebp % sudo ip address add 127.53.0.1 dev lo
jdebp % ifconfig lo|head -n 4          
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          inet6 addr: ::2/128 Scope:Compat
jdebp % ip address show lo|fgrep -A 1 inet      
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.53.0.1/32 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.53.53.1/8 scope host secondary lo:0
       valid_lft forever preferred_lft forever
    inet6 ::2/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
jdebp %

But it most definitely can assign multiple IP addresses to a single interface, and these will be reported as such by ip even though ifconfig shows them differently:

jdebp % sudo ifconfig lo inet add 127.53.0.2
jdebp % ifconfig lo|head -n 4          
lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          inet6 addr: ::2/128 Scope:Compat
jdebp % ifconfig lo:0|head -n 2             
lo:0      Link encap:Local Loopback  
          inet addr:127.53.0.2  Mask:255.0.0.0
jdebp % ip address show lo|fgrep -A 1 inet      
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.53.0.1/32 scope host lo
       valid_lft forever preferred_lft forever
    inet 127.53.53.1/8 scope host secondary lo:0
       valid_lft forever preferred_lft forever
    inet 127.53.0.2/8 scope host secondary lo:1
       valid_lft forever preferred_lft forever
    inet6 ::2/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
jdebp %

Moreover, one can add multiple IP addresses to an interface with ip in such a way that ifconfig sees them, by assigning labels:

jdebp % sudo ip address del 127.53.0.1/32 dev lo
jdebp % sudo ip address add 127.53.0.1 dev lo label lo:2
jdebp % ifconfig lo:2|head -n 2                            
lo:2      Link encap:Local Loopback  
          inet addr:127.53.0.1  Mask:255.255.255.255
jdebp % 

One interesting tidbit in the aforegiven:  The network mask inference calculation differs.  ip inferred 127.53.0.1/32 whereas ifconfig inferred 127.53.0.2/8.