openstack網路模式之vlan分析
阿新 • • 發佈:2019-02-20
openstack neutron中定義了四種網路模式:
1. local模式
此模式主要用來做測試,只能做單節點的部署(all-in-one),這是因為此網路模式下流量並不能通過真實的物理網絡卡流出,即neutron的integration bridge並沒有與真實的物理網絡卡做mapping,只能保證同一主機上的vm是連通的,具體參見RDO和neutron的配置檔案。
(1)RDO配置檔案(answer.conf)
主要看下面紅色的配置項,預設為空。
2. vlan模式
大家對vlan可能比較熟悉,就不再贅述,直接看RDO和neutron的配置檔案。
(1)RDO配置檔案
思考:很多同學可能會碰到一場景:物理機只有一塊網絡卡,或有兩塊網絡卡但只有一塊網絡卡連線有網線
此時,可以做如下配置
(2)單網絡卡:
此時如果網路節點也是單網絡卡的話,可能就不能使用float ip的功能了。
(3)雙網絡卡,單網線
3. vlan網路模式詳解
圖1 vlan模式下計算節點的網路裝置拓撲結構圖
首先來分析下vlan網路模式下,計算節點上虛擬網路裝置的拓撲結構。
(1)qbrXXX 等裝置
前面已經講過,主要是因為不能再tap裝置vnet0上配置network ACL rules而增加的
(2)qvbXXX/qvoXXX等裝置
這是一對veth pair devices,用來連線bridge device和switch,從名字猜測下:q-quantum, v-veth, b-bridge, o-open vswitch(quantum年代的遺留)。
(3) int-br-eth1和phy-br-eth1
這也是一對veth pair devices,用來連線br-int和br-eth1, 另外,vlan ID的轉化也是在這執行的,比如從int-br-eth1進來的packets,其vlan id=101會被轉化成1,同理,從phy-br-eth1出去的packets,其vlan id會從1轉化成101
(4)br-eth1和eth1
packets要想進入physical network最後還得到真正的物理網絡卡eth1,所以add eth1 to br-eth1上,整個鏈路才完全打通
圖2 vlan模式下網路節點的網路裝置拓撲結構圖
網路節點與計算節點相比,就是多了external network,L3 agent和dhcp agent。
(1)network namespace
每個L3 router對應一個private network,但是怎麼保證每個private的ip address可以overlapping而又不相互影響呢,這就利用了linux kernel的network namespace
(2)qr-YYY和qg-VVV等裝置 (q-quantum, r-router, g-gateway)
qr-YYY獲得了一個internal的ip,qg-VVV是一個external的ip,通過iptables rules進行NAT對映。
思考:phy-br-ex和int-br-ex是幹啥的?
堅持"所有packets必須經過物理的線路才能通"的思想,雖然 qr-YYY和qg-VVV之間建立的NAT的對映,歸根到底還得通過一條物理鏈路,那麼phy-br-ex和int-br-ex就建立了這條物理鏈路
- # tenant_network_type = local
- # tenant_network_type = vlan
- # Example: tenant_network_type = gre
- # Example: tenant_network_type = vxlan
1. local模式
此模式主要用來做測試,只能做單節點的部署(all-in-one),這是因為此網路模式下流量並不能通過真實的物理網絡卡流出,即neutron的integration bridge並沒有與真實的物理網絡卡做mapping,只能保證同一主機上的vm是連通的,具體參見RDO和neutron的配置檔案。
(1)RDO配置檔案(answer.conf)
主要看下面紅色的配置項,預設為空。
- CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS
- CONFIG_NEUTRON_OVS_BRIDGE_IFACES
- # Type of network to allocate for tenant networks (eg. vlan, local,
- # gre)
- CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE=local
- # A comma separated list of VLAN ranges for the Neutron openvswitch
- # plugin (eg. physnet1:1:4094,physnet2,physnet3:3000:3999)
- CONFIG_NEUTRON_OVS_VLAN_RANGES=
- # A comma separated list of bridge mappings for the Neutron
- # openvswitch plugin (eg. physnet1:br-eth1,physnet2:br-eth2,physnet3
- # :br-eth3)
- CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS
- # A comma separated list of colon-separated OVS bridge:interface
- # pairs. The interface will be added to the associated bridge.
- CONFIG_NEUTRON_OVS_BRIDGE_IFACES=
- [ovs]
- # (StrOpt) Type of network to allocate for tenant networks. The
- # default value 'local' is useful only for single-box testing and
- # provides no connectivity between hosts. You MUST either change this
- # to 'vlan' and configure network_vlan_ranges below or change this to
- # 'gre' or 'vxlan' and configure tunnel_id_ranges below in order for
- # tenant networks to provide connectivity between hosts. Set to 'none'
- # to disable creation of tenant networks.
- #
- tenant_network_type = local
2. vlan模式
大家對vlan可能比較熟悉,就不再贅述,直接看RDO和neutron的配置檔案。
(1)RDO配置檔案
- # Type of network to allocate for tenant networks (eg. vlan, local,
- # gre)
- CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE=vlan //指定網路模式為vlan
- # A comma separated list of VLAN ranges for the Neutron openvswitch
- # plugin (eg. physnet1:1:4094,physnet2,physnet3:3000:3999)
- CONFIG_NEUTRON_OVS_VLAN_RANGES=physnet1:100:200 //設定vlan ID value為100~200
- # A comma separated list of bridge mappings for the Neutron
- # openvswitch plugin (eg. physnet1:br-eth1,physnet2:br-eth2,physnet3
- # :br-eth3)
- CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth1 //設定將br-int對映到橋br-eth1(會自動建立phy-br-eth1和int-br-eth1來連線br-int和br-eth1)
- # A comma separated list of colon-separated OVS bridge:interface
- # pairs. The interface will be added to the associated bridge.
- CONFIG_NEUTRON_OVS_BRIDGE_IFACES=br-eth1:eth1 //設定eth0橋接到br-eth1上,即最後的網路流量從eth1流出 (會自動執行ovs-vsctl add br-eth1 eth1)
思考:很多同學可能會碰到一場景:物理機只有一塊網絡卡,或有兩塊網絡卡但只有一塊網絡卡連線有網線
此時,可以做如下配置
(2)單網絡卡:
- CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth0 //設定將br-int對映到橋br-eth10
- # A comma separated list of colon-separated OVS bridge:interface
- # pairs. The interface will be added to the associated bridge.
- CONFIG_NEUTRON_OVS_BRIDGE_IFACES= //配置為空
此時如果網路節點也是單網絡卡的話,可能就不能使用float ip的功能了。
(3)雙網絡卡,單網線
- CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth1 //設定將br-int對映到橋br-eth1
- # A comma separated list of colon-separated OVS bridge:interface
- # pairs. The interface will be added to the associated bridge.
- CONFIG_NEUTRON_OVS_BRIDGE_IFACES=eth1 //配置為空
3. vlan網路模式詳解
圖1 vlan模式下計算節點的網路裝置拓撲結構圖
首先來分析下vlan網路模式下,計算節點上虛擬網路裝置的拓撲結構。
(1)qbrXXX 等裝置
前面已經講過,主要是因為不能再tap裝置vnet0上配置network ACL rules而增加的
(2)qvbXXX/qvoXXX等裝置
這是一對veth pair devices,用來連線bridge device和switch,從名字猜測下:q-quantum, v-veth, b-bridge, o-open vswitch(quantum年代的遺留)。
(3) int-br-eth1和phy-br-eth1
這也是一對veth pair devices,用來連線br-int和br-eth1, 另外,vlan ID的轉化也是在這執行的,比如從int-br-eth1進來的packets,其vlan id=101會被轉化成1,同理,從phy-br-eth1出去的packets,其vlan id會從1轉化成101
(4)br-eth1和eth1
packets要想進入physical network最後還得到真正的物理網絡卡eth1,所以add eth1 to br-eth1上,整個鏈路才完全打通
圖2 vlan模式下網路節點的網路裝置拓撲結構圖
網路節點與計算節點相比,就是多了external network,L3 agent和dhcp agent。
(1)network namespace
每個L3 router對應一個private network,但是怎麼保證每個private的ip address可以overlapping而又不相互影響呢,這就利用了linux kernel的network namespace
(2)qr-YYY和qg-VVV等裝置 (q-quantum, r-router, g-gateway)
qr-YYY獲得了一個internal的ip,qg-VVV是一個external的ip,通過iptables rules進行NAT對映。
思考:phy-br-ex和int-br-ex是幹啥的?
堅持"所有packets必須經過物理的線路才能通"的思想,雖然 qr-YYY和qg-VVV之間建立的NAT的對映,歸根到底還得通過一條物理鏈路,那麼phy-br-ex和int-br-ex就建立了這條物理鏈路