创建公网
[root@station140 ~(network_admin)]# neutron net-create --router:external=true pub1 Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | aebe75f0-6013-4a5e-bbd9-cb81e1f017bc | | name | pub1 | | provider:network_type | local | | provider:physical_network | | | provider:segmentation_id | | | router:external | True | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | e3a71a59840c4e88b8740b789c3afb9c | +---------------------------+--------------------------------------+注: 参数 --router:external=true 表示创建的是公网网络
查询公网网络信息
[root@station140 ~(keystone_admin)]# nova network-list | grep pub1 +--------------------------------------+---------+------+ | ID | Label | Cidr | +--------------------------------------+---------+------+ | aebe75f0-6013-4a5e-bbd9-cb81e1f017bc | pub1 | None | +--------------------------------------+---------+------+
############ 注意 ##########
把该 id (aebe75f0-6013-4a5e-bbd9-cb81e1f017bc) 定义到 /etc/neutron/l3_agent.ini
gateway_external_network_id = aebe75f0-6013-4a5e-bbd9-cb81e1f017bc handle_internal_only_routers = True external_network_id = aebe75f0-6013-4a5e-bbd9-cb81e1f017bc external_network_bridge = br-ex
重启服务
/etc/init.d/neutron-l3-agent restart
注: 上述问题可解决 内部网络 中 ROUTE 显示为 DOWN 状态
############ 注意 ##########
创建子网
neutron subnet-create --name terry_pub_net1 --allocation-pool start=192.168.48.142,end=192.168.48.148 --gateway 192.168.48.1 --dns-nameserver 192.168.86.37 --enable_dhcp=False --ip-version 4 pub1 192.168.48.0/24 Created a new subnet: +------------------+------------------------------------------------------+ | Field | Value | +------------------+------------------------------------------------------+ | allocation_pools | {"start": "192.168.48.142", "end": "192.168.48.148"} | | cidr | 192.168.48.0/24 | | dns_nameservers | 192.168.86.37 | | enable_dhcp | False | | gateway_ip | 192.168.48.1 | | host_routes | | | id | 59cc431b-498e-49a0-bc60-4a8ca1ca6f48 | | ip_version | 4 | | name | terry_pub_net1 | | network_id | aebe75f0-6013-4a5e-bbd9-cb81e1f017bc | | tenant_id | e3a71a59840c4e88b8740b789c3afb9c | +------------------+------------------------------------------------------+
删除网络方法
neutron net-delete pub1
查询外部网络
[root@station140 ~(network_admin)]# nova floating-ip-pool-list +--------+ | name | +--------+ | public | | pub1 | <- 注: 假如 neutron net-create 不带 --router:external=true 参数, 则代表网络为内部网络 +--------+