手動建立veth pair

dpid="`docker inspect -f '{{.State.Pid}}' hello`"
echo $dpid

mkdir -p /var/run/netns
sudo ln -snf /proc/${dpid}/ns/net /var/run/netns/${dpid}
sudo ip link add q${dpid} type veth peer name r${dpid}
sudo ip link set q${dpid} master br0
sudo ip link set q${dpid} up
sudo ip link set r${dpid} netns ${dpid}
sudo ip netns exec ${dpid} ip link set dev r${dpid} name eth0
sudo ip netns exec ${dpid} ip link set eth0 up
sudo ip netns exec ${dpid} ip addr add 192.168.43.10/24 brd 192.168.43.255 dev eth0
sudo ip netns exec ${dpid} ip route add default via 192.168.43.1

Last updated