Last active
July 13, 2020 10:59
-
-
Save chenchun/b6dcbe2980952f6dd4962e0b9e57cdf5 to your computer and use it in GitHub Desktop.
#idea #veth
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
umount /var/run/netns/idea &> /dev/null || true | |
docker rm -vf idea &> /dev/null || true | |
ip link del p1 &> /dev/null || true | |
docker run -d --name=idea --net=none --restart=always chenchun/ideals | |
pid=`docker inspect -f {{.State.Pid}} idea` | |
mkdir -p /var/run/netns/ | |
touch /var/run/netns/idea | |
mount --bind /proc/$pid/ns/net /var/run/netns/idea | |
ip link add p1 type veth peer name p2 | |
ip link set p2 netns idea | |
ip netns exec idea ip ad add 138.68.240.8/32 dev p2 | |
ip netns exec idea ip link set p2 up | |
ip netns exec idea ip route add 169.254.0.1 dev p2 scope link | |
ip netns exec idea ip route add default via 169.254.0.1 dev p2 scope global | |
ip netns exec idea ip neigh add 169.254.0.1 dev p2 lladdr `cat /sys/class/net/p1/address` | |
ip link set p1 up | |
ip route add 138.68.240.8 dev p1 | |
idea server: | |
http://138.68.240.8:41017 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment