#vbox虛擬機1 ip netns add left ip link add name veth1 type veth peer name sw1-p1 ip link set dev veth1 netns left ip netns exec left ifconfig veth1 10.0.0.1/24 up ovs-vsctl add-br sw1 ovs-vsctl add-port sw1 sw1-p1 ip link set sw1-p1 up #vbox虛擬機2 ip netns add right ip link add name veth1 type veth peer name sw2-p1 ip link set dev veth1 netns right ip netns exec right ifconfig veth1 10.0.0.2/24 up ovs-vsctl add-br sw2 ovs-vsctl add-port sw2 sw2-p1 ip link set sw2-p1 up
vbox虛擬機1測試
ovs-vsctl add-port sw1 tun0 -- set Interface tun0 type=gre options:remote_ip=10.30.10.141
vbox虛擬機2blog
ovs-vsctl add-port sw2 tun0 -- set Interface tun0 type=gre options:remote_ip=10.30.10.145
vbox虛擬機1ip
root@controller-VirtualBox:~# ovs-vsctl show 29c5cc05-2a31-4f14-a304-3a697698f96a Bridge "sw1" Port "sw1" Interface "sw1" type: internal Port "sw1-p1" Interface "sw1-p1" Port "tun0" Interface "tun0" type: gre options: {remote_ip="10.30.10.141"} ovs_version: "2.5.2"
vbox虛擬機2rem
root@controller-VirtualBox:~# ovs-vsctl show 0f92aaa0-5385-48f5-a54a-644e05652f59 Bridge "sw2" Port "sw2-p1" Interface "sw2-p1" Port "sw2" Interface "sw2" type: internal Port "tun0" Interface "tun0" type: gre options: {remote_ip="10.30.10.145"} ovs_version: "2.5.2" root@controller-VirtualBox
root@controller-VirtualBox:~# ip netns exec left ping 10.0.0.2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.953 ms 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.609 ms
vbox虛擬機1get
ovs-vsctl add-port sw1 tun0 -- set Interface tun0 type=vxlan options:local_ip=10.30.10.145 options:remote_ip=10.30.10.141
vbbox虛擬機2虛擬機
ovs-vsctl add-port sw2 tun0 -- set Interface tun0 type=vxlan options:local_ip=10.30.10.141 options:remote_ip=10.30.10.145
vbox虛擬機1it
root@controller-VirtualBox:~# ovs-vsctl show 29c5cc05-2a31-4f14-a304-3a697698f96a Bridge "sw1" Port "sw1" Interface "sw1" type: internal Port "sw1-p1" Interface "sw1-p1" Port "tun0" Interface "tun0" type: vxlan options: {local_ip="10.30.10.145", remote_ip="10.30.10.141"} ovs_version: "2.5.2"
vbox虛擬機2io
root@controller-VirtualBox:~# ovs-vsctl show 0f92aaa0-5385-48f5-a54a-644e05652f59 Bridge "sw2" Port "sw2-p1" Interface "sw2-p1" Port "sw2" Interface "sw2" type: internal Port "tun0" Interface "tun0" type: vxlan options: {local_ip="10.30.10.141", remote_ip="10.30.10.145"} ovs_version: "2.5.2" root@controller-VirtualBox:~#
root@controller-VirtualBox:~# ip netns exec left ping 10.0.0.2 PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data. 64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.905 ms 64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.490 ms 2 packets transmitted, 2 received, 0% packet loss, time 1001ms rtt min/avg/max/mdev = 0.490/0.697/0.905/0.209 ms