在启动实例之前,您必须创建必须的虚拟机网络设施。对于网络选项1,实例使用提供者(外部)网络,提供者网络通过L2(桥/交换机)设备连接到物理网络。这个网络包括为实例提供IP地址的DHCP服务器。
``admin``或者其他权限用户必须创建这个网络,因为它直接连接到物理网络设施。
注解
下面的说明和框图使用示例IP 地址范围。你必须依据你的实际环境修改它们。
Networking Option 1: Provider networks - Overview
Networking Option 1: Provider networks - Connectivity
在控制节点上,加载 admin
凭证来获取管理员能执行的命令访问权限:
$ . admin-openrc
创建网络:
$ openstack network create --share --external \
--provider-physical-network provider \
--provider-network-type flat provider
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2017-03-14T14:37:39Z |
| description | |
| dns_domain | None |
| id | 54adb94a-4dce-437f-a33b-e7e2e7648173 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | None |
| mtu | 1500 |
| name | provider |
| port_security_enabled | True |
| project_id | 4c7f48f1da5b494faaa66713686a7707 |
| provider:network_type | flat |
| provider:physical_network | provider |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 3 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| updated_at | 2017-03-14T14:37:39Z |
+---------------------------+--------------------------------------+
``–share``选项允许所有项目使用虚拟网络
The --external
option defines the virtual network to be external. If
you wish to create an internal network, you can use --internal
instead.
Default value is internal
.
The --provider-physical-network provider
and
--provider-network-type flat
options connect the flat virtual network
to the flat (native/untagged) physical network on the eth1
interface
on the host using information from the following files:
ml2_conf.ini
:
[ml2_type_flat]
flat_networks = provider
linuxbridge_agent.ini
:
[linux_bridge]
physical_interface_mappings = provider:eth1
在网络上创建一个子网:
$ openstack subnet create --network provider \
--allocation-pool start=START_IP_ADDRESS,end=END_IP_ADDRESS \
--dns-nameserver DNS_RESOLVER --gateway PROVIDER_NETWORK_GATEWAY \
--subnet-range PROVIDER_NETWORK_CIDR provider
使用提供者物理网络的子网CIDR标记替换``PROVIDER_NETWORK_CIDR``。
将``START_IP_ADDRESS``和``END_IP_ADDRESS``使用你想分配给实例的子网网段的第一个和最后一个IP地址。这个范围不能包括任何已经使用的IP地址。
将 DNS_RESOLVER
替换为DNS解析服务的IP地址。在大多数情况下,你可以从主机``/etc/resolv.conf`` 文件选择一个使用。
将``PUBLIC_NETWORK_GATEWAY`` 替换为公共网络的网关,一般的网关IP地址以 ”.1” 结尾。
Example
公共网络203.0.113.0/24的网关为203.0.113.1。DHCP服务为每个实例分配IP,IP从203.0.113.101 到 203.0.113.200。所有实例的DNS使用8.8.4.4。
$ openstack subnet create --network provider \
--allocation-pool start=203.0.113.101,end=203.0.113.250 \
--dns-nameserver 8.8.4.4 --gateway 203.0.113.1 \
--subnet-range 203.0.113.0/24 provider
Created a new subnet:
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| allocation_pools | 203.0.113.101-203.0.113.250 |
| cidr | 203.0.113.0/24 |
| created_at | 2016-11-02T20:45:04Z |
| description | |
| dns_nameservers | 8.8.4.4 |
| enable_dhcp | True |
| gateway_ip | 203.0.113.1 |
| headers | |
| host_routes | |
| id | 2c65ef8c-a5f3-4f51-94c1-4df0daaaab5c |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | provider |
| network_id | 9793a02d-4f05-40d2-a280-407c48db0161 |
| project_id | 7e188c33604d4b02ae0a99b5da68cae0 |
| revision_number | 2 |
| service_types | [] |
| subnetpool_id | None |
| updated_at | 2016-11-02T20:45:04Z |
+-------------------+--------------------------------------+
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.