1、获取网络列表
[root@cc ~(keystone_admin)]# neutron net-list +--------------------------------------+----------+-----------------------------------------------------+ | id | name | subnets | +--------------------------------------+----------+-----------------------------------------------------+ | afde2904-9951-44b9-a3a2-f23b0b68a60b | flat | abb07ddd-110d-408d-8879-e0fc0d640b63 172.16.80.0/24 | | 1d7ede32-66aa-41c0-bec0-1b93a5741e46 | vlan1681 | 1c06ea64-5d1f-49ec-804e-97d44974c583 172.16.81.0/24 | +--------------------------------------+----------+-----------------------------------------------------+
2、查看某个网络的信息
[root@cc ~(keystone_admin)]# neutron net-show afde2904-9951-44b9-a3a2-f23b0b68a60b +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | id | afde2904-9951-44b9-a3a2-f23b0b68a60b | | name | flat | | provider | False | | provider:network_type | flat | | provider:physical_network | physnet1 | | provider:segmentation_id | | | router:external | False | | shared | False | | status | ACTIVE | | subnets | abb07ddd-110d-408d-8879-e0fc0d640b63 | | tenant_id | cbeb053466384fd4a3eaa4fced6e307a | +---------------------------+--------------------------------------+
3、创建公网
[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 表示创建的是公网网络
4、创建私有网络,指定tenant
[root@cc07 ~]# neutron net-create hzb-privnet1 --tenant-id=26a8e1feb372493d831c19d4d9e28d73 Created a new network: +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | True | | availability_zone_hints | | | availability_zones | | | created_at | 2018-10-25T06:20:35 | | description | | | id | 2193270e-c4c9-469c-99ae-87ebdb4ba535 | | ipv4_address_scope | | | ipv6_address_scope | | | mtu | 1500 | | name | hzb-privnet1 | | port_security_enabled | True | | provider | False | | provider:network_type | vlan | | provider:physical_network | physnet1 | | provider:segmentation_id | 219 | | qos_policy_id | | | router:external | False | | shared | False | | status | ACTIVE | | subnets | | | tags | | | tenant_id | 26a8e1feb372493d831c19d4d9e28d73 | | updated_at | 2018-10-25T06:20:35 | +---------------------------+--------------------------------------+
5、创建hzb-privnet1的子网
[root@cc07 ~]# neutron subnet-create --name hzb-sub-net1 --allocation-pool start=10.30.0.50,end=10.30.0.100 --no-gateway --ip-version 4 hzb-privnet1 10.30.0.0/24 Created a new subnet: +-------------------+-----------------------------------------------+ | Field | Value | +-------------------+-----------------------------------------------+ | allocation_pools | {"start": "10.30.0.50", "end": "10.30.0.100"} | | cidr | 10.30.0.0/24 | | created_at | 2018-10-25T06:25:23 | | description | | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | | | host_routes | | | id | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | hzb-sub-net1 | | network_id | 2193270e-c4c9-469c-99ae-87ebdb4ba535 | | subnetpool_id | | | tenant_id | ff2958aa964541679833ddbcc503c5d2 | | updated_at | 2018-10-25T06:25:23 | +-------------------+-----------------------------------------------+
6、列出网络hzb-privnet1的子网
[root@cc07 ~]# neutron subnet-list --network_id=2193270e-c4c9-469c-99ae-87ebdb4ba535 +--------------------------------------+--------------+--------------+-----------------------------------------------+ | id | name | cidr | allocation_pools | +--------------------------------------+--------------+--------------+-----------------------------------------------+ | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 | hzb-sub-net1 | 10.30.0.0/24 | {"start": "10.30.0.50", "end": "10.30.0.100"} | +--------------------------------------+--------------+--------------+-----------------------------------------------+
7、查看某一子网的详情
[root@cc07 ~]# neutron subnet-show 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 +-------------------+-----------------------------------------------+ | Field | Value | +-------------------+-----------------------------------------------+ | allocation_pools | {"start": "10.30.0.50", "end": "10.30.0.100"} | | cidr | 10.30.0.0/24 | | created_at | 2018-10-25T06:25:23 | | description | | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | | | host_routes | | | id | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | hzb-sub-net1 | | network_id | 2193270e-c4c9-469c-99ae-87ebdb4ba535 | | subnetpool_id | | | tenant_id | ff2958aa964541679833ddbcc503c5d2 | | updated_at | 2018-10-25T06:25:23 | +-------------------+-----------------------------------------------+
8、更新子网
[root@cc07 ~]# neutron subnet-update 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 --dns-nameserver 8.8.8.8 --allocation-pool start=10.30.0.60,end=10.30.0.90 Updated subnet: 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 [root@cc07 ~]# neutron subnet-show 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 +-------------------+----------------------------------------------+ | Field | Value | +-------------------+----------------------------------------------+ | allocation_pools | {"start": "10.30.0.60", "end": "10.30.0.90"} | | cidr | 10.30.0.0/24 | | created_at | 2018-10-25T06:25:23 | | description | | | dns_nameservers | 8.8.8.8 | | enable_dhcp | True | | gateway_ip | | | host_routes | | | id | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | hzb-sub-net1 | | network_id | 2193270e-c4c9-469c-99ae-87ebdb4ba535 | | subnetpool_id | | | tenant_id | ff2958aa964541679833ddbcc503c5d2 | | updated_at | 2018-10-25T06:42:27 | +-------------------+----------------------------------------------+
9、删除子网
neutron subnet-delete hzb-sub-net1
10、清理被占用的子网,比如要清理掉74网段的
[root@cc25 ~]# neutron port-list |grep 74. | 01564391-c27c-4adc-a9b0-28b0b225574f | | fa:16:3e:cc:23:16 | {"subnet_id": "fde62b7a-a313-49ae-95ba-02f1ad491c9d", "ip_address": "192.168.50.39"} | | 1929b1ad-14c2-45e7-a56c-97405aa0fd97 | | fa:16:3e:92:33:07 | {"subnet_id": "648eaf18-7033-4401-9ce2-bea42d98c94a", "ip_address": "172.16.74.141"} | | 2a385f13-80a5-4885-91a8-1d776016b3b7 | | fa:16:3e:92:df:24 | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.150"} | | 32f830cc-9d1f-4f02-b4d0-cd397b18cd9f | | fa:16:3e:58:cf:6b | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.146"} | | 3a36f5fe-77f7-481c-ac55-2b51c3d606ef | | fa:16:3e:ea:38:ef | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.151"} | | 4500b42e-c43f-4c28-a8f3-81ee8ea3cf01 | | fa:16:3e:7c:35:d8 | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.147"} | | 544943a6-132e-41e4-b56b-b3295e774cce | | fa:16:3e:33:2a:f9 | {"subnet_id": "861fe053-5619-4350-8a5f-9f189be669fc", "ip_address": "10.10.10.12"} | | 63b1053a-9f02-4d02-95f0-dd6ab7bb913b | | fa:16:3e:8a:20:68 | {"subnet_id": "648eaf18-7033-4401-9ce2-bea42d98c94a", "ip_address": "172.16.74.142"} | | 6fc468f5-2f4d-4337-ae9f-dddfae12aba1 | | fa:16:3e:32:c1:f7 | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.152"} | | 888dc43c-3396-4a73-a92d-76745b171c9f | | fa:16:3e:ff:ec:7d | {"subnet_id": "fde62b7a-a313-49ae-95ba-02f1ad491c9d", "ip_address": "192.168.50.33"} | | 9a6302d7-765a-4e8c-8ff4-2d220314116d | | fa:16:3e:ed:be:e5 | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.149"} | | a8a70f01-a430-4336-8815-ccb2d5e78b95 | | fa:16:3e:23:74:1a | {"subnet_id": "861fe053-5619-4350-8a5f-9f189be669fc", "ip_address": "10.10.10.7"} | | abc3b68f-dea7-427e-8b99-bb9ef6df6f11 | | fa:16:3e:bb:16:ce | {"subnet_id": "582523a3-5740-4150-a377-140d6cc2d261", "ip_address": "11.11.11.1"} | | ca4c163b-dd8c-4a3a-9b75-0db8b92ee26b | | fa:16:3e:85:99:62 | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.145"} | | d594a69e-cf61-4b99-ac2e-19cb71b22c7d | | fa:16:3e:42:62:91 | {"subnet_id": "648eaf18-7033-4401-9ce2-bea42d98c94a", "ip_address": "172.16.74.140"} | | dbe3b20a-f69a-4091-8c2c-8a63ea849a71 | | fa:16:3e:c7:77:8f | {"subnet_id": "582523a3-5740-4150-a377-140d6cc2d261", "ip_address": "11.11.11.3"} | | e5df42b1-cd52-41e6-9df2-c7d8739e3547 | | fa:16:3e:b2:4d:5b | {"subnet_id": "a37ce888-abb1-42d5-88ed-06e6fbacfb91", "ip_address": "172.16.74.148"} | | f1523f4e-a8b3-42df-867a-72a2505e51d1 | | fa:16:3e:c0:a6:9d | {"subnet_id": "648eaf18-7033-4401-9ce2-bea42d98c94a", "ip_address": "172.16.74.145"} | | fbdc7f8f-9c3c-4b93-a251-4a841c11cbbd | | fa:16:3e:ff:25:d7 | {"subnet_id": "648eaf18-7033-4401-9ce2-bea42d98c94a", "ip_address": "172.16.74.146"} |
执行:
neutron port-delete cb5ed928-015a-4059-b78f-816c91191b56
11、列出浮动IP池(也就是外部网络)
(nova-api)[root@cc07 nova]# nova floating-ip-pool-list
+-----------+
| name |
+-----------+
| hzb-pub1 |
| vlan_1612 |
+-----------+
12、创建浮动IP
(nova-api)[root@cc07 nova]# nova floating-ip-create vlan_1612 +--------------------------------------+---------------+-----------+----------+-----------+ | Id | IP | Server Id | Fixed IP | Pool | +--------------------------------------+---------------+-----------+----------+-----------+ | 37c2c8b1-92ec-4702-b83f-198977e4554c | 172.16.12.234 | - | - | vlan_1612 | +--------------------------------------+---------------+-----------+----------+-----------+
(nova-api)[root@cc07 nova]# nova floating-ip-list +--------------------------------------+---------------+-----------+----------+-----------+ | Id | IP | Server Id | Fixed IP | Pool | +--------------------------------------+---------------+-----------+----------+-----------+ | 37c2c8b1-92ec-4702-b83f-198977e4554c | 172.16.12.234 | - | - | vlan_1612 | | 7bb93e28-bf36-4791-aebf-94fafa27d5fa | 172.16.12.219 | - | - | vlan_1612 | | bc258041-139e-4151-98c1-a6ba7960ad59 | 172.16.12.218 | - | - | vlan_1612 | +--------------------------------------+---------------+-----------+----------+-----------+
需要指定浮动ip池
13、删除浮动ip
nova floating-ip-delete <address>
(nova-api)[root@cc07 nova]# nova floating-ip-delete 172.16.12.234 (nova-api)[root@cc07 nova]# nova floating-ip-list +--------------------------------------+---------------+-----------+----------+-----------+ | Id | IP | Server Id | Fixed IP | Pool | +--------------------------------------+---------------+-----------+----------+-----------+ | 7bb93e28-bf36-4791-aebf-94fafa27d5fa | 172.16.12.219 | - | - | vlan_1612 | | bc258041-139e-4151-98c1-a6ba7960ad59 | 172.16.12.218 | - | - | vlan_1612 | +--------------------------------------+---------------+-----------+----------+-----------+