Skip to content

Instantly share code, notes, and snippets.

@timcharper
Last active October 22, 2023 13:05
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save timcharper/d547fbe13bdd859f4836bfb02197e295 to your computer and use it in GitHub Desktop.
Macvlan using systemd

Before

yum install -y systemd-networkd
modprobe macvlan # make sure this returns no errors

Put config files in place

eth0.network and mac0.{netdev,network} go in /etc/systemd/network/ macvlan.service goes in /etc/systemd/system/

...

After

systemctl daemon-reload
systemctl enable systemd-networkd
systemctl enable macvlan

Notes

[Match]
Name=eth0
[Network]
MACVLAN=mac0
[NetDev]
Name=mac0
Kind=macvlan
[MACVLAN]
Mode=bridge
[Match]
Name=mac0
[Network]
IPForward=yes
Address=10.11.12.51/24
[Unit]
After=network.target
Before=network-online.target
[Service]
Type=oneshot
ExecStart=/sbin/ip link set eth0 promisc on
RemainAfterExit=yes
[Install]
WantedBy=network-online.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment