I would like to instruct systemd to 'run a unit' in a specified, pre-existing network namespace, in particular to start the unit's process(es) in the namespace.
2 Answers
Looks like it's now possible to do this in systemd 242 via the NetworkNamespacePath
option: announcement.
Check out the docs for use it here.
systemd is not fully compatible with network namespace as the issues https://github.com/systemd/systemd/issues/2741, may add some other key words like ExecStart to add network namespace switch into namespace before running service.
-
The
NetworkNamespacePath
option was introduced in 2019. Consequently, I believe this answer is out of date and/or misleading, and the answer should be updated or deleted.– mpbJul 9, 2023 at 21:39
JoinsNamespaceOf=
if systemd created the namespace for the other process.