Hacker News new | ask | show | jobs
by klaasvakie 2953 days ago
I've never understood the purpose of IP aliases like the "secondary em0" the author is setting up with systemd.networkd. These aliases are practically useless, you cannot bind() to them without knowing the IP, you cannot use them in firewall rules, you cannot setup dhcp for them etc. What are people using them for?

I'm not sure what the low level difference is between an alias like in the article, or a "eth0:1" type alias (made with ifconfig eth0:1 xx.xx.xx.xx up), but the "eth0:1" type alias seems infinitely more useful.

This is also a major deficiency of the Ubuntu 18.04 netplan implementation, it can only do the systemd.networkd type aliases and not the "eth0:1" type ones. What gives?

4 comments

People don't seem to use them on Linux for containers, but on FreeBSD that was the way to set up IP addresses for jails. You just had tons of aliases on an interface and you gave these IPs to jails. Anything that binds to 0.0.0.0 inside a jail gets bound to the jail's IP.

Now you can use VNET/VIMAGE to give jails separate virtual network interfaces. If you want to. The option to use aliases is still there of course.

> What are people using them for?

In my case, keepalived VRRP floating addresses.

I've used eth0:xx style aliases for that for a decade with no problem. Do you know what the difference is?
Yeah, your eth0:xx is just a label (a tag of sorts) attached to the entry. Otherwise, they're exactly the same thing.

You can even add an address with `ip addr add' that will be visible to ifconfig.

Dont know, but when I used to do index arb trading they had vlans on virtual IPs on bonds and ifconfig simply couldn't show the addresses. 'ip' could
Yep. It was kind of funny watching a couple graybeards trying to figure out how keepalived was assigning addresses and how to view them. It’s a rare treat when you can help someone like that with something they might normally help you with.
In many cases, the IP is the thing that comes first and foremost. You'll put it in DNS, you'll bind services to it (often because that's what the DNS is pointing to) or use it for outgoing traffic, and so on. Any interface name for it is simply an implementation detail, and you can live without it and even simplify your life if you don't have to come up with and keep track of those names.

(This is especially the case if you may at some point shift an IP alias between systems in order to move traffic from one to the other.)

FreeBSD just lists those IPs under the interface.