-
-
Notifications
You must be signed in to change notification settings - Fork 32
Systemd Units and Netns
James Swineson edited this page Nov 2, 2017
·
2 revisions
You can use PrivateNetwork=yes to create a netns automatically when starting a systemd unit; but that netns is unnamed, which means it is hard to access it by user.
A systemd unit cannot use a named netns (created by ip netns add command) directly.
This project implements a way to let a systemd unit use a named netns.
Assume you want to put bar.service into netns foo, Create a file named /etc/systemd/system/bar.service.d/netns.conf and put the following content in:
[Unit]
[email protected]
[email protected]
[email protected]
[Service]
PrivateNetwork=yes
Do a systemctl daemon-reload afterwards. If you have enabled it, systemctl reenable bar.service too.
If you need automatic bridging or NAT, systemctl enable [email protected] or systemctl enable [email protected].