Skip to content

Instantly share code, notes, and snippets.

@pottedplant
Last active December 17, 2017 12:52
Show Gist options
  • Save pottedplant/6e7f6fa3caa0a348dd0093943c030437 to your computer and use it in GitHub Desktop.
Save pottedplant/6e7f6fa3caa0a348dd0093943c030437 to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
IFNAME=vei_`date +'%s'`
unshare --mount -- bash -e -c \
"
mount -t tmpfs none /etc/isolation_redirects/net
touch /etc/isolation_redirects/net/ns
unshare --net -- bash -e -c \\
\"
ip link add veth0 type veth peer name $IFNAME
ip link set $IFNAME netns /proc/1/ns/net
mount -o bind /proc/\\$\\$/ns/net /etc/isolation_redirects/net/ns
\"
ip link set $IFNAME up
brctl addif lxd.sandbox $IFNAME
touch /etc/isolation_redirects/net/resolv.conf
nsenter --net=/etc/isolation_redirects/net/ns -- bash -e -c \\
\"
busybox udhcpc -i veth0
echo 'success, spawning shell'
/bin/bash -l
\"
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment