Advertisement
teknoraver

ip_netns

Dec 19th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.32 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. [ $# -eq 2 ] || exec echo "usage: $0 <pid> <name>"
  4.  
  5. pid=$1
  6. name=$2
  7.  
  8. if ! grep -q /netns /proc/mounts; then
  9.     ip netns add tmp$$
  10.     ip netns del tmp$$
  11. fi
  12.  
  13. if ! [ -d "/proc/$pid" ]; then
  14.     echo "PID $pid doesn't exist"
  15.     exit 1
  16. fi
  17.  
  18. >"/run/netns/$name"
  19. mount --bind "/proc/$pid/ns/net" "/run/netns/$name"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement