openstack neutron中定義了四種網路模式:
# tenant_network_type = local
# tenant_network_type = vlan
# Example: tenant_network_type = gre
# Example: tenant_network_type = vxlan
本文主要以vlan為例,並結合local來詳細的分析下openstack的網路模式。
1. local模式
此模式主要用來做測試,只能做單節點的部署(all-in-one),這是因為此網路模式下流量並不能通過真實的物理網卡流出,即neutron的integration bridge並沒有與真實的物理網卡做mapping,只能保證同一主機上的vm是連通的,具體參見RDO和neutron的配置文件。
(1)RDO配置文件(answer.conf)
主要看下面紅色的配置項,默認為空。
CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS
openswitch默認的網橋的映射到哪,即br-int映射到哪。 正式由於br-int沒有映射到任何bridge或interface,所以只能br-int上的虛擬機之間是連通的。
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=
(2)neutron配置文件(/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini)
[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
RDO會根據answer.conf中local的配置將neutron中open vswitch配置文件中配置為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)
此配置描述的網橋與網橋之間,網橋與網卡之間的映射和連接關係具體可結合 《圖1 vlan模式下計算節點的網路設備拓撲結構圖》和 《圖2 vlan模式下網路節點的網路設備拓撲結構圖 》來理解。
思考:很多同學可能會碰到一場景:物理機只有一塊網卡,或有兩塊網卡但只有一塊網卡連接有網線
此時,可以做如下配置
(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= //配置為空
這個配置的含義是將br-int映射到br-eth0,但是br-eth0並沒有與真正的物理網卡綁定,這就需要你事先在所有的計算節點(或網路節點)上事先創建好br-eth0橋,並將eth0添加到br-eth0上,然後在br-eth0上配置好ip,那麼RDO在安裝的時候,只要建立好br-int與br-eth0之間的連接,整個網路就通了。
此時如果網路節點也是單網卡的話,可能就不能使用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 //配置為空
還是默認都配置到eth1上,然後通過iptables將eth1的流量forward到eth0(沒有試驗過,不確定是否可行)
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就建立了這條物理鏈路。
原文鏈接:http://blog.csdn.net/ustc_dylan/article/details/17224943#1536434-tsina-1-92100-66a1f5d8f89e9ad52626f6f40fdeadaa
[火星人 ] openstack網路模式之vlan分析已經有1583次圍觀