9

We have a server with multiple IP adresses. Lately we migrated to systemd and we still need mutliple IPs on that server. With systemd-networkd we have some trouble finding a configuration example. so we use a bash script at the end of the boot process to add the ips to the interface.

Can someone provide a systemd-networkd config example for adding more than one IP to one interface.

  • Have you checked man systemd.network ? Just a sidenote, you don't have to go ALL in an use systemd-networkd. What distribution are we talking about? – phoops Jul 2 '14 at 7:09
  • We checked the manpage. I think it is very compatible and portable if we use systemd-netword, as it will be available on all distros soon. Distro is gentoo. – user61664 Jul 2 '14 at 7:35
11

According to systemd.network(5), you can simply add multiple Address= lines to the [Network] section, with the required addresses.

[Network]
Address=10.2.3.4/16
Address=10.6.7.8/16
Gateway=...

Alternatively, create a separate [Address] section for each address.

[Network]
Gateway=...

[Address]
Address=10.2.3.4/16

[Address]
Address=10.6.7.8/16

(The same applies to [Route] sections and Gateway= parameters.)

Note that systemd-networkd is still very new and receives bug fixes almost daily. Make sure you're using the latest systemd release, and test the Git builds if possible. See the mailing list and the IRC channels #systemd & #gentoo-systemd on freenode in case of bugs.

  • 3
    In Ubuntu 16.04 LTS, the first method does not seem to work (only the first IP address is reachable). However, the second method, with separate [Address] sections, does work. For what it's worth, I have defined a single gateway under the [Network] section, as in the second example. I should add also that I am unable to get two static IP addresses working on two separate physical network interfaces, no matter what I try (I have yet to find an example of this in the systemd documentation or elsewhere on the web), so I'm left to settle for two IP addresses on a single interface. – Ben Johnson Sep 23 '16 at 16:56
1

I'm using a container under Proxmox, and Proxmox writes its own /etc/systemd/network/eth0.network in the container. To get around not being able to rely on that file not being overwritten, you can create a drop-in file with the additional IP address(es), /etc/systemd/network/eth0.network.d/additional-ips.conf

[Match]
Name = eth0

[Address]
Address = 192.168.1.102/24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.