neutron flat和vxlan网络访问外网流量走向

OpenStack版本:Mitaka

物理节点:

Hostname Management IP Tunnel IP Role
test-ctrl-01 192.168.100.11 192.168.120.11 Controller Node、Network Node
test-cmpt-01 192.168.100.21 192.168.120.21 Compute Node
test-cmpt-02 192.168.100.22 192.168.120.22 Compute Node

 

 

 

 

Neutron网络:

网络 网络类型 网络模式 子网
public_net External Network Flat 192.168.100.0/24
share_net Private Network Vxlan 192.168.111.0/24

 

 

 

网络拓扑:

 

虚拟机:

test-01:直接连接到public_net,fixed ip为192.168.100.101

test-02:连接到share_net,fixed ip 192.168.111.4,绑定floating ip 192.168.100.102

特意将两个虚拟机建到同一台宿主机test-cmpt-02上,方便进行对比。

 

网络节点test-ctrl-01的网桥结构图:

计算节点test-cmpt-02上的网桥结构图:

flat网络(虚拟机test-01)访问外网的流量

1. 数据包从虚拟网卡tapaf305168-66出来,到达网桥qbraf305168-66,此处有iptables规则做IP/MAC pairs的匹配,如果配置了安全组规则,还会有对应的iptables规则:

2. 通过qvbaf305168-66和qboaf305168-66这对peer,到达br-int。由于qboaf305168-66在br-int上的vlan tag是2(类似交换机的access口),数据包的vlan_id会被标记成2。

3. br-int的flow table对ip和mac进行过滤,防止ip和mac伪造:

可以看到对arp和icmp有ip和mac的匹配。对mac的检测在mitaka版本以后都有,而kilo版只有arp_spa的规则。

这是些规则是neutron-openvswitch-agent添加的,具体实现在neutron.plugins.ml2.drivers.openvswitch.agent.openflow.ovs_ofctl.br_int. OVSIntegrationBridge的install_icmpv6_na_spoofing_protection(), set_allowed_macs_for_port()和install_arp_spoofing_protection()三个函数。

4. MAC地址检测通过后的action是normal,数据包有两个走向:

1) 通过patch-tun和patch-int这对peer到达br-tun:

最后会到达table 22,此处对于dl_vlan=2没有添加任何规则,会直接被丢弃。

2) 通过int-br-ex和phy-br-ex这对peer到达br-ex:

此处对于dl_vlan=2的action是normal,数据包会根据路由表规则从eth3发出。

 

vxlan网络(虚拟机test-02)访问外网的流量

前3步同test-01。

4. MAC地址检测通过后的action是normal,数据包有两个走向:

1) 通过int-br-ex和phy-br-ex这对peer到达br-ex:

此处对于dl_vlan=1没有添加任何规则,会直接被丢弃。

2) 通过patch-tun和patch-int这对peer到达br-tun:

对于dl_vlan=1的包,会将vlan id去除,设置tunnel id为0x10050(也就是share_net的segmentation_id 65616),从port 2和port 3(分别和test-ctrl-01和test-cmpt-01建立的tunnel隧道)发出。这一步即是vxlan封装。

 

下面的流程在网络节点进行:

5. 网络节点通过tunnel隧道收到这个封装过的vxlan数据包,到达br-tun上的vxlan-c0a87b16这个端口:

匹配到tunnel id是0x10050,会将vlan id设置为1,这一步就是vxlan的解包。然后从port 1送出。

6. 同过patch-int和patch-tun这对peer,到达br-int,br-int的流表对dl_vlan=1的包没有任何处理,action是normal:

7. 数据包有三个走向:

1) 通过int-br-ex和phy-br-ex这对peer到达br-ex:

此处对于dl_vlan=1没有添加任何规则,会直接被丢弃。

2) 到达tap96835b35-be,直接丢弃。

3) 到达qr-466214fa-3d,直接丢弃。

4) 到达qg-169d638e-0e,接收此数据包,进入qrouter-c8aec0d9-3203-4bdb-9237-9818603f521f,根据iptables规则,对来自192.168.111.4的数据包做SNAT:

然后根据路由表规则最终从eth3发出。

posted @ 2019-12-31 10:24  黑桃09  阅读(618)  评论(0编辑  收藏  举报