openstack之neutron linuxbridge + vlan組網


linuxbridge是和linuxbridge plugin匹配的core agent,主要實現L2層的功能和security group的功能。security group的功能逐漸會被 neutron firewall取代。
linuxbridge的啟動命令在linuxbridge_ neutron_agent.py中;啟動的時候需要提供 neutron.conf和linuxbridge_conf.ini配置文件
主要配置項:
 
  linuxbridge_conf.ini
  [vlans]
  network_vlan_ranges = physnet1,physnet2:1000:2999
  tenant_network_type=vlan
  [linux_bridge]
  physical_interface_mappings = physnet1:eth0, physnet2:eth1
  其中physnet1和physnet2表示該節點可用的物理網絡名字(physical network, 名字可以隨便定義),physical_interface_mappings用來把名字和該網絡使用的物理網卡對應起來。

physical_interface_mappings的作用:

  physical_interface_mappings是linuxbridge中最重要的配置項,用來定義節點中的物理網絡,可以有多個。openstack中的節點(按功能不同,可分為計算節點,dhcp節點,L3節點等)通過物理網絡實現互聯。這個物理網絡用來實現neutron中定義的虛擬網絡拓撲,和openstack的管理網絡不是一個,是不同的概念。

  虛擬網絡的流量需要通過物理網絡承載,而物理網絡其實就是該節點上的網卡。在linuxbridge實現中,每個網絡對應一個bridge,每個網絡又會有一個物理網絡(provider:physical_network屬性)來承載,與該物理網絡對應的網卡(physical_interface_mappings中配置,如physnet1對應eth1),會被加入這個bridge中,這樣該網絡就可以和外部系統通信了。

  如果虛擬機中需要和外網相連(訪問Internet),需要在L3節點(負責路由功能)上配置可以訪問外部的物理網絡,然后創建一個provider網絡 和這個物理網絡對應起來。把該provider網絡和需要訪問外網的虛擬機所在網絡加入同一個路由器,即可實現訪問外網的功能;

 例子:創建provider網絡,public01是該網絡的名字,physnet1是物理網絡的名字。physical_interface_mappings需要配置physnet1對應的物理網卡,如eth0。

1 $neutron router-create router01
2 $ neutron net-create --tenant-id $tenant public01 \
3           --provider:network_type flat \
4           --provider:physical_network physnet1 \
5           --router:external=True
6 $ neutron subnet-create --tenant-id $tenant --name public01_subnet01 \
7           --gateway 10.64.201.254 public01 10.64.201.0/24 --disable-dhcp
8 $ neutron router-gateway-set router01 public01

  創建可訪問外網的網絡net01(vlan類型),該網絡的物理網絡是physnet2。physical_interface_mappings需要配置physnet2對應的物理網卡,如eth1。

$ neutron net-create --tenant-id $tenant net01 \
          --provider:network_type vlan \
          --provider:physical_network physnet2 \
          --provider:segmentation_id 101
$ neutron subnet-create --tenant-id $tenant --name net01_subnet01 net01
192.168.101.0/24
$ neutron router-interface-add router01 net01_subnet01

  創建另外一個可訪問外網的網絡net02

$ neutron net-create --tenant-id $tenant net02 \
          --provider:network_type vlan \
          --provider:physical_network physnet2 \
          --provider:segmentation_id 102
$ neutron subnet-create --tenant-id $tenant --name net02_subnet01 net02
192.168.102.0/24
$ neutron router-interface-add router01 net02_subnet01

  這兩個網絡中的VM就可以訪問外網,通過SNAT方式。如果需要外部網絡直接訪問VM,需要給VM分配一個floating IP地址。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM