1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0 3 # 4 # Execute a subprocess in a network namespace 5 6 set -e 7 8 readonly NETNS="ns-$(mktemp -u XXXXXX)" 9 10 setup() { 11 ip netns add "${NETNS}" 12 ip -netns "${NETNS}" link set lo up 13 } 14 15 cleanup() { 16 ip netns del "${NETNS}" 17 } 18 19 trap cleanup EXIT 20 setup 21 22 ip netns exec "${NETNS}" "$@" 23 exit "$?"
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.