首页 > 技术文章 > create subnet

gushiren 2018-09-05 14:26 原文

子网相关功能点:

模块功能描述备注
子网


创建子网 创建一个子网  
设置子网网段范围  
设置子网网关IP/不开启网关  
给子网开启/关闭dhcp  
设置子网dns  
修改子网 修改子网名称  
修改子网dhcp开启或者关闭  

修改子网dns地址

 
修改子网网关  
删除已经分配的子网IP  
删除子网 同时删除一个或多个子网  

子网相关命令:

subnet-create                      Create a subnet for a given tenant.
subnet-delete                      Delete a given subnet.
subnet-list                        List subnets that belong to a given tenant.
subnet-show                        Show information of a given subnet.
subnet-update                      Update subnet's information.
subnetpool-create                  Create a subnetpool for a given tenant.
subnetpool-delete                  Delete a given subnetpool.
subnetpool-list                    List subnetpools that belong to a given tenant.
subnetpool-show                    Show information of a given subnetpool.
subnetpool-update                  Update subnetpool's information.
subnet-create子命令相关属性:
参数
描述
参数
描述
--name 设置子网名称
--tenant-id 创建子网的租户ID
--description 描述信息
--gateway 设置子网网关
--no-gateway 不开启子网网关
--allocation-pool 允许分配的子网IP地址池
--host-route 设置子网主机路由
--dns-nameserver 设置子网dns地址
--disable-dhcp 关闭子网dhcp功能
--enable-dhcp 开启子网dhcp功能
--ip-version {4,6} IP版本

示例:创建一个子网

命令语法:neutron subnet-create < 关联的NETWORK_NAME/ID > < 要创建的subnet_CIDR > --name < subnet_name > --tenant-id < 租户ID > --description '描述信息.' --gateway < subnet网关 >  --enable-dhcp --ip-version < IP版本 >
--allocation-pool <子网池起始、结束IP> --dns-nameserver < 子网DNS>
[root@10-0-192-18 ~]# neutron subnet-create testltw 192.168.100.0/24 --name test0509 --tenant-id 73c538f5e43c4ac98ee01482f371539c --description 'this is test create subnet.' --gateway 192.168.100.1  --enable-dhcp --ip-version 4 --allocation-pool start=192.168.100.2,end=192.168.100.254 --dns-nameserver 8.8.8.8
Created a new subnet:
+-------------------+------------------------------------------------------+
| Field             | Value                                                |
+-------------------+------------------------------------------------------+
| allocation_pools  | {"start": "192.168.100.2", "end": "192.168.100.254"} |
| cidr              | 192.168.100.0/24                                     |
| created_at        | 2017-05-10T01:47:00Z                                 |
| description       | this is test create subnet.                          |
| dns_nameservers   | 8.8.8.8                                              |
| enable_dhcp       | True                                                 |
| gateway_ip        | 192.168.100.1                                        |
| host_routes       |                                                      |
| id                | 4e564b13-4336-4b8c-9217-797ef2f54380                 |
| ip_version        | 4                                                    |
| ipv6_address_mode |                                                      |
| ipv6_ra_mode      |                                                      |
| name              | test0509                                             |
| network_id        | fe054163-d056-4b8f-8c32-0b39c884fb8c                 |
| project_id        | 73c538f5e43c4ac98ee01482f371539c                     |
| revision_number   | 2                                                    |
| service_types     |                                                      |
| subnetpool_id     |                                                      |
| tenant_id         | 73c538f5e43c4ac98ee01482f371539c                     |
| updated_at        | 2017-05-10T01:47:00Z                                 |
+-------------------+------------------------------------------------------+

  

subnet-update子命令相关属性:
参数
描述
参数
描述
--name 修改子网名称
--description 描述信息
--gateway 修改子网网关
--no-gateway 关闭网关
--allocation-pool 修改子网IP地址池
--dns-nameserver 修改子网dns
--disable-dhcp 关闭子网dhcp
--enable-dhcp 开启dncp

示例:更新子网

命令语法:neutron subnet-update < 需要更新的subnet_NAME/ID > --name < 更新后subnet_NAME > --description '描述信息.' --gateway < 更新后的网关地址 > --allocation-pool < 更新后的子网池起始、终止IP >
--dns-nameserver < 更新后的DNS > --disable-dhcp < 更新后关闭dhcp >
[root@10-0-192-18 ~]# neutron subnet-update test0509 --name testltw --description 'update.' --gateway 192.168.100.254 --allocation-pool start=192.168.100.1,end=192.168.100.253 --dns-nameserver 114.114.114.114 --disable-dhcp
Updated subnet: test0509
subnet-delete子命令相关属性:
参数
描述
SUBNET 删除子网的ID(s)或NAME(s)

示例:同时删除一个或多个子网

命令语法:neutron subnet-delete < subnet_ID(s)/NAME(s)> 

[root@10-0-192-18 ~]# neutron subnet-delete jjj
Deleted subnet(s):jjj

 

推荐阅读