openstack網(wǎng)絡(luò)模式之vlan分析
openstack neutron中定義了四種網(wǎng)絡(luò)模式:
# tenant_network_type = local
# tenant_network_type = vlan
# Example: tenant_network_type = gre
# Example: tenant_network_type = vxlan
本文主要以vlan為例,并結(jié)合local來(lái)詳細(xì)的分析下openstack的網(wǎng)絡(luò)模式。
1. local模式
此模式主要用來(lái)做測(cè)試,只能做單節(jié)點(diǎn)的部署(all-in-one),這是因?yàn)榇司W(wǎng)絡(luò)模式下流量并不能通過(guò)真實(shí)的物理網(wǎng)卡流出,即neutron的integration bridge并沒(méi)有與真實(shí)的物理網(wǎng)卡做mapping,只能保證同一主機(jī)上的vm是連通的,具體參見(jiàn)RDO和neutron的配置文件。
(1)RDO配置文件(answer.conf)
主要看下面紅色的配置項(xiàng),默認(rèn)為空。
CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS
openswitch默認(rèn)的網(wǎng)橋的映射到哪,即br-int映射到哪。 正式由于br-int沒(méi)有映射到任何bridge或interface,所以只能br-int上的虛擬機(jī)之間是連通的。
CONFIG_NEUTRON_OVS_BRIDGE_IFACES
流量***從哪塊物理網(wǎng)卡流出配置項(xiàng)
# 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會(huì)根據(jù)answer.conf中l(wèi)ocal的配置將neutron中open vswitch配置文件中配置為local
2. vlan模式
大家對(duì)vlan可能比較熟悉,就不再贅述,直接看RDO和neutron的配置文件。
(1)RDO配置文件
# Type of network to allocate for tenant networks (eg. vlan, local,
# gre)
CONFIG_NEUTRON_OVS_TENANT_NETWORK_TYPE=vlan //指定網(wǎng)絡(luò)模式為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 //設(shè)置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 //設(shè)置將br-int映射到橋br-eth1(會(huì)自動(dòng)創(chuàng)建phy-br-eth1和int-br-eth1來(lái)連接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 //設(shè)置eth0橋接到br-eth1上,即***的網(wǎng)絡(luò)流量從eth1流出 (會(huì)自動(dòng)執(zhí)行ovs-vsctl add br-eth1 eth1)
此配置描述的網(wǎng)橋與網(wǎng)橋之間,網(wǎng)橋與網(wǎng)卡之間的映射和連接關(guān)系具體可結(jié)合 《圖1 vlan模式下計(jì)算節(jié)點(diǎn)的網(wǎng)絡(luò)設(shè)備拓?fù)浣Y(jié)構(gòu)圖》和 《圖2 vlan模式下網(wǎng)絡(luò)節(jié)點(diǎn)的網(wǎng)絡(luò)設(shè)備拓?fù)浣Y(jié)構(gòu)圖 》來(lái)理解。
思考:很多同學(xué)可能會(huì)碰到一場(chǎng)景:物理機(jī)只有一塊網(wǎng)卡,或有兩塊網(wǎng)卡但只有一塊網(wǎng)卡連接有網(wǎng)線
此時(shí),可以做如下配置
(2)單網(wǎng)卡:
CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth0 //設(shè)置將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= //配置為空
這個(gè)配置的含義是將br-int映射到br-eth0,但是br-eth0并沒(méi)有與真正的物理網(wǎng)卡綁定,這就需要你事先在所有的計(jì)算節(jié)點(diǎn)(或網(wǎng)絡(luò)節(jié)點(diǎn))上事先創(chuàng)建好br-eth0橋,并將eth0添加到br-eth0上,然后在br-eth0上配置好ip,那么RDO在安裝的時(shí)候,只要建立好br-int與br-eth0之間的連接,整個(gè)網(wǎng)絡(luò)就通了。
此時(shí)如果網(wǎng)絡(luò)節(jié)點(diǎn)也是單網(wǎng)卡的話,可能就不能使用float ip的功能了。
(3)雙網(wǎng)卡,單網(wǎng)線
CONFIG_NEUTRON_OVS_BRIDGE_MAPPINGS=physnet1:br-eth1 //設(shè)置將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 //配置為空
還是默認(rèn)都配置到eth1上,然后通過(guò)iptables將eth1的流量forward到eth0(沒(méi)有試驗(yàn)過(guò),不確定是否可行)
3. vlan網(wǎng)絡(luò)模式詳解
圖1 vlan模式下計(jì)算節(jié)點(diǎn)的網(wǎng)絡(luò)設(shè)備拓?fù)浣Y(jié)構(gòu)圖
首先來(lái)分析下vlan網(wǎng)絡(luò)模式下,計(jì)算節(jié)點(diǎn)上虛擬網(wǎng)絡(luò)設(shè)備的拓?fù)浣Y(jié)構(gòu)。
(1)qbrXXX 等設(shè)備
前面已經(jīng)講過(guò),主要是因?yàn)椴荒茉賢ap設(shè)備vnet0上配置network ACL rules而增加的
(2)qvbXXX/qvoXXX等設(shè)備
這是一對(duì)veth pair devices,用來(lái)連接bridge device和switch,從名字猜測(cè)下:q-quantum, v-veth, b-bridge, o-open vswitch(quantum年代的遺留)。
(3) int-br-eth1和phy-br-eth1
這也是一對(duì)veth pair devices,用來(lái)連接br-int和br-eth1, 另外,vlan ID的轉(zhuǎn)化也是在這執(zhí)行的,比如從int-br-eth1進(jìn)來(lái)的packets,其vlan id=101會(huì)被轉(zhuǎn)化成1,同理,從phy-br-eth1出去的packets,其vlan id會(huì)從1轉(zhuǎn)化成101
(4)br-eth1和eth1
packets要想進(jìn)入physical network***還得到真正的物理網(wǎng)卡eth1,所以add eth1 to br-eth1上,整個(gè)鏈路才完全打通

圖2 vlan模式下網(wǎng)絡(luò)節(jié)點(diǎn)的網(wǎng)絡(luò)設(shè)備拓?fù)浣Y(jié)構(gòu)圖
網(wǎng)絡(luò)節(jié)點(diǎn)與計(jì)算節(jié)點(diǎn)相比,就是多了external network,L3 agent和dhcp agent。
(1)network namespace
每個(gè)L3 router對(duì)應(yīng)一個(gè)private network,但是怎么保證每個(gè)private的ip address可以overlapping而又不相互影響呢,這就利用了linux kernel的network namespace
(2)qr-YYY和qg-VVV等設(shè)備 (q-quantum, r-router, g-gateway)
qr-YYY獲得了一個(gè)internal的ip,qg-VVV是一個(gè)external的ip,通過(guò)iptables rules進(jìn)行NAT映射。
思考:phy-br-ex和int-br-ex是干啥的?
堅(jiān)持"所有packets必須經(jīng)過(guò)物理的線路才能通"的思想,雖然 qr-YYY和qg-VVV之間建立的NAT的映射,歸根到底還得通過(guò)一條物理鏈路,那么phy-br-ex和int-br-ex就建立了這條物理鏈路。
原文鏈接:http://blog.csdn.net/ustc_dylan/article/details/17224943#1536434-tsina-1-92100-66a1f5d8f89e9ad52626f6f40fdeadaa