You are not logged in.

#1 2024-12-15 03:41:20

gregbert
Member
Registered: 2015-06-07
Posts: 15

making ip link and addr commands persistent with systemd-networkd

Hi

i am new to macvlan. I've created a docker macvlan of 192.168.4.0, and there is a container on that network at 192.168.4.2 that I need to be able to reach from my typical network (192.168.2.0)
i've figured out how to do that, but the following ip commands need to be executed every time i reboot. I am using systemd-networkd

Is there a way to make these persistent in the configuration, or is the right/best answer to simply create a systemd unit file?

ip link add mynet-shim link enp8s0 type macvlan mode bridge
ip addr add 192.168.4.3/32 dev mynet-shim
ip link set mynet-shim up
ip route add 192.168.4.2/32 dev mynet-shim


for reference, here is how i set up the docker macvlan. it is persistent.

docker network create -d macvlan -o parent=enp8s0 \
   --subnet 192.168.0.0/16 \
   --gateway 192.168.4.1 \
   --ip-range 192.168.4.2/32 \
   --aux-address 'host=192.168.4.3' \
   mynet

I also have the necessary static route set on my router to direct 192.168.4.x traffic to my server. It all works. just want it to be persistent.

Offline

#2 2024-12-15 07:26:15

-thc
Member
Registered: 2017-03-15
Posts: 852

Re: making ip link and addr commands persistent with systemd-networkd

Offline

Board footer

Powered by FluxBB