本操作分别在三个节点上完成
配置控制节点
root@controller:~# vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 第130行:添加网络类型
tenant_network_types = vxlan
# 第181行:添加
flat_networks = physnet1
# 第235行:添加
vni_ranges = 1:1000
重启服务
root@controller:~# systemctl restart neutron-server
配置网络节点
添加一个ovs桥
root@network:~# ovs-vsctl add-br br-floating
把网络节点的第二个网卡(eth1)添加到桥端口上,ps:之前hosts文件中配置的ip是第一个网卡的ip。
root@network:~# ovs-vsctl add-port br-floating eth1
root@network:~# vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 第130行:添加网络类型
tenant_network_types = vxlan
# 第181行:添加
flat_networks = physnet1
# 第235行:添加
vni_ranges = 1:1000
root@network:~# vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# 第118行:添加
[agent]
tunnel_types = vxlan
l2_population = True
prevent_arp_spoofing = True
# 第196行:添加
[ovs]
local_ip = 172.31.0.20
bridge_mappings = physnet1:br-floating
重启服务
root@network:~# systemctl restart neutron-dhcp-agent neutron-l3-agent neutron-metadata-agent neutron-openvswitch-agent
配置计算节点
root@compute:~# vi /etc/neutron/plugins/ml2/ml2_conf.ini
# 第130行:添加网络类型
tenant_network_types = vxlan
# 第181行:添加
flat_networks = physnet1
# 第235行:添加
vni_ranges = 1:1000
root@compute:~# vi /etc/neutron/plugins/ml2/openvswitch_agent.ini
# 第118行:添加
[agent]
tunnel_types = vxlan
l2_population = True
prevent_arp_spoofing = True
# 第196行:添加
[ovs]
local_ip = 10.0.0.5
重启agent服务
root@compute:~# systemctl restart neutron-openvswitch-agent
创建网络及路由(控制节点上完成)
创建虚拟路由
root@controller ~(keystone)# openstack router create router_01
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2020-04-26T08:36:28Z |
| description | |
| distributed | False |
| external_gateway_info | None |
| flavor_id | None |
| ha | False |
| id | d0c25fb5-9619-4dfb-8ed9-3fefec9e71bb |
| name | router_01 |
| project_id | 460e4247a8984b2cbf1b35c3da7e6708 |
| revision_number | 1 |
| routes | |
| status | ACTIVE |
| tags | |
| updated_at | 2020-04-26T08:36:29Z |
+-------------------------+--------------------------------------+
创建内部网络
root@controller ~(keystone)# openstack network create int_net --provider-network-type vxlan
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2020-04-26T08:51:55Z |
| description | |
| dns_domain | None |
| id | 96589b40-771a-4115-9960-fbc37a541490 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1450 |
| name | int_net |
| port_security_enabled | True |
| project_id | 460e4247a8984b2cbf1b35c3da7e6708 |
| provider:network_type | vxlan |
| provider:physical_network | None |
| provider:segmentation_id | 20 |
| qos_policy_id | None |
| revision_number | 2 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2020-04-26T08:51:55Z |
+---------------------------+--------------------------------------+
创建内部网络的子网
root@controller ~(keystone)# openstack subnet create subnet1 --network int_net
--subnet-range 192.168.100.0/24 --gateway 192.168.100.1
--dns-nameserver 10.0.0.10
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 192.168.100.2-192.168.100.254 |
| cidr | 192.168.100.0/24 |
| created_at | 2020-04-26T08:53:23Z |
| description | |
| dns_nameservers | 10.0.0.10 |
| enable_dhcp | True |
| gateway_ip | 192.168.100.1 |
| host_routes | |
| id | 19629a49-cd13-431a-9150-3ba9caf93bc1 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | subnet1 |
| network_id | 96589b40-771a-4115-9960-fbc37a541490 |
| project_id | 460e4247a8984b2cbf1b35c3da7e6708 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2020-04-26T08:53:23Z |
+-------------------+--------------------------------------+
连接内部网络到路由
root@controller ~(keystone)# openstack router add subnet router_01 subnet1
创建外部网络
root@controller ~(keystone)# openstack network create
--provider-physical-network physnet1
--provider-network-type flat --external ext_net
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2020-04-26T08:37:39Z |
| description | |
| dns_domain | None |
| id | 347ace20-84ac-4672-ae96-780a930524b1 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| mtu | 1500 |
| name | ext_net |
| port_security_enabled | True |
| project_id | 460e4247a8984b2cbf1b35c3da7e6708 |
| provider:network_type | flat |
| provider:physical_network | physnet1 |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 5 |
| router:external | External |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2020-04-26T08:37:39Z |
+---------------------------+--------------------------------------+
创建外部网络的子网
root@controller ~(keystone)# openstack subnet create subnet2
--network ext_net --subnet-range 10.0.0.0/24
--allocation-pool start=10.0.0.200,end=10.0.0.254
--gateway 10.0.0.1 --dns-nameserver 10.0.0.10 --no-dhcp
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 10.0.0.200-10.0.0.254 |
| cidr | 10.0.0.0/24 |
| created_at | 2020-04-26T08:55:51Z |
| description | |
| dns_nameservers | 10.0.0.10 |
| enable_dhcp | False |
| gateway_ip | 10.0.0.1 |
| host_routes | |
| id | 10b04524-63c3-4799-996a-7e76bfda61e7 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | subnet2 |
| network_id | 347ace20-84ac-4672-ae96-780a930524b1 |
| project_id | 460e4247a8984b2cbf1b35c3da7e6708 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2020-04-26T08:55:51Z |
+-------------------+--------------------------------------+
连接外部网络到路由
root@controller ~(keystone)# openstack router add subnet router_01 subnet2