Neutron组件管理OpenStack环境中虚拟网络基础架构(VNI)的所有网络以及物理网络基础架构(PNI)的访问层。OpenStack Networking使项目能够创建高级虚拟网络拓扑,其中包括防火墙,负载均衡器和虚拟专用网络()等服务。
OpenStack通过Neutron提供网络,子网和路由器作为对象实例。每个实例都具有模仿物理对象的功能:VPC包含子网,VPC路由器可以在不同子网之间路由流量。网络设置中至少有一个外部网络。外部网络不仅是一个虚拟定义的网络。它代表在OpenStack安装之外可访问的物理外部网络。VM通过OpenStack外部网络可以访问实际物理网络上的IP地址。除了外部网络,任何网络设置都有一个或多个内部网络。这些SDN网络直接连接到VM。只有内部网络上的VM才能直接访问连接到该网络的其它VM。
对于外部网络访问VM,需要外部与内部网络之间的虚拟路由器实现。每个虚拟路由器都有一个连接到外部网络的网关和一个连接到内部网络的一个或多个接口。与物理路由器一样,子网可以访问连接到同一路由器的其他子网上的计算机,并且计算机可以通过虚拟路由器的网关访问外部网络。
VPC网络还支持安全组。安全组使管理员能够在组中定义防火墙规则。VM可以属于一个或多个安全组,并且Networking应用这些安全组中的规则来阻止或取消阻止该VM的端口,端口范围或流量类型,比如在安全组中阻止ICMP流量通信,允许外部网络访问内部80端口等策略都可以设置在安全组中。
Neutron使用的每个插件都有自己的概念。虽然对操作VNI和OpenStack环境并不重要,但了解这些概念可以帮助您设置网络。所有网络安装都使用核心插件和安全组插件(或仅使用No-Op安全组插件)。此外,还提供防火墙即服务(FWaaS)和负载平衡器即服务(LBaaS)插件,这些插件都需要单独安装配置。
总结一下、neutron功能非常强大,提供fwaas、lbaas、安全组、dhcp等非常多的功能,这些功能需要单独安装插件实现,neutron需要通过rabbitmq组件与nova进行交互,需要与keystone组件进行交互,需要在控制节点与计算节点节点上均安装不同类型的neutron软件。
您可以使用TYPEI和TYPEII两种体系结构之一来安装部署neutron网络服务。
TYPEI部署采用最简单架构,仅支持将实例附加到(外部)网络。没有VPC网络,路由器或浮动IP地址。只有该admin
特权用户或其他特权用户才能管理提供商网络。
TYPEII部署支持将实例附加到自助服务网络的第3层服务来增强TYPEI。该选项下支持非特权用户可以管理自助服务网络,包括提供自助服务和提供商网络之间连接的路由器。此外,浮动IP地址提供与使用来自外部网络(如Internet)的自助服务网络的实例的连接。
自助服务网络通常使用VXLAN网络。覆盖网络协议包括额外的报头,这些报头增加了开销并减少了有效载荷或用户数据的可用空间。在不了解虚拟网络基础结构的情况下,实例尝试使用1500字节的默认以太网最大传输单元(MTU)来发送分组。Networking服务自动通过DHCP为实例提供正确的MTU值。但是,某些云映像不使用DHCP或忽略DHCP MTU选项,并且需要使用元数据或脚本进行配置。
一、注册用户、服务、endpoint
openstack user create --domain default --password-prompt neutron
将neutron用户添加admin角色访问service项目
openstack role add --project service --user neutron admin
在openstack上创建neutron服务
openstack service create --name neutron --description "OpenStack Networking" network
在neutron服务下注册internal、public、admin三项endpoint
openstack endpoint create --region RegionOne network public http://controller:9696
openstack endpoint create --region RegionOne network internal http://controller:9696
openstack endpoint create --region RegionOne network admin http://controller:9696
二、添加防火墙允许端口
firewall-cmd --add-port=9696/tcp --permanent && firewall-cmd --reload
三、修改neutron配置文件
vi /etc/neutron/neutron.conf
# create new
[DEFAULT]
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
state_path = /var/lib/neutron
dhcp_agent_notification = True
allow_overlapping_ips = True
notify_nova_on_port_status_changes = True
# create new
[DEFAULT]
core_plugin = ml2
service_plugins = router
auth_strategy = keystone
state_path = /var/lib/neutron
dhcp_agent_notification = True
allow_overlapping_ips = True
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
# RabbitMQ connection info
transport_url = rabbit://openstack:openstack@controller
# Keystone auth info
[keystone_authtoken]
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron
# MariaDB connection info
[database]
connection = mysql+pymysql://neutron:neutron@controller/neutron
# Nova connection info
[nova]
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = nova
[oslo_concurrency]
lock_path = $state_path/tmp
四、配置Layer 2 (ML2) plug-in模块
ML2插件使用Linux桥接机制为实例构建第2层(桥接和交换)虚拟网络基础架构。
vi /etc/neutron/plugins/ml2/ml2_conf.ini
文件并完成以下操作:
-
在该
[ml2]
部分中,启用flat,VLAN和VXLAN网络:[ml2] type_drivers = flat,vlan,vxlan
-
在该
[ml2]
部分中,启用VXLAN自助服务网络:[ml2] tenant_network_types = vxlan
-
在该
[ml2]
部分中,启用Linux桥和第2层填充机制:[ml2] mechanism_drivers = linuxbridge,l2population
-
在该
[ml2]
部分中,启用端口安全性扩展驱动程序:[ml2] extension_drivers = port_security
-
在该
[ml2_type_flat]
部分中,将提供商虚拟网络配置为扁平网络:[ml2_type_flat] flat_networks = provider
-
在该
[ml2_type_vxlan]
部分中,为自助服务网络配置VXLAN网络标识符范围:[ml2_type_vxlan] vni_ranges = 1:1000
-
在该
[securitygroup]
部分中,启用ipset以提高安全组规则的效率:[securitygroup] enable_ipset = true
五、配置linux桥
Linux网桥为实例构建第2层(桥接和交换)虚拟网络基础架构并处理安全组。
-
编辑
/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件并完成以下操作:-
在该
[linux_bridge]
部分中,将提供者虚拟网络映射到提供者物理网络接口:[linux_bridge] physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
-
替换PROVIDER_INTERFACE_NAME
为基础提供程序物理网络接口ens192
[linux_bridge]
physical_interface_mappings = provider:ens192
-
在该
[vxlan]
部分中,启用VXLAN重叠网络,配置处理覆盖网络的物理网络接口的IP地址,并启用第2层填充:[vxlan] enable_vxlan = true local_ip = 10.37.6.23 l2_population = true
在该
[securitygroup]
部分中,启用安全组并配置Linux网桥iptables防火墙驱动程序: -
[securitygroup] enable_security_group = true firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
-
通过验证以下所有
sysctl
值都设置为1
:确保您的Linux操作系统内核支持网桥过滤器:net.bridge.bridge-nf-call-iptables net.bridge.bridge-nf-call-ip6tables
- 汇总配置信息如下
[linux_bridge]
physical_interface_mappings = provider:ens192
[vxlan]
enable_vxlan = true
local_ip = 10.37.6.23
l2_population = true
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
六、配置三层服务代理
第3层(L3)代理为自助服务虚拟网络提供路由和NAT服务。
-
编辑
/etc/neutron/l3_agent.ini
文件并完成以下操作:-
在本
[DEFAULT]
节中,配置Linux桥接接口驱动程序和外部网桥:[DEFAULT] interface_driver = linuxbridge
-
七、配置DHCP
DHCP为虚拟网络提供DHCP服务。
-
编辑
/etc/neutron/dhcp_agent.ini
文件并完成以下操作:-
在本
[DEFAULT]
节中,配置Linux桥接接口驱动程序,Dnsmasq DHCP驱动程序,并启用隔离的元数据,以便提供商网络上的实例可以通过网络访问元数据:[DEFAULT] interface_driver = linuxbridge dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq enable_isolated_metadata = true
-
八、配置元数据
元数据提供配置信息,例如实例的凭证。
-
编辑
/etc/neutron/metadata_agent.ini
文件并完成以下操作:-
在该
[DEFAULT]
部分中,配置元数据主机和共享密钥:[DEFAULT] nova_metadata_host = controller metadata_proxy_shared_secret = metadatapassword
-
九、配置Nova服务以使用Neutron服务
编辑/etc/nova/nova.conf
文件并执行以下操作:
-
在该
[neutron]
部分中,配置访问参数,启用元数据并配置密码:[neutron] url = http://controller:9696 auth_url = http://controller:5000 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = neutron service_metadata_proxy = true metadata_proxy_shared_secret = metadatapassword
十、创建软连接同步数据库
-
网络服务初始化脚本需要一个
/etc/neutron/plugin.ini
指向ML2插件配置文件的符号链接/etc/neutron/plugins/ml2/ml2_conf.ini
。如果此符号链接不存在,请使用以下命令创建它:# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
-
填充数据库:
# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \ --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
验证数据库是否同步成功
十一、重新启动Compute API服务:
systemctl restart openstack-nova-api.service
十二、启动网络服务并将其配置为在系统引导时启动
# systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
# systemctl start neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
# systemctl enable neutron-l3-agent.service
# systemctl start neutron-l3-agent.service