SlideShare a Scribd company logo
1 of 6
Download to read offline
neutron测试例子
重要阅读提示:
黄色:命令的格式
绿色:执行的命令
红色:一些提示帮助信息
1.隔离网络创建:
1).[root@001-kilo-dvr-101-ctl02 ~]# source demo-openrc.sh
2).创建网络
命令形式:neutron net-create NETWORK
[root@001-kilo-dvr-101-ctl02 ~]# neutron net-create net1
Created a new network:
+-----------------+--------------------------------------+
| Field | Value |
+-----------------+--------------------------------------+
| admin_state_up | True |
| id | f72d8027-9cb5-42bc-8dd4-07695ad5b472 |
| mtu | 0 |
| name | net1 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-----------------+--------------------------------------+
3).在网络下创建子网
命令形式:
neutron subnet-create [-h]
[--name NAME]
[--gatewayGATEWAY_IP | --no-gateway]
[--allocation-pool start=IP_ADDR,end=IP_ADDR]
[--host-route destination=CIDR,nexthop=IP_ADDR]
[--dns-nameserver DNS_NAMESERVER]
[--disable-dhcp] [--enable-dhcp]
[--ip-version {4,6}]
[--subnetpool SUBNETPOOL]
NETWORK [CIDR]
[root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name subnet1 --allocation-pool start=10.10.10.3,end=10.10.10.130
--dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 f72d8027-9cb5-42bc-8dd4-07695ad5b472 10.10.10.0/24
Created a new subnet:
+-------------------+------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------+
| allocation_pools | {"start": "10.10.10.3", "end": "10.10.10.130"} |
| cidr | 10.10.10.0/24 |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | 10.10.10.1 |
| host_routes | |
| id | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | subnet1 |
| network_id | f72d8027-9cb5-42bc-8dd4-07695ad5b472 |
| subnetpool_id | |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-------------------+------------------------------------------------+
4).创建路由器
命令形式:neutron router-create ROUTER
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-create router-net1
Created a new router:
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| admin_state_up | True |
| external_gateway_info | |
| id | 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 |
| name | router-net1 |
| routes | |
| status | ACTIVE |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-----------------------+--------------------------------------+
5).路由器添加子网接口
neutron router-interface-add ROUTER_ID subnet=SUBNET_ID
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 subnet=d0776b76-
9b60-4a9e-a3a4-4f934b7313e0
Added interface 4cdb72d9-ab7d-473f-8b77-6418c5333b38 to router 5c752e88-b007-49c1-9c0f-2c0ae4ba2507.
注:以上为创建隔离网络的过程(这时可以测试内网中的虚拟机可以互相通信,以及内网的域名解析)
2.隔离网络获取公网ip(SNAT)
[root@001-kilo-dvr-101-ctl02 ~]# neutron net-list
+--------------------------------------+----------+-------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+----------+-------------------------------------------------------+
| f72d8027-9cb5-42bc-8dd4-07695ad5b472 | net1 | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 10.10.10.0/24 |
| 66bc4c0a-911c-4cfa-b4d6-f4384b19837f | api-net1 | 77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 192.168.199.0/24 |
| e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 | ext-net1 | b9672626-0392-4f3b-846c-7552481db11d |
+--------------------------------------+----------+-------------------------------------------------------+
注:ext-net1为公网
命令形式:neutron router-gateway-set ROUTER EXT_NET_ID
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-gateway-set router-net1 e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15
Set gatewayfor router router-net1
注:这时可以测试网络内的虚拟机可以ping通外网
3.隔离网络删除
注:这次示例要删的网络是上边新建的网络,网络设置的公网,同时网络内没有虚拟机
1).删除路由器的网关
命令形式:neutron router-gateway-clear ROUTER
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-gateway-clear 5c752e88-b007-49c1-9c0f-2c0ae4ba2507
Removed gatewayfromrouter 5c752e88-b007-49c1-9c0f-2c0ae4ba2507
2).删除路由器接口
命令形式:neutron router-interface-delete ROUTER INTERFACE
[root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-list
+--------------------------------------+-------------+------------------+------------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+-------------+------------------+------------------------------------------------------+
| 24b29466-6029-4f90-a9cc-48cbd9853c43 | vpc-subnet1 | 10.10.10.0/24 | {"start": "10.10.10.30", "end": "10.10.10.230"} |
| 5a88c6e6-8cbd-42c4-be76-68e0d7e1e6f9 | vpc-subnet2 | 11.11.11.0/24 | {"start": "11.11.11.30", "end": "11.11.11.230"} |
| 77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 | api-subnet1 | 192.168.199.0/24 | {"start": "192.168.199.2", "end": "192.168.199.254"}
|
| a95a6292-479c-4619-a0c7-b7d2ab06c102 | vpc-subnet3 | 12.12.12.0/24 | {"start": "12.12.12.30", "end": "12.12.12.230"} |
| d0776b76-9b60-4a9e-a3a4-4f934b7313e0 | subnet1 | 10.10.10.0/24 | {"start": "10.10.10.3", "end": "10.10.10.130"} |
+--------------------------------------+-------------+------------------+------------------------------------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-delete 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 d0776b76-9b60-
4a9e-a3a4-4f934b7313e0
Removed interface fromrouter 5c752e88-b007-49c1-9c0f-2c0ae4ba2507.
3).删除路由器
命令形式:neutron router-delete ROUTER
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-delete router-net1
Deleted router: router-net1
4).删除网络
命令形式:neutron net-delete NETWORK
[root@001-kilo-dvr-101-ctl02 ~]# neutron net-delete net1
Deleted network: net1
4.给某个虚拟机配置浮动ip
[root@001-kilo-dvr-101-ctl02 ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+--------------------------+
| ID | Name | Status| Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+--------------------------+
| 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 |
| 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104 |
| b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 |
+--------------------------------------+-------+--------+------------+-------------+--------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# neutron port-list
+--------------------------------------+--------------+-------------------+---------------------------------------------------------------
-------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+--------------+-------------------+---------------------------------------------------------------
-------------------------+
| 14d6d044-d972-4a0f-83ec-790e7e26e669 | | fa:16:3e:bc:d8:40 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-
54aa8c5e0f95", "ip_address": "192.168.199.104"} |
| 1c479fb9-35fa-4266-b337-2cf99c7030ca | | fa:16:3e:36:dc:34 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-
54aa8c5e0f95", "ip_address": "192.168.199.2"} |
| 20adfb97-4659-4fd0-ba9d-e9090da71a5e | | fa:16:3e:3f:33:9e | {"subnet_id": "77edbc3c-c3a2-4741-ae31-
54aa8c5e0f95", "ip_address": "192.168.199.3"} |
| 22c05f0b-3f41-4872-a0e8-1f6472886ad8 | | fa:16:3e:73:5e:11 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-
54aa8c5e0f95", "ip_address": "192.168.199.1"} |
| 32a76cf1-7163-4f4b-a916-453a659fc918 | private-port | fa:16:3e:9a:db:5b |
|
| 4cdb72d9-ab7d-473f-8b77-6418c5333b38 | | fa:16:3e:9d:91:1b | {"subnet_id": "d0776b76-9b60-4a9e-a3a4-
4f934b7313e0", "ip_address": "10.10.10.1"} |
| 74682ad5-acdf-4de7-aef2-f5dc8660811d | | fa:16:3e:45:4f:aa | {"subnet_id": "d0776b76-9b60-4a9e-a3a4-
4f934b7313e0", "ip_address": "10.10.10.3"} |
| 75cae2c8-5b6b-4b33-bb9a-e8ee284cc7c6 | | fa:16:3e:58:b9:b6 | {"subnet_id": "d0776b76-9b60-4a9e-a3a4-
4f934b7313e0", "ip_address": "10.10.10.4"} |
| 9e050ca5-14ef-4823-a80b-c820f6e5de93 | api-port2 | fa:16:3e:7c:f8:d4 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-
54aa8c5e0f95", "ip_address": "192.168.199.100"} |
| a5082303-face-468b-959c-b3405c860fab | | fa:16:3e:f6:15:d1 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-
54aa8c5e0f95", "ip_address": "192.168.199.106"} |
| fab94b32-cadf-4ff7-ad17-1b20e87f094f | | fa:16:3e:55:af:28 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-54aa8c5e0f95",
"ip_address": "192.168.199.110"} |
+--------------------------------------+--------------+-------------------+---------------------------------------------------------------
-------------------------+
根据显示的信息,我们给虚拟机test2配置floatingip,根据neutron port-list中的子网id,和虚拟机ip地址找到虚拟机的port id,
命令格式:neutron floatingip-create [--fixed-ip-addressFIXED_IP_ADDRESS] [--floating-ip-addressFLOATING_IP_ADDRESS] [-
-port-id PORT_ID] FLOATING_NETWORK
例如我们用简单的port_id来定位就可以,后面加上FLOATING_NETWORK(外网id)
[root@001-kilo-dvr-101-ctl02 ~]# neutron floatingip-create --port-id 14d6d044-d972-4a0f-83ec-790e7e26e669 e2bdc67f-
e6d2-4eb9-9e69-9a9316f5eb15
Created a new floatingip:
+---------------------+--------------------------------------+
| Field | Value |
+---------------------+--------------------------------------+
| fixed_ip_address | 192.168.199.104 |
| floating_ip_address| 110.110.110.135 |
| floating_network_id | e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 |
| id | 47e12e42-4155-4510-96ab-2d76e766cc34 |
| port_id | 14d6d044-d972-4a0f-83ec-790e7e26e669 |
| router_id | 8c9299f4-3a11-4e56-ab98-c29f463c62b3 |
| status | DOWN |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+---------------------+--------------------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| ID | Name | Status| Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 |
| 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 |
| b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
注:以上是给虚拟机配置floatingip的过程,这时可以登录到虚拟机ping一下公网,或者在公网ping一下虚拟机的floatingip
5.vpc网络多子网创建,(单子网vpc网络和隔离网络相同)
[root@001-kilo-dvr-101-ctl02 ~]# neutron net-create vpc-net1
Created a new network:
+-----------------+--------------------------------------+
| Field | Value |
+-----------------+--------------------------------------+
| admin_state_up | True |
| id | 11f539b3-d821-4c7e-b61a-e722414d06e6 |
| mtu | 0 |
| name | vpc-net1 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-----------------+--------------------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name vpc-subnet1 --allocation-pool
start=10.10.10.30,end=10.10.10.230 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 11f539b3-d821-4c7e-
b61a-e722414d06e6 10.10.10.0/24
Created a new subnet:
+-------------------+-------------------------------------------------+
| Field | Value |
+-------------------+-------------------------------------------------+
| allocation_pools | {"start": "10.10.10.30", "end": "10.10.10.230"} |
| cidr | 10.10.10.0/24 |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | 10.10.10.1 |
| host_routes | |
| id | 24b29466-6029-4f90-a9cc-48cbd9853c43 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | vpc-subnet1 |
| network_id | 11f539b3-d821-4c7e-b61a-e722414d06e6 |
| subnetpool_id | |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-------------------+-------------------------------------------------+
然后再创建第二个子网,和第三个子网
[root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name vpc-subnet2 --allocation-pool
start=11.11.11.30,end=11.11.11.230 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 11f539b3-d821-4c7e-
b61a-e722414d06e6 11.11.11.0/24
Created a new subnet:
+-------------------+-------------------------------------------------+
| Field | Value |
+-------------------+-------------------------------------------------+
| allocation_pools | {"start": "11.11.11.30", "end": "11.11.11.230"} |
| cidr | 11.11.11.0/24 |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | 11.11.11.1 |
| host_routes | |
| id | 5a88c6e6-8cbd-42c4-be76-68e0d7e1e6f9 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | vpc-subnet2 |
| network_id | 11f539b3-d821-4c7e-b61a-e722414d06e6 |
| subnetpool_id | |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-------------------+-------------------------------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name vpc-subnet3 --allocation-pool
start=12.12.12.30,end=12.12.12.230 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 11f539b3-d821-4c7e-
b61a-e722414d06e6 12.12.12.0/24
Created a new subnet:
+-------------------+-------------------------------------------------+
| Field | Value |
+-------------------+-------------------------------------------------+
| allocation_pools | {"start": "12.12.12.30", "end": "12.12.12.230"} |
| cidr | 12.12.12.0/24 |
| dns_nameservers | 114.114.114.114 |
| enable_dhcp | True |
| gateway_ip | 12.12.12.1 |
| host_routes | |
| id | a95a6292-479c-4619-a0c7-b7d2ab06c102 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | vpc-subnet3 |
| network_id | 11f539b3-d821-4c7e-b61a-e722414d06e6 |
| subnetpool_id | |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-------------------+-------------------------------------------------+
下面创建路由并连接网络下3个子网:
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-create router-vpc-net1
Created a new router:
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| admin_state_up | True |
| external_gateway_info | |
| id | 46933956-956a-4d19-84c7-7cd1fbad76a7 |
| name | router-vpc-net1 |
| routes | |
| status | ACTIVE |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-----------------------+--------------------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 46933956-956a-4d19-84c7-7cd1fbad76a7 subnet=24b29466-
6029-4f90-a9cc-48cbd9853c43
Added interface 4c33c4e2-c5d6-4c13-80df-696ec3e1d3ac to router 46933956-956a-4d19-84c7-7cd1fbad76a7.
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 46933956-956a-4d19-84c7-7cd1fbad76a7 subnet=5a88c6e6-
8cbd-42c4-be76-68e0d7e1e6f9
Added interface 37092b90-c2cc-442a-8897-881ec29bcf0e to router 46933956-956a-4d19-84c7-7cd1fbad76a7.
[root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 46933956-956a-4d19-84c7-7cd1fbad76a7 subnet=a95a6292-
479c-4619-a0c7-b7d2ab06c102
Added interface 5d331bb9-1894-4258-888d-b9f76e73ceb3 to router 46933956-956a-4d19-84c7-7cd1fbad76a7.
这样vpc网络多子网ok了,
nova 分别启动到各个子网的虚拟机,然后可以测试虚拟机的通信,
6.vpc网络获取外网和隔离网络相同,虚拟机获取floatingip也相同
7.虚拟机辅助ip地址
[root@001-kilo-dvr-101-ctl02 ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| ID | Name | Status| Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 |
| 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 |
| b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
[root@001-kilo-dvr-101-ctl02 ~]# neutron net-list
+--------------------------------------+----------+-------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+----------+-------------------------------------------------------+
| 11f539b3-d821-4c7e-b61a-e722414d06e6 | vpc-net1 | 24b29466-6029-4f90-a9cc-48cbd9853c43 10.10.10.0/24 |
| | | 5a88c6e6-8cbd-42c4-be76-68e0d7e1e6f9 11.11.11.0/24 |
| | | a95a6292-479c-4619-a0c7-b7d2ab06c102 12.12.12.0/24 |
| 66bc4c0a-911c-4cfa-b4d6-f4384b19837f | api-net1 | 77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 192.168.199.0/24 |
| e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 | ext-net1 | b9672626-0392-4f3b-846c-7552481db11d |
| f72d8027-9cb5-42bc-8dd4-07695ad5b472 | net1 | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 10.10.10.0/24 |
+--------------------------------------+----------+-------------------------------------------------------+
例如我们给test1另加一块网卡,test1实例的网络在api-net1中。
命令形式:
neutron port-create [--fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR]
[--device-id DEVICE_ID]
[--device-owner DEVICE_OWNER] [--admin-state-down]
[--mac-addressMAC_ADDRESS]
[--vnic-type <direct | macvtap | normal>]
[--binding-profile BINDING_PROFILE]
[--security-group SECURITY_GROUP | --no-securitygroups]
[--extra-dhcp-opt EXTRA_DHCP_OPTS]
[--qos-policyQOS_POLICY]
NETWORK
我们要用子网id,因为vpc网络下创建需要子网id,这样我们隔离网络和vpc都指定就可以了
[root@001-kilo-dvr-101-ctl02 ~]# neutron port-create --fixed-ip subnet_id=77edbc3c-c3a2-4741-ae31-54aa8c5e0f95
66bc4c0a-911c-4cfa-b4d6-f4384b19837f
Created a new port:
+-----------------------+----------------------------------------------------------------------------------------+
| Field | Value |
+-----------------------+----------------------------------------------------------------------------------------+
| admin_state_up | True |
| allowed_address_pairs| |
| binding:vnic_type | normal |
| device_id | |
| device_owner | |
| fixed_ips | {"subnet_id": "77edbc3c-c3a2-4741-ae31-54aa8c5e0f95", "ip_address": "192.168.199.107"} |
| id | ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5 |
| mac_address | fa:16:3e:95:ea:52 |
| name | |
| network_id | 66bc4c0a-911c-4cfa-b4d6-f4384b19837f |
| security_groups | 9219ef8f-da77-44e5-83f1-a13590018e5b |
| status | DOWN |
| tenant_id | 0f25a5f074f94726a9b19742f7e261c9 |
+-----------------------+----------------------------------------------------------------------------------------+
nova的命令形式:
nova interface-attach --port-id ID INSTANCEID
[root@001-kilo-dvr-101-ctl02 ~]# nova interface-attach --port-id ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5 7fa10cfa-423e-
47ba-aa2e-210418f71031
[root@001-kilo-dvr-101-ctl02 ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| ID | Name | Status| Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106, 192.168.199.107 |
| 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 |
| b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
这样我们的辅助ip就创建好了
命令形式:neutron port-delete PORT_ID
删除辅助ip时:
[root@001-kilo-dvr-101-ctl02 ~]# neutron port-delete ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5
Deleted port: ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5
这样就可以删除掉port了
[root@001-kilo-dvr-101-ctl02 ~]# nova list
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| ID | Name | Status| Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+
| 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 |
| 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 |
| b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 |
+--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+

More Related Content

What's hot

A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN Riyaj Shamsudeen
 
Multicloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRPMulticloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRPBob Melander
 
Enabling a Secure Multi-Tenant Environment for HPC
Enabling a Secure Multi-Tenant Environment for HPCEnabling a Secure Multi-Tenant Environment for HPC
Enabling a Secure Multi-Tenant Environment for HPCinside-BigData.com
 
Deep review of LMS process
Deep review of LMS processDeep review of LMS process
Deep review of LMS processRiyaj Shamsudeen
 
oracle cloud with 2 nodes processing
oracle cloud with 2 nodes processingoracle cloud with 2 nodes processing
oracle cloud with 2 nodes processingmahdi ahmadi
 
M|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in TimeM|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in TimeMariaDB plc
 
pstack, truss etc to understand deeper issues in Oracle database
pstack, truss etc to understand deeper issues in Oracle databasepstack, truss etc to understand deeper issues in Oracle database
pstack, truss etc to understand deeper issues in Oracle databaseRiyaj Shamsudeen
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareSage Computing Services
 
Experiences in Providing Secure Mult-Tenant Lustre Access to OpenStack
Experiences in Providing Secure Mult-Tenant Lustre Access to OpenStackExperiences in Providing Secure Mult-Tenant Lustre Access to OpenStack
Experiences in Providing Secure Mult-Tenant Lustre Access to OpenStackinside-BigData.com
 
How deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performanceHow deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performanceCumulus Networks
 
Oracle cluster installation with grid and iscsi
Oracle cluster  installation with grid and iscsiOracle cluster  installation with grid and iscsi
Oracle cluster installation with grid and iscsiChanaka Lasantha
 
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster Shaun Domingo
 

What's hot (19)

BGP communities and geotags
BGP communities and geotagsBGP communities and geotags
BGP communities and geotags
 
Mysql56 replication
Mysql56 replicationMysql56 replication
Mysql56 replication
 
A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN A deep dive about VIP,HAIP, and SCAN
A deep dive about VIP,HAIP, and SCAN
 
Digging OpenStack
Digging OpenStackDigging OpenStack
Digging OpenStack
 
Multicloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRPMulticloud connectivity using OpenNHRP
Multicloud connectivity using OpenNHRP
 
Sql2
Sql2Sql2
Sql2
 
Enabling a Secure Multi-Tenant Environment for HPC
Enabling a Secure Multi-Tenant Environment for HPCEnabling a Secure Multi-Tenant Environment for HPC
Enabling a Secure Multi-Tenant Environment for HPC
 
Deep review of LMS process
Deep review of LMS processDeep review of LMS process
Deep review of LMS process
 
oracle cloud with 2 nodes processing
oracle cloud with 2 nodes processingoracle cloud with 2 nodes processing
oracle cloud with 2 nodes processing
 
M|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in TimeM|18 Querying Data at a Previous Point in Time
M|18 Querying Data at a Previous Point in Time
 
pstack, truss etc to understand deeper issues in Oracle database
pstack, truss etc to understand deeper issues in Oracle databasepstack, truss etc to understand deeper issues in Oracle database
pstack, truss etc to understand deeper issues in Oracle database
 
Lab telematicos
Lab telematicosLab telematicos
Lab telematicos
 
The Cost Based Optimiser in 11gR2
The Cost Based Optimiser in 11gR2The Cost Based Optimiser in 11gR2
The Cost Based Optimiser in 11gR2
 
1 Dundee - Cassandra 101
1 Dundee - Cassandra 1011 Dundee - Cassandra 101
1 Dundee - Cassandra 101
 
Bind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning NightmareBind Peeking - The Endless Tuning Nightmare
Bind Peeking - The Endless Tuning Nightmare
 
Experiences in Providing Secure Mult-Tenant Lustre Access to OpenStack
Experiences in Providing Secure Mult-Tenant Lustre Access to OpenStackExperiences in Providing Secure Mult-Tenant Lustre Access to OpenStack
Experiences in Providing Secure Mult-Tenant Lustre Access to OpenStack
 
How deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performanceHow deep is your buffer – Demystifying buffers and application performance
How deep is your buffer – Demystifying buffers and application performance
 
Oracle cluster installation with grid and iscsi
Oracle cluster  installation with grid and iscsiOracle cluster  installation with grid and iscsi
Oracle cluster installation with grid and iscsi
 
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
CoreOS in anger : firing up wordpress across a 3 machine CoreOS cluster
 

Similar to neutron测试例子

Kickstat File_Draft_ESXI5.1_Template
Kickstat File_Draft_ESXI5.1_TemplateKickstat File_Draft_ESXI5.1_Template
Kickstat File_Draft_ESXI5.1_TemplateLuca Viscomi
 
Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015Stephen Gordon
 
L3HA-VRRP-20141201
L3HA-VRRP-20141201L3HA-VRRP-20141201
L3HA-VRRP-20141201Manabu Ori
 
Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
 Design and Develop SQL DDL statements which demonstrate the use of SQL objec... Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
Design and Develop SQL DDL statements which demonstrate the use of SQL objec...bhavesh lande
 
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...Codemotion
 
[2015-11월 정기 세미나]K8s on openstack
[2015-11월 정기 세미나]K8s on openstack[2015-11월 정기 세미나]K8s on openstack
[2015-11월 정기 세미나]K8s on openstackOpenStack Korea Community
 
Weird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack NeutronWeird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack NeutronNick Jones
 
MariaDB: ANALYZE for statements (lightning talk)
MariaDB:  ANALYZE for statements (lightning talk)MariaDB:  ANALYZE for statements (lightning talk)
MariaDB: ANALYZE for statements (lightning talk)Sergey Petrunya
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527Saewoong Lee
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboardsDenis Ristic
 
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習Computational Materials Science Initiative
 
Parallel Query in AWS Aurora MySQL
Parallel Query in AWS Aurora MySQLParallel Query in AWS Aurora MySQL
Parallel Query in AWS Aurora MySQLMydbops
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceKaren Morton
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraSveta Smirnova
 
ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)YoungHeon (Roy) Kim
 
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean WinnCouch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean WinnTrevor Roberts Jr.
 
Exadata - Smart Scan Testing
Exadata - Smart Scan TestingExadata - Smart Scan Testing
Exadata - Smart Scan TestingMonowar Mukul
 

Similar to neutron测试例子 (20)

Kickstat File_Draft_ESXI5.1_Template
Kickstat File_Draft_ESXI5.1_TemplateKickstat File_Draft_ESXI5.1_Template
Kickstat File_Draft_ESXI5.1_Template
 
Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015Compute 101 - OpenStack Summit Vancouver 2015
Compute 101 - OpenStack Summit Vancouver 2015
 
L3HA-VRRP-20141201
L3HA-VRRP-20141201L3HA-VRRP-20141201
L3HA-VRRP-20141201
 
Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
 Design and Develop SQL DDL statements which demonstrate the use of SQL objec... Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
Design and Develop SQL DDL statements which demonstrate the use of SQL objec...
 
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
Functional Reactive Programming with Kotlin on Android - Giorgio Natili - Cod...
 
[2015-11월 정기 세미나]K8s on openstack
[2015-11월 정기 세미나]K8s on openstack[2015-11월 정기 세미나]K8s on openstack
[2015-11월 정기 세미나]K8s on openstack
 
Switching 2
Switching 2Switching 2
Switching 2
 
Weird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack NeutronWeird things we've seen with OpenStack Neutron
Weird things we've seen with OpenStack Neutron
 
Explain
ExplainExplain
Explain
 
MariaDB: ANALYZE for statements (lightning talk)
MariaDB:  ANALYZE for statements (lightning talk)MariaDB:  ANALYZE for statements (lightning talk)
MariaDB: ANALYZE for statements (lightning talk)
 
MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527MySQL 5.7 innodb_enhance_partii_20160527
MySQL 5.7 innodb_enhance_partii_20160527
 
16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards16 MySQL Optimization #burningkeyboards
16 MySQL Optimization #burningkeyboards
 
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
第5回CCMSハンズオン(ソフトウェア講習会): AkaiKKRチュートリアル 2. AkaiKKRの実習
 
C&C Botnet Factory
C&C Botnet FactoryC&C Botnet Factory
C&C Botnet Factory
 
Parallel Query in AWS Aurora MySQL
Parallel Query in AWS Aurora MySQLParallel Query in AWS Aurora MySQL
Parallel Query in AWS Aurora MySQL
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query Performance
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
 
ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)ProxySQL & PXC(Query routing and Failover Test)
ProxySQL & PXC(Query routing and Failover Test)
 
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean WinnCouch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
Couch to OpenStack: Neutron (Quantum) - August 13, 2013 Featuring Sean Winn
 
Exadata - Smart Scan Testing
Exadata - Smart Scan TestingExadata - Smart Scan Testing
Exadata - Smart Scan Testing
 

neutron测试例子

  • 1. neutron测试例子 重要阅读提示: 黄色:命令的格式 绿色:执行的命令 红色:一些提示帮助信息 1.隔离网络创建: 1).[root@001-kilo-dvr-101-ctl02 ~]# source demo-openrc.sh 2).创建网络 命令形式:neutron net-create NETWORK [root@001-kilo-dvr-101-ctl02 ~]# neutron net-create net1 Created a new network: +-----------------+--------------------------------------+ | Field | Value | +-----------------+--------------------------------------+ | admin_state_up | True | | id | f72d8027-9cb5-42bc-8dd4-07695ad5b472 | | mtu | 0 | | name | net1 | | router:external | False | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-----------------+--------------------------------------+ 3).在网络下创建子网 命令形式: neutron subnet-create [-h] [--name NAME] [--gatewayGATEWAY_IP | --no-gateway] [--allocation-pool start=IP_ADDR,end=IP_ADDR] [--host-route destination=CIDR,nexthop=IP_ADDR] [--dns-nameserver DNS_NAMESERVER] [--disable-dhcp] [--enable-dhcp] [--ip-version {4,6}] [--subnetpool SUBNETPOOL] NETWORK [CIDR] [root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name subnet1 --allocation-pool start=10.10.10.3,end=10.10.10.130 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 f72d8027-9cb5-42bc-8dd4-07695ad5b472 10.10.10.0/24 Created a new subnet: +-------------------+------------------------------------------------+ | Field | Value | +-------------------+------------------------------------------------+ | allocation_pools | {"start": "10.10.10.3", "end": "10.10.10.130"} | | cidr | 10.10.10.0/24 | | dns_nameservers | 114.114.114.114 | | enable_dhcp | True | | gateway_ip | 10.10.10.1 | | host_routes | | | id | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | subnet1 | | network_id | f72d8027-9cb5-42bc-8dd4-07695ad5b472 | | subnetpool_id | | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-------------------+------------------------------------------------+ 4).创建路由器 命令形式:neutron router-create ROUTER [root@001-kilo-dvr-101-ctl02 ~]# neutron router-create router-net1
  • 2. Created a new router: +-----------------------+--------------------------------------+ | Field | Value | +-----------------------+--------------------------------------+ | admin_state_up | True | | external_gateway_info | | | id | 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 | | name | router-net1 | | routes | | | status | ACTIVE | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-----------------------+--------------------------------------+ 5).路由器添加子网接口 neutron router-interface-add ROUTER_ID subnet=SUBNET_ID [root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 subnet=d0776b76- 9b60-4a9e-a3a4-4f934b7313e0 Added interface 4cdb72d9-ab7d-473f-8b77-6418c5333b38 to router 5c752e88-b007-49c1-9c0f-2c0ae4ba2507. 注:以上为创建隔离网络的过程(这时可以测试内网中的虚拟机可以互相通信,以及内网的域名解析) 2.隔离网络获取公网ip(SNAT) [root@001-kilo-dvr-101-ctl02 ~]# neutron net-list +--------------------------------------+----------+-------------------------------------------------------+ | id | name | subnets | +--------------------------------------+----------+-------------------------------------------------------+ | f72d8027-9cb5-42bc-8dd4-07695ad5b472 | net1 | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 10.10.10.0/24 | | 66bc4c0a-911c-4cfa-b4d6-f4384b19837f | api-net1 | 77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 192.168.199.0/24 | | e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 | ext-net1 | b9672626-0392-4f3b-846c-7552481db11d | +--------------------------------------+----------+-------------------------------------------------------+ 注:ext-net1为公网 命令形式:neutron router-gateway-set ROUTER EXT_NET_ID [root@001-kilo-dvr-101-ctl02 ~]# neutron router-gateway-set router-net1 e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 Set gatewayfor router router-net1 注:这时可以测试网络内的虚拟机可以ping通外网 3.隔离网络删除 注:这次示例要删的网络是上边新建的网络,网络设置的公网,同时网络内没有虚拟机 1).删除路由器的网关 命令形式:neutron router-gateway-clear ROUTER [root@001-kilo-dvr-101-ctl02 ~]# neutron router-gateway-clear 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 Removed gatewayfromrouter 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 2).删除路由器接口 命令形式:neutron router-interface-delete ROUTER INTERFACE [root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-list +--------------------------------------+-------------+------------------+------------------------------------------------------+ | id | name | cidr | allocation_pools | +--------------------------------------+-------------+------------------+------------------------------------------------------+ | 24b29466-6029-4f90-a9cc-48cbd9853c43 | vpc-subnet1 | 10.10.10.0/24 | {"start": "10.10.10.30", "end": "10.10.10.230"} | | 5a88c6e6-8cbd-42c4-be76-68e0d7e1e6f9 | vpc-subnet2 | 11.11.11.0/24 | {"start": "11.11.11.30", "end": "11.11.11.230"} | | 77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 | api-subnet1 | 192.168.199.0/24 | {"start": "192.168.199.2", "end": "192.168.199.254"} | | a95a6292-479c-4619-a0c7-b7d2ab06c102 | vpc-subnet3 | 12.12.12.0/24 | {"start": "12.12.12.30", "end": "12.12.12.230"} | | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 | subnet1 | 10.10.10.0/24 | {"start": "10.10.10.3", "end": "10.10.10.130"} | +--------------------------------------+-------------+------------------+------------------------------------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-delete 5c752e88-b007-49c1-9c0f-2c0ae4ba2507 d0776b76-9b60- 4a9e-a3a4-4f934b7313e0 Removed interface fromrouter 5c752e88-b007-49c1-9c0f-2c0ae4ba2507. 3).删除路由器 命令形式:neutron router-delete ROUTER [root@001-kilo-dvr-101-ctl02 ~]# neutron router-delete router-net1 Deleted router: router-net1 4).删除网络 命令形式:neutron net-delete NETWORK [root@001-kilo-dvr-101-ctl02 ~]# neutron net-delete net1 Deleted network: net1 4.给某个虚拟机配置浮动ip [root@001-kilo-dvr-101-ctl02 ~]# nova list
  • 3. +--------------------------------------+-------+--------+------------+-------------+--------------------------+ | ID | Name | Status| Task State | Power State | Networks | +--------------------------------------+-------+--------+------------+-------------+--------------------------+ | 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 | | 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104 | | b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 | +--------------------------------------+-------+--------+------------+-------------+--------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# neutron port-list +--------------------------------------+--------------+-------------------+--------------------------------------------------------------- -------------------------+ | id | name | mac_address | fixed_ips | +--------------------------------------+--------------+-------------------+--------------------------------------------------------------- -------------------------+ | 14d6d044-d972-4a0f-83ec-790e7e26e669 | | fa:16:3e:bc:d8:40 | {"subnet_id": "77edbc3c-c3a2-4741-ae31- 54aa8c5e0f95", "ip_address": "192.168.199.104"} | | 1c479fb9-35fa-4266-b337-2cf99c7030ca | | fa:16:3e:36:dc:34 | {"subnet_id": "77edbc3c-c3a2-4741-ae31- 54aa8c5e0f95", "ip_address": "192.168.199.2"} | | 20adfb97-4659-4fd0-ba9d-e9090da71a5e | | fa:16:3e:3f:33:9e | {"subnet_id": "77edbc3c-c3a2-4741-ae31- 54aa8c5e0f95", "ip_address": "192.168.199.3"} | | 22c05f0b-3f41-4872-a0e8-1f6472886ad8 | | fa:16:3e:73:5e:11 | {"subnet_id": "77edbc3c-c3a2-4741-ae31- 54aa8c5e0f95", "ip_address": "192.168.199.1"} | | 32a76cf1-7163-4f4b-a916-453a659fc918 | private-port | fa:16:3e:9a:db:5b | | | 4cdb72d9-ab7d-473f-8b77-6418c5333b38 | | fa:16:3e:9d:91:1b | {"subnet_id": "d0776b76-9b60-4a9e-a3a4- 4f934b7313e0", "ip_address": "10.10.10.1"} | | 74682ad5-acdf-4de7-aef2-f5dc8660811d | | fa:16:3e:45:4f:aa | {"subnet_id": "d0776b76-9b60-4a9e-a3a4- 4f934b7313e0", "ip_address": "10.10.10.3"} | | 75cae2c8-5b6b-4b33-bb9a-e8ee284cc7c6 | | fa:16:3e:58:b9:b6 | {"subnet_id": "d0776b76-9b60-4a9e-a3a4- 4f934b7313e0", "ip_address": "10.10.10.4"} | | 9e050ca5-14ef-4823-a80b-c820f6e5de93 | api-port2 | fa:16:3e:7c:f8:d4 | {"subnet_id": "77edbc3c-c3a2-4741-ae31- 54aa8c5e0f95", "ip_address": "192.168.199.100"} | | a5082303-face-468b-959c-b3405c860fab | | fa:16:3e:f6:15:d1 | {"subnet_id": "77edbc3c-c3a2-4741-ae31- 54aa8c5e0f95", "ip_address": "192.168.199.106"} | | fab94b32-cadf-4ff7-ad17-1b20e87f094f | | fa:16:3e:55:af:28 | {"subnet_id": "77edbc3c-c3a2-4741-ae31-54aa8c5e0f95", "ip_address": "192.168.199.110"} | +--------------------------------------+--------------+-------------------+--------------------------------------------------------------- -------------------------+ 根据显示的信息,我们给虚拟机test2配置floatingip,根据neutron port-list中的子网id,和虚拟机ip地址找到虚拟机的port id, 命令格式:neutron floatingip-create [--fixed-ip-addressFIXED_IP_ADDRESS] [--floating-ip-addressFLOATING_IP_ADDRESS] [- -port-id PORT_ID] FLOATING_NETWORK 例如我们用简单的port_id来定位就可以,后面加上FLOATING_NETWORK(外网id) [root@001-kilo-dvr-101-ctl02 ~]# neutron floatingip-create --port-id 14d6d044-d972-4a0f-83ec-790e7e26e669 e2bdc67f- e6d2-4eb9-9e69-9a9316f5eb15 Created a new floatingip: +---------------------+--------------------------------------+ | Field | Value | +---------------------+--------------------------------------+ | fixed_ip_address | 192.168.199.104 | | floating_ip_address| 110.110.110.135 | | floating_network_id | e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 | | id | 47e12e42-4155-4510-96ab-2d76e766cc34 | | port_id | 14d6d044-d972-4a0f-83ec-790e7e26e669 | | router_id | 8c9299f4-3a11-4e56-ab98-c29f463c62b3 | | status | DOWN | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +---------------------+--------------------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# nova list +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | ID | Name | Status| Task State | Power State | Networks | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 | | 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 | | b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ 注:以上是给虚拟机配置floatingip的过程,这时可以登录到虚拟机ping一下公网,或者在公网ping一下虚拟机的floatingip
  • 4. 5.vpc网络多子网创建,(单子网vpc网络和隔离网络相同) [root@001-kilo-dvr-101-ctl02 ~]# neutron net-create vpc-net1 Created a new network: +-----------------+--------------------------------------+ | Field | Value | +-----------------+--------------------------------------+ | admin_state_up | True | | id | 11f539b3-d821-4c7e-b61a-e722414d06e6 | | mtu | 0 | | name | vpc-net1 | | router:external | False | | shared | False | | status | ACTIVE | | subnets | | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-----------------+--------------------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name vpc-subnet1 --allocation-pool start=10.10.10.30,end=10.10.10.230 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 11f539b3-d821-4c7e- b61a-e722414d06e6 10.10.10.0/24 Created a new subnet: +-------------------+-------------------------------------------------+ | Field | Value | +-------------------+-------------------------------------------------+ | allocation_pools | {"start": "10.10.10.30", "end": "10.10.10.230"} | | cidr | 10.10.10.0/24 | | dns_nameservers | 114.114.114.114 | | enable_dhcp | True | | gateway_ip | 10.10.10.1 | | host_routes | | | id | 24b29466-6029-4f90-a9cc-48cbd9853c43 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | vpc-subnet1 | | network_id | 11f539b3-d821-4c7e-b61a-e722414d06e6 | | subnetpool_id | | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-------------------+-------------------------------------------------+ 然后再创建第二个子网,和第三个子网 [root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name vpc-subnet2 --allocation-pool start=11.11.11.30,end=11.11.11.230 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 11f539b3-d821-4c7e- b61a-e722414d06e6 11.11.11.0/24 Created a new subnet: +-------------------+-------------------------------------------------+ | Field | Value | +-------------------+-------------------------------------------------+ | allocation_pools | {"start": "11.11.11.30", "end": "11.11.11.230"} | | cidr | 11.11.11.0/24 | | dns_nameservers | 114.114.114.114 | | enable_dhcp | True | | gateway_ip | 11.11.11.1 | | host_routes | | | id | 5a88c6e6-8cbd-42c4-be76-68e0d7e1e6f9 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | vpc-subnet2 | | network_id | 11f539b3-d821-4c7e-b61a-e722414d06e6 | | subnetpool_id | | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-------------------+-------------------------------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# neutron subnet-create --name vpc-subnet3 --allocation-pool start=12.12.12.30,end=12.12.12.230 --dns-nameserver 114.114.114.114 --enable-dhcp --ip-version 4 11f539b3-d821-4c7e- b61a-e722414d06e6 12.12.12.0/24 Created a new subnet:
  • 5. +-------------------+-------------------------------------------------+ | Field | Value | +-------------------+-------------------------------------------------+ | allocation_pools | {"start": "12.12.12.30", "end": "12.12.12.230"} | | cidr | 12.12.12.0/24 | | dns_nameservers | 114.114.114.114 | | enable_dhcp | True | | gateway_ip | 12.12.12.1 | | host_routes | | | id | a95a6292-479c-4619-a0c7-b7d2ab06c102 | | ip_version | 4 | | ipv6_address_mode | | | ipv6_ra_mode | | | name | vpc-subnet3 | | network_id | 11f539b3-d821-4c7e-b61a-e722414d06e6 | | subnetpool_id | | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-------------------+-------------------------------------------------+ 下面创建路由并连接网络下3个子网: [root@001-kilo-dvr-101-ctl02 ~]# neutron router-create router-vpc-net1 Created a new router: +-----------------------+--------------------------------------+ | Field | Value | +-----------------------+--------------------------------------+ | admin_state_up | True | | external_gateway_info | | | id | 46933956-956a-4d19-84c7-7cd1fbad76a7 | | name | router-vpc-net1 | | routes | | | status | ACTIVE | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-----------------------+--------------------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 46933956-956a-4d19-84c7-7cd1fbad76a7 subnet=24b29466- 6029-4f90-a9cc-48cbd9853c43 Added interface 4c33c4e2-c5d6-4c13-80df-696ec3e1d3ac to router 46933956-956a-4d19-84c7-7cd1fbad76a7. [root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 46933956-956a-4d19-84c7-7cd1fbad76a7 subnet=5a88c6e6- 8cbd-42c4-be76-68e0d7e1e6f9 Added interface 37092b90-c2cc-442a-8897-881ec29bcf0e to router 46933956-956a-4d19-84c7-7cd1fbad76a7. [root@001-kilo-dvr-101-ctl02 ~]# neutron router-interface-add 46933956-956a-4d19-84c7-7cd1fbad76a7 subnet=a95a6292- 479c-4619-a0c7-b7d2ab06c102 Added interface 5d331bb9-1894-4258-888d-b9f76e73ceb3 to router 46933956-956a-4d19-84c7-7cd1fbad76a7. 这样vpc网络多子网ok了, nova 分别启动到各个子网的虚拟机,然后可以测试虚拟机的通信, 6.vpc网络获取外网和隔离网络相同,虚拟机获取floatingip也相同 7.虚拟机辅助ip地址 [root@001-kilo-dvr-101-ctl02 ~]# nova list +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | ID | Name | Status| Task State | Power State | Networks | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 | | 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 | | b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ [root@001-kilo-dvr-101-ctl02 ~]# neutron net-list +--------------------------------------+----------+-------------------------------------------------------+ | id | name | subnets | +--------------------------------------+----------+-------------------------------------------------------+ | 11f539b3-d821-4c7e-b61a-e722414d06e6 | vpc-net1 | 24b29466-6029-4f90-a9cc-48cbd9853c43 10.10.10.0/24 | | | | 5a88c6e6-8cbd-42c4-be76-68e0d7e1e6f9 11.11.11.0/24 | | | | a95a6292-479c-4619-a0c7-b7d2ab06c102 12.12.12.0/24 | | 66bc4c0a-911c-4cfa-b4d6-f4384b19837f | api-net1 | 77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 192.168.199.0/24 | | e2bdc67f-e6d2-4eb9-9e69-9a9316f5eb15 | ext-net1 | b9672626-0392-4f3b-846c-7552481db11d | | f72d8027-9cb5-42bc-8dd4-07695ad5b472 | net1 | d0776b76-9b60-4a9e-a3a4-4f934b7313e0 10.10.10.0/24 | +--------------------------------------+----------+-------------------------------------------------------+
  • 6. 例如我们给test1另加一块网卡,test1实例的网络在api-net1中。 命令形式: neutron port-create [--fixed-ip subnet_id=SUBNET,ip_address=IP_ADDR] [--device-id DEVICE_ID] [--device-owner DEVICE_OWNER] [--admin-state-down] [--mac-addressMAC_ADDRESS] [--vnic-type <direct | macvtap | normal>] [--binding-profile BINDING_PROFILE] [--security-group SECURITY_GROUP | --no-securitygroups] [--extra-dhcp-opt EXTRA_DHCP_OPTS] [--qos-policyQOS_POLICY] NETWORK 我们要用子网id,因为vpc网络下创建需要子网id,这样我们隔离网络和vpc都指定就可以了 [root@001-kilo-dvr-101-ctl02 ~]# neutron port-create --fixed-ip subnet_id=77edbc3c-c3a2-4741-ae31-54aa8c5e0f95 66bc4c0a-911c-4cfa-b4d6-f4384b19837f Created a new port: +-----------------------+----------------------------------------------------------------------------------------+ | Field | Value | +-----------------------+----------------------------------------------------------------------------------------+ | admin_state_up | True | | allowed_address_pairs| | | binding:vnic_type | normal | | device_id | | | device_owner | | | fixed_ips | {"subnet_id": "77edbc3c-c3a2-4741-ae31-54aa8c5e0f95", "ip_address": "192.168.199.107"} | | id | ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5 | | mac_address | fa:16:3e:95:ea:52 | | name | | | network_id | 66bc4c0a-911c-4cfa-b4d6-f4384b19837f | | security_groups | 9219ef8f-da77-44e5-83f1-a13590018e5b | | status | DOWN | | tenant_id | 0f25a5f074f94726a9b19742f7e261c9 | +-----------------------+----------------------------------------------------------------------------------------+ nova的命令形式: nova interface-attach --port-id ID INSTANCEID [root@001-kilo-dvr-101-ctl02 ~]# nova interface-attach --port-id ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5 7fa10cfa-423e- 47ba-aa2e-210418f71031 [root@001-kilo-dvr-101-ctl02 ~]# nova list +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | ID | Name | Status| Task State | Power State | Networks | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106, 192.168.199.107 | | 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 | | b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ 这样我们的辅助ip就创建好了 命令形式:neutron port-delete PORT_ID 删除辅助ip时: [root@001-kilo-dvr-101-ctl02 ~]# neutron port-delete ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5 Deleted port: ef4c9855-1ba7-4f31-b9b1-b2e21143fbd5 这样就可以删除掉port了 [root@001-kilo-dvr-101-ctl02 ~]# nova list +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | ID | Name | Status| Task State | Power State | Networks | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+ | 7fa10cfa-423e-47ba-aa2e-210418f71031 | test1 | ACTIVE | - | Running | api-net1=192.168.199.106 | | 057a8e62-5740-444d-817a-f5faccc8017f | test2 | ACTIVE | - | Running | api-net1=192.168.199.104, 110.110.110.135 | | b762f140-ee10-471d-9a2f-ea9b3b8068c5 | test4 | ACTIVE | - | Running | api-net1=192.168.199.110 | +--------------------------------------+-------+--------+------------+-------------+-------------------------------------------+