5

I am trying to port the following alias from /etc/network/interfaces to /etc/systemd/network/eth0.network.

auto eth0:1 iface eth0:1 inet static address 10.0.2.1/24 
3
  • You don't. Interface aliases don't exist anymore. Commented Aug 5, 2020 at 18:54
  • @MichaelHampton Thanks Michael, so how can I add another IP to eth0 then? I am trying to solve serverfault.com/questions/1029000/…. Commented Aug 5, 2020 at 18:56
  • It's a container, not a real VM. You probably don't. Commented Aug 5, 2020 at 19:00

1 Answer 1

5

As Michael pointed out, you don’t.

Instead, you add additional Address= and Gateway= lines to the interface.

Example:

$ cat /etc/systemd/network/eth0.network [Match] Name=eth0 [Network] Address=2a0a:3840:1337:126::b9c1:7ecb:1337/64 Gateway=2a0a:3840:1337:126::1 IPv6AcceptRA=no Address=185.193.126.203/24 Gateway=185.193.126.1 DNS=95.215.19.53 [DHCP] UseDNS=false 
3
  • Thank you for this information! Additionally on my machine the config file is named 10-eth0.network is there any significance for this number prefix ? Commented Jan 18, 2023 at 11:18
  • The problem with this is that if you want to set up address-specific config (e.g. which source IP to use for multicast traffic), you can't control which address it gets attached to. You need an alias interface so your route can apply to one interface/IP but not the other. Commented Jul 11, 2024 at 9:01
  • Convert the Address line into an [Address] section and add Label=eth0:1. This should match exactly the old ifupdown behavior. See superuser.com/a/1008200/143635 for an example. Commented Sep 26 at 16:44

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.