systemd.network allows to create virtual network interface cards in different ways. The common type is MACVLAN where the virtual NIC has its own MAC address, which allows to assign separate IP addresses via DHCP/RA.
- Switch away from old /etc/network stuff to systemd. If you have special manual settings then adapt them to systemd.network
systemctl enable systemd-networkd.service
systemctl disable networking.service
systemctl status networking.service systemd-networkd.service
systemctl start systemd-networkd.service
systemctl stop systemd-networkd.service
systemctl status networking.service systemd-networkd.service
- Tell systemd.network which real existing NIC may have which virtual NIC via MACVLAN
/etc/systemd/system/eth0.network:
[Match]
Name=eth0
[Network]
DHCP=ipv4
MACVLAN=dnsextra01
MACVLAN=dnsextra02
- Define the virtual NIC itself via systemd.netdev (not the network on it)
/etc/systemd/system/eth0_dnsextra01.netdev
[Match]
[NetDev]
Description=Virtual Network Interface for Extra DNS Server Instance
Name=dnsextra01
Kind=macvlan
[MACVLAN]
Mode=bridge
- Define the network on the virtual NIC
/etc/systemd/system/eth0_dnsextra01.network
[Match]
Name=dnsextra01
[Network]
IPForward=yes
Address=192.168.0.98/24
- Enable arp/rp_filter to avoid connecting issues
/etc/sysctl.d/90_ipv4_arp_filter.conf
net.ipv4.conf.all.arp_filter=1
/etc/sysctl.d/90_ipv4_rp_filter.conf
net.ipv4.conf.all.rp_filter=1
- Apply sysctl changes and restart systemd.network (or reboot)
sysctl --system
systemctl restart systemd-networkd.service