基于NEUTRON VXLAN网络实践01-VPC实现手动实现了NEUTRON的VPC网络的设计。本文中,介绍以下内容:
- 创建VPC 时,流表的变化
- 网络节点的设计与实现
创建VPC
VPC参数:
- CIDR: 10.20.10.0/24
- vni : 0x33
假设compute1和compute2上均有一台虚拟机在此VPC内:
- VM1: 10.20.10.11
- VM2: 10.20.10.12
- VM1,local_vlan: 33
- VM2,local_vlan: 43
按以上参数,设计此VPC网络:
利用namspace模拟虚拟机。
Compute1:
添加linux bridge:
#brctl addbr qbr124
#ip link set qbr124 up
添加veth口,连接br-int,qbr124:
#ip link add name qvo124 type veth peer name qvb124
#ip link set qvo124 up
#ip link set qvb124 up
#ovs-vsctl add-port br-int qvo124
#brctl addif qbr124 qvb124
设置local vlan:
#ovs-vsctl set port qvo124 tag=33
添加测试namespace:
#ip netns add test124
#ip link add veth124 type veth peer name veth124p
#ip link set dev veth124 netns test124
#brctl addif qbr124 veth124p
#ip link set veth124p up
#ip netns exec test124 ip link set veth124 up
#ip netns exec test124 ip addr add 10.20.10.11/24 dev veth124
Compute2:
添加linux bridge:
#brctl addbr qbr124
#ip link set qbr124 up
添加veth口,连接br-int,qbr124:
#ip link add name qvo124 type veth peer name qvb124
#ip link set qvo124 up
#ip link set qvb124 up
#ovs-vsctl add-port br-int qvo124
#brctl addif qbr124 qvb124
设置local vlan:
#ovs-vsctl set port qvo124 tag=43
添加测试namespace:
#ip netns add test124
#ip link add veth124 type veth peer name veth124p
#ip link set dev veth124 netns test124
#brctl addif qbr124 veth124p
#ip link set veth124p up
#ip netns exec test124 ip link set veth124 up
#ip netns exec test124 ip addr add 10.20.10.12/24 dev veth124
流表设计
添加VPC后,打通VPC内的虚机,主要涉及VXLAN进出流量的处理,涉及table 4及table 22
table 4流表,主要处理入流量:
compute1:
#ovs-ofctl add-flow br-tun 'cookie=0x79, table=4, priority=1,tun_id=0x33 actions=mod_vlan_vid:33,resubmit(,10)'
compute2:
#ovs-ofctl add-flow br-tun 'cookie=0x79, table=4, priority=1,tun_id=0x33 actions=mod_vlan_vid:43,resubmit(,10)'
table 22流表,主要处理出流量:
compute1:
#ovs-ofctl add-flow br-tun 'cookie=0x79, table=22, dl_vlan=33 actions=strip_vlan,set_tunnel:0x33,output:8'
compute2:
#ovs-ofctl add-flow br-tun 'cookie=0x79, table=22, dl_vlan=43 actions=strip_vlan,set_tunnel:0x33,output:7'
验证连通性:
compute1上pinc测试
[root@localhost ~]# ip netns exec test124 ping 10.20.10.12
PING 10.20.10.12 (10.20.10.12) 56(84) bytes of data.
64 bytes from 10.20.10.12: icmp_seq=1 ttl=64 time=2.50 ms
64 bytes from 10.20.10.12: icmp_seq=2 ttl=64 time=0.541 ms
64 bytes from 10.20.10.12: icmp_seq=3 ttl=64 time=0.515 ms
64 bytes from 10.20.10.12: icmp_seq=4 ttl=64 time=0.553 ms
^C
--- 10.20.10.12 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3001ms
rtt min/avg/max/mdev = 0.515/1.028/2.503/0.851 ms
网友评论