diff options
author | uvok cheetah | 2025-02-02 15:21:26 +0100 |
---|---|---|
committer | uvok cheetah | 2025-02-02 15:21:26 +0100 |
commit | 526797b41c8dfffc7e74a951c17ef96734980e7a (patch) | |
tree | 84e562022de12f2cedc089ae8d0cbfdc02c595e9 /roles/linux-ns/files/systemd/my-netns@.service | |
parent | 0ee94b306e667225b64804f169f15a961e966511 (diff) |
Add role for Dn42 and network namespace
Diffstat (limited to 'roles/linux-ns/files/systemd/my-netns@.service')
-rw-r--r-- | roles/linux-ns/files/systemd/my-netns@.service | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/roles/linux-ns/files/systemd/my-netns@.service b/roles/linux-ns/files/systemd/my-netns@.service new file mode 100644 index 0000000..7368028 --- /dev/null +++ b/roles/linux-ns/files/systemd/my-netns@.service @@ -0,0 +1,32 @@ +# actual setup of the minimal namespace + +[Unit] +Description=Named network namespace %I +Documentation=https://github.com/Jamesits/systemd-named-netns + +After=network-pre.target +Before=network.target network-online.target + +[Install] +WantedBy=network-online.target +WantedBy=multi-user.target + +[Service] +Type=oneshot +RemainAfterExit=yes + +# precaution +ExecStartPre=-/usr/bin/env ip netns delete %I + +# set up netns and bind it to this service +ExecStart=/usr/bin/flock --no-fork -- /var/run/netns.lock /usr/bin/env ip netns add %I +ExecStart=/usr/bin/env ip link add veth%I type veth peer vethpeer%I netns %I +ExecStart=/usr/bin/env ip link set veth%I up +ExecStart=/usr/bin/env ip netns exec %I ip link set vethpeer%I name eth0 +ExecStart=/usr/bin/env ip netns exec %I ip link set lo up +ExecStart=/usr/bin/env ip netns exec %I ip link set eth0 up + +# remove the netns +ExecStop=/usr/bin/env ip link del veth%I +# type veth peer vethpeer%I netns %I +ExecStop=/usr/bin/env ip netns delete %I |