netns 336 B

123456789101112131415
  1. #!/bin/sh
  2. set -e
  3. if [ -n "${IF_NETNS}" ]
  4. then
  5. unshare -m /bin/sh <<-EOF
  6. mount --make-rprivate /
  7. mount --bind /run/network.${IF_NETNS} /run/network
  8. if (ip netns exec ${IF_NETNS} ifquery --list | grep -qx ${IFACE}); then
  9. ip netns exec ${IF_NETNS} ifdown ${IFACE}
  10. fi
  11. ip netns exec ${IF_NETNS} ip link set netns 1 dev ${IFACE}
  12. EOF
  13. fi