brintos

brintos / linux-shallow public Read only

0
0
Text · 323 B · 88795b5 Raw
24 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.03#4# Execute a subprocess in a network namespace5 6set -e7 8readonly NETNS="ns-$(mktemp -u XXXXXX)"9 10setup() {11	ip netns add "${NETNS}"12	ip -netns "${NETNS}" link set lo up13}14 15cleanup() {16	ip netns del "${NETNS}"17}18 19trap cleanup EXIT20setup21 22ip netns exec "${NETNS}" "$@"23exit "$?"24