本文主要是介绍openvswitch实践二 vxlan隧道互联互通,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1.试验环境
2.试验配置
2.1 host 172.16.0.100 配置
ovs-vsctl add-br br1
ovs-vsctl add-br br2
ovs-vsctl add-port br1 tap1 -- set Interface tap1 type=internal
ovs-vsctl add-port br2 tap2 -- set Interface tap2 type=internal
ip netns add ns1
ip netns add ns2
ip link set tap1 netns ns1
ip link set tap2 netns ns2
ip netns exec ns1 ip addr add 1.1.1.1/24 dev tap1
ip netns exec ns1 ip link set tap1 up
ip netns exec ns1 ip link set lo up
ip netns exec ns2 ip addr add 1.1.1.2/24 dev tap2
ip netns exec ns2 ip link set tap2 up
ip netns exec ns2 ip link set lo up
ovs-vsctl add-port br1 patch-ovs-1 -- set Interface patch-ovs-1 type=patch options:peer=patch-ovs-2
ovs-vsctl add-port br2 patch-ovs-2 -- set Interface patch-ovs-2 type=patch options:peer=patch-ovs-1
2.2 host172.16.1.75 配置
ovs-vsctl add-br br1
ovs-vsctl add-br br2
ovs-vsctl add-port br1 tap1 -- set Interface tap1 type=internal
ovs-vsctl add-port br2 tap2 -- set Interface tap2 type=internal
ip netns add ns1
ip netns add ns2
ip link set tap1 netns ns1
ip link set tap2 netns ns2
ip netns exec ns1 ip addr add 1.1.1.3/24 dev tap1
ip netns exec ns1 ip link set tap1 up
ip netns exec ns1 ip link set lo up
ip netns exec ns2 ip addr add 1.1.1.4/24 dev tap2
ip netns exec ns2 ip link set tap2 up
ip netns exec ns2 ip link set lo up
ovs-vsctl add-port br1 patch-ovs-1 -- set Interface patch-ovs-1 type=patch options:peer=patch-ovs-2
ovs-vsctl add-port br2 patch-ovs-2 -- set Interface patch-ovs-2 type=patch options:peer=patch-ovs-1
2.3 vxlan通道配置
host 172.16.1.75
ovs-vsctl add-port br1 vx1 -- set interface vx1 type=vxlan options:remote_ip=172.16.0.100 options:key=100
host 172.16.0.100
ovs-vsctl add-port br1 vx1 -- set interface vx1 type=vxlan options:remote_ip=172.16.1.75 options:key=100
3.试验验证
3.1 ping验证
3.2 抓包验证
4 vxlan tunnel 补充
# key=flow的话,表示该port的vni可以通过openflow的actions来进行设置
# 如: actions=set_field:100->tun_id
# 或: actions=set_tunnel:100
ovs-vsctl add-port ovs0 vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip=10.10.10.1 options:key=flow
指定flow流表进行转发
host 172.16.1.75
ovs-vsctl add-port br1 vx1 -- set interface vx1 type=vxlan options:remote_ip=172.16.0.100 options:key=flow
ovs-ofctl dump-ports-desc br1
OFPST_PORT_DESC reply (xid=0x2):
1(tap1): addr:00:00:00:00:00:00
config: PORT_DOWN
state: LINK_DOWN
speed: 0 Mbps now, 0 Mbps max
2(patch-ovs-1): addr:62:91:1f:1e:59:08
config: 0
state: 0
speed: 0 Mbps now, 0 Mbps max
4(vx1): addr:46:29:c3:cc:f2:2b
config: 0
state: 0
speed: 0 Mbps now, 0 Mbps max
LOCAL(br1): addr:36:10:88:95:d2:ea
config: PORT_DOWN
state: LINK_DOWN
speed: 0 Mbps now, 0 Mbps max
ovs-ofctl add-flow br1 'cookie=0x79, table=0, in_port=1, priority=1 actions=set_tunnel:200,output:4'
host 172.16.0.100
ovs-vsctl add-port br1 vx1 -- set interface vx1 type=vxlan options:remote_ip=172.16.1.75 options:key=flow
ovs-ofctl add-flow br1 'cookie=0x79, table=0, in_port=1, priority=1 actions=set_tunnel:200,output:6'
这篇关于openvswitch实践二 vxlan隧道互联互通的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!