Created
October 8, 2018 07:46
-
-
Save luohao-brian/54e010c221c5b78b4c145a400e2ac0e6 to your computer and use it in GitHub Desktop.
Linux Networking Scripts
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
# 创建2个ns, 分别用veth连接在ns1和ns2, 接在ovs网桥br1上 | |
# ns1 & ns2 | |
ip netns add ns1 | |
ip netns add ns2 | |
# tap1 & tap2 | |
ip link add tap1 type veth peer name ovs-tap1 | |
ip link add tap2 type veth peer name ovs-tap2 | |
# veth01=>ns1, veth02=>ns2 | |
ip link set tap1 netns ns1 | |
ip link set tap2 netns ns2 | |
# ovs | |
ovs-vsctl add-br br1 | |
ovs-vsctl add-port br1 ovs-tap1 | |
ovs-vsctl add-port br1 ovs-tap2 | |
ip link set dev ovs-tap1 up | |
ip link set dev ovs-tap2 up | |
# ns1 netdev ip setup | |
ip netns exec ns1 ip link set dev tap1 up | |
ip netns exec ns1 ifconfig tap1 192.168.88.2 netmask 255.255.255.0 | |
# ns2 netdev ip setup | |
ip netns exec ns2 ip link set dev tap2 up | |
ip netns exec ns2 ifconfig tap2 192.168.88.3 netmask 255.255.255.0 | |
# clean up | |
ovs-vsctl del-br br1 | |
ip netns del ns1 | |
ip netns del ns2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment