1. 程式人生 > >openstack網路模式之vlan分析

openstack網路模式之vlan分析

 openstack neutron中定義了四種網路模式:
  1. # tenant_network_type = local
  2. # tenant_network_type = vlan   
  3. # Example: tenant_network_type = gre
  4. # 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
流量最後從哪塊物理網絡卡流出配置項
  1. # Type of network to allocate for tenant networks (eg. vlan, local,
  2. # gre)
  3. CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE=local

  4. # A comma separated list of VLAN ranges for the Neutron openvswitch
  5. # plugin (eg. physnet1:1:4094,physnet2,physnet3:3000:3999)
  6. CONFIG_NEUTRON_OVS_VLAN_RANGES=
  7. # A comma separated list of bridge mappings for the Neutron
  8. # openvswitch plugin (eg. physnet1:br-eth1,physnet2:br-eth2,physnet3
  9. :br-eth3)
  10. CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS
    =
  11. # A comma separated list of colon-separated OVS bridge:interface
  12. # pairs. The interface will be added to the associated bridge.
  13. CONFIG_NEUTRON_OVS_BRIDGE_IFACES=
(2)neutron配置檔案(/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini)
  1. [ovs]
  2. (StrOpt) Type of network to allocate for tenant networks. The
  3. # default value 'local' is useful only for single-box testing and
  4. # provides no connectivity between hosts. You MUST either change this
  5. # to 'vlan' and configure network_vlan_ranges below or change this to
  6. 'gre' or 'vxlan' and configure tunnel_id_ranges below in order for
  7. # tenant networks to provide connectivity between hosts. Set to 'none'
  8. # to disable creation of tenant networks.
  9. #
  10. tenant_network_type = local
RDO會根據answer.conf中local的配置將neutron中open vswitch配置檔案中配置為local

2. vlan模式
  大家對vlan可能比較熟悉,就不再贅述,直接看RDO和neutron的配置檔案。
(1)RDO配置檔案
  1. # Type of network to allocate for tenant networks (eg. vlan, local,
  2. # gre)
  3. CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE=vlan   //指定網路模式為vlan
  4. # A comma separated list of VLAN ranges for the Neutron openvswitch
  5. # plugin (eg. physnet1:1:4094,physnet2,physnet3:3000:3999)
  6. CONFIG_NEUTRON_OVS_VLAN_RANGES=physnet1:100:200     //設定vlan ID value為100~200
  7. # A comma separated list of bridge mappings for the Neutron
  8. # openvswitch plugin (eg. physnet1:br-eth1,physnet2:br-eth2,physnet3
  9. :br-eth3)
  10. CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth1  //設定將br-int對映到橋br-eth1(會自動建立phy-br-eth1和int-br-eth1來連線br-int和br-eth1
  11. # A comma separated list of colon-separated OVS bridge:interface
  12. # pairs. The interface will be added to the associated bridge.
  13. CONFIG_NEUTRON_OVS_BRIDGE_IFACES=br-eth1:eth1     //設定eth0橋接到br-eth1上,即最後的網路流量從eth1流出 (會自動執行ovs-vsctl add br-eth1 eth1)
    此配置描述的網橋與網橋之間,網橋與網絡卡之間的對映和連線關係具體可結合 《圖1 vlan模式下計算節點的網路裝置拓撲結構圖》和 《圖2  vlan模式下網路節點的網路裝置拓撲結構圖 》來理解。
思考:很多同學可能會碰到一場景:物理機只有一塊網絡卡,或有兩塊網絡卡但只有一塊網絡卡連線有網線
   此時,可以做如下配置
(2)單網絡卡:
  1. CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth0    //設定將br-int對映到橋br-eth10
  2. # A comma separated list of colon-separated OVS bridge:interface
  3. # pairs. The interface will be added to the associated bridge.
  4. 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)雙網絡卡,單網線
  1. CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth1    //設定將br-int對映到橋br-eth1
  2. # A comma separated list of colon-separated OVS bridge:interface
  3. # pairs. The interface will be added to the associated bridge.
  4. 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就建立了這條物理鏈路