Initial commit

This commit is contained in:
Benjamin Collet 2018-04-07 21:40:38 +02:00
commit 35f2972e98
5 changed files with 90 additions and 0 deletions
if-pre-up.d

20
if-pre-up.d/netns Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
set -e
if [ -n "${IF_NETNS}" ]
then
# Create netns if it doesn't already exist, and bring up the loopback
if ! (ip netns list | grep -qx ${IF_NETNS})
then
mkdir -p /etc/netns/$IF_NETNS/network/{if-down.d,if-post-down.d,if-pre-up.d,if-up.d}
if [ ! -f /etc/netns/$IF_NETNS/network/interfaces ]; then
touch /etc/netns/$IF_NETNS/network/interfaces
fi
mkdir -p /run/network.${IF_NETNS}
rm -rf /run/network.${IF_NETNS}/*
ip netns add ${IF_NETNS}
ip netns exec ${IF_NETNS} ip link set lo up
fi
ip link set ${IFACE} netns ${IF_NETNS}
fi