vlan:虛擬局域網
VLAN是一種將局域網設備從邏輯上划分成一個個網段,從而實現虛擬工作組的數據交換技術
vxlan:(Virtual eXtensible LAN可擴展虛擬局域網),基於IP網絡之上,采用的是MAC in UDP技術(通過建立隧道進行傳輸數據)
控制節點修改:
建議將之前配置的flat網絡的虛擬機全部刪除:(本次操作全部是將flat的網絡模式更改為3層的模式)
1:編輯/etc/neutron/neutron.conf
文件並完成以下操作:
[root@controller01 ~]# vim /etc/neutron/neutron.conf
在該[DEFAULT]
部分中,啟用模塊化第2層(ML2)插件,路由器服務和重疊的IP地址
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
2:配置模塊化層2(ML2)插件
ML2插件使用Linux橋接器機制為實例構建第2層(橋接和交換)虛擬網絡基礎結構。
-
編輯
/etc/neutron/plugins/ml2/ml2_conf.ini
文件並完成以下操作:-
在該
[ml2]
部分中,啟用平面,VLAN和VXLAN網絡:
tenant_network_types:定義租戶的網絡類型,,l2population此參數是為了優化l2網絡插件性能[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types = vxlan
mechanism_drivers = linuxbridge,l2population -
在該[ml2_type_vxlan]
部分中,為自助服務網絡配置VXLAN網絡標識符范圍:vlan:1-4096 vlan:4096*4096-2
[ml2_type_vxlan]
vni_ranges = 1:100000
3:配置Linux網橋代理
前提:對每個節點進行添加一個vxlan單獨使用網卡,並且給每個網卡進行添加永久地址:(添加之后注意不要重啟網絡服務,使用ifup進行重啟網卡)
Linux網橋代理為實例構建第2層(橋接和交換)虛擬網絡基礎結構並處理安全組。
-
編輯
/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件並完成以下操作
[vxlan]
enable_vxlan = true
local_ip = 10.100.203.201
l2_population = true
4:配置第3層劑
第3層(L3)代理為自助式虛擬網絡提供路由和NAT服務。
-
編輯
/etc/neutron/l3_agent.ini
文件並完成以下操作
在該[DEFAULT]
部分中,配置Linux網橋接口驅動程序和外部網橋:
[DEFAULT]
interface_driver = linuxbridge
啟動服務:
[root@controller01 ~]# systemctl restart neutron-server.service \
> neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
> neutron-metadata-agent.service
[root@controller01 ~]# systemctl enable neutron-l3-agent.service
[root@controller01 ~]# systemctl start neutron-l3-agent.service
計算節點修改:
[root@compute01 ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[vxlan]
enable_vxlan = true
local_ip = 10.100.203.202
l2_population = true
重啟服務:
[root@compute01 ~]# systemctl restart neutron-linuxbridge-agent.service
檢測:
開啟 路由:
[root@compute01 ~]# vim /etc/openstack-dashboard/local_settings
[root@compute01 ~]# systemctl restart httpd
創建網絡(vxlan網絡創建的時候必須要有公有網絡和私有網絡同時創建)
1:創建一個網絡
[root@controller01 ~]# openstack network create selfprovider
2:在網絡上創建一個子網
[root@controller01 ~]# openstack network create selfprovider
[root@controller01 ~]# openstack subnet create --network selfprovider \
> --dns-nameserver 114.114.114.114 --gateway 172.16.1.1 \
> --subnet-range 172.16.1.0/24 selfsubnet
3:創建路由:
[root@controller01 ~]# openstack router create router
4:將網絡的子網添加為路由器上的接口:
[root@controller01 ~]# openstack router add subnet router selfsubnet
5:給路由器設置公有網絡的網關:
[root@controller01 ~]# neutron router-gateway-set router provider
驗證操作:
[root@controller01 ~]# openstack port list --router router
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| ID | Name | MAC Address | Fixed IP Addresses | Status |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
| d5db964d-3a40-46f4-ba59-e71b13dbdc19 | | fa:16:3e:b5:6a:34 | ip_address='172.16.1.1', subnet_id='67b74cd2-304e-46ae-8eb2-448f0c0410c1' | ACTIVE |
| f3ce76b9-5452-4b47-b48f-cf6ba752dea3 | | fa:16:3e:4a:27:8e | ip_address='10.100.214.151', subnet_id='fe427e08-7d4f-46ec-bebd-1a2d277fbef2' | ACTIVE |
+--------------------------------------+------+-------------------+-------------------------------------------------------------------------------+--------+
從控制節點或任意公共物理網絡上的節點Ping這個IP地址:
[root@controller01 ~]# ping -c 4 10.100.214.151