Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Huh?!?

I use multiple addresses a lot, and recall having used them through ifconfig for years, probably well over a decade. Anyway, at least on Debian, the package net-tools brings ifconfig it back, again with full multiple addresses support.

  # uname -v
  #1 SMP Debian 5.4.19-1 (2020-02-13)


  # ifconfig
  enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.42  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::2e4d:54ff:fed8:7b59  prefixlen 64  scopeid 0x20<link>
        ether 2c:4d:54:d8:7b:59  txqueuelen 1000  (Ethernet)
        RX packets 1162942  bytes 1627138668 (1.5 GiB)
        RX errors 0  dropped 42049  overruns 0  frame 0
        TX packets 546159  bytes 41181499 (39.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 16  bytes 818 (818.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 818 (818.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


  # ifconfig enp2s0:1 192.168.1.42

  # ifconfig
  enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.10.42  netmask 255.255.255.0  broadcast 192.168.10.255
        inet6 fe80::2e4d:54ff:fed8:7b59  prefixlen 64  scopeid 0x20<link>
        ether 2c:4d:54:d8:7b:59  txqueuelen 1000  (Ethernet)
        RX packets 1163011  bytes 1627147417 (1.5 GiB)
        RX errors 0  dropped 42089  overruns 0  frame 0
        TX packets 546185  bytes 41184061 (39.2 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  enp2s0:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.42  netmask 255.255.255.0  broadcast 192.168.1.255
        ether 2c:4d:54:d8:7b:59  txqueuelen 1000  (Ethernet)

  lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 16  bytes 818 (818.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16  bytes 818 (818.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


    ifconfig enp2s0:1 192.168.1.42
Now try

    ip addr add dev enp2s0 192.168.42.1/24
and observe how ifconfig ignores the second IP on the same interface. enp2s0:1 is an alias to enp2s0, not enp2s0 itself. To replicate your ifconfig command, you'd use

    ip addr add dev enp2s0 192.168.1.42/32 label enp2s0:1
and then it shows up in ifconfig as well.


You're right, it's not exactly the same thing and both approaches (with an alias and without) have their uses. ifconfig forcing you to come up with a unique label can be annoying when you want some script to add a new address to an interface without having to go handle the error case of "but what if <iface>:1 is already used?".

Meanwhile having an explicit label can be nice in other situations if you want to replace an address instead of merely adding a new one.

I also seem to recall running into issues dealing with IPv6 with ifconfig that I worked around by switching to ip. I don't remember the specifics however.

Overall I wish ifconfig had been updated, I still find it a lot more user friendly that iproute. In particular the default output of a plain "ifconfig" is vastly more readable IMO: https://svkt.org/~simias/up/20200319-165513_ip.png

In general these days I use ip in scripts and ifconfig (when available) interactively. I don't love having to remember two ways of doing the same thing but I can't rely on ifconfig being available in scripts anymore and I just waste too much time parsing ip's bad output when I'm messing with networking interactively.


Understood, thanks, I'm so used to ifconfig that always tried to avoid using ip. Time to learn it I guess.


I spend a lot of times dealing with new devices. Plug it into the same VLAN as my desktop and then in a term:

# ip a a 192.168.1.32/24 dev eth0

Then put 192.168.1.1 into browser etc. Do job. Back to term. Up arrow to get last command, change the second a to d (for delete) and the extra address is gone.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: