Skip to content

Instantly share code, notes, and snippets.

@marineam
Created December 3, 2014 19:23
Show Gist options
  • Save marineam/c9dd841afd218f7d021e to your computer and use it in GitHub Desktop.
Save marineam/c9dd841afd218f7d021e to your computer and use it in GitHub Desktop.
#!/bin/bash
# And now we cry because --network-interface on systemd-nspawn is broken. :(
set -e
NAME="$1"
shift
for retry in {1..5}; do
if machinectl status "$NAME" &>/dev/null; then
break
else
sleep 0.1
fi
done
LEADER=$(machinectl show "$NAME" --property=Leader)
PID="${LEADER#Leader=}"
echo "Moving interfaces to net namespace of $NAME ($PID): $*"
for IF in "$@"; do
ip link set dev "$IF" netns "$PID"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment