Skip to content

Systemd Units and Netns

James Swineson edited this page Nov 2, 2017 · 2 revisions

Put a systemd service to that 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]
BindsTo=netns@foo.service
After=netns@foo.service
JoinsNamespaceOf=netns@foo.service

[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 netns-bridge@foo.service or systemctl enable netns-nat@foo.service.

Clone this wiki locally