1、命令一览

[root@cc07 ~]# neutron help | grep route
bgp-speaker-advertiseroute-list List routes advertised by a given BGP speaker.
l3-agent-list-hosting-router List L3 agents hosting a router.
l3-agent-router-add Add a router to a L3 agent.
l3-agent-router-remove Remove a router from a L3 agent.
net-gateway-connect Add an internal network interface to a router.
router-create Create a router for a given tenant.
router-delete Delete a given router.
router-gateway-clear Remove an external network gateway from a router.
router-gateway-set Set the external network gateway for a router.
router-interface-add Add an internal network interface to a router.
router-interface-delete Remove an internal network interface from a router.
router-list List routers that belong to a given tenant.
router-list-on-l3-agent List the routers on a L3 agent.
router-port-list List ports that belong to a given tenant, with specified router.
router-show Show information of a given router.
router-update Update router's information.

2、列表

[root@cc07 ~]# neutron router-list
+--------------------------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| id | name | external_gateway_info | distributed | ha |
+--------------------------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| 00fede5d-71cf-4c12-b694-88157a503fb5 | routerC | null | False | True |
| 2752b0c9--49ed-a044-2e960a38710a | test | null | False | False |
| 4fe00052--4ecf-bbd4-ddc28c3ed6da | routerA | null | False | True |
| 66d23d4a-472d-41e1-ba98-eee1551c40f1 | hzb-router | null | False | False |
| 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 | hzb-route-test | null | False | False |
| 75cc932a--49c3--11e50c719858 | wh-router2 | null | False | False |
| 9ef43a4b-1e96--9e14-529a90a9b87f | public_router | null | False | False |
| a7ed7a6f-efb1-4fc3-95c1-f3048230b2d5 | vpc-router | null | False | False |
| bca33800-1ddd-49dc-b6b6-313d72b97018 | wh-router | null | False | False |
| d90f3ea9-adc1-48fc-97fb-daa4a51194a8 | test123 | {"network_id": "519386bf-542a-4769-ac87-1b15ab96550c", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "732a6431-e412-4db6-a5ec-bd9913699bab", "ip_address": "172.16.12.211"}]} | False | False |
| e8a2d0cb-e27e-46e1-8bef-c727d9da13bc | vpc-router | null | False | False |
| e8de4f0e-9a6e-41ba-ad5e-1fa0d215c865 | routerB | {"network_id": "519386bf-542a-4769-ac87-1b15ab96550c", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "732a6431-e412-4db6-a5ec-bd9913699bab", "ip_address": "172.16.12.201"}]} | False | True |
| f9670288-6e74--a6f7-695ab8aab986 | wh-router | {"network_id": "519386bf-542a-4769-ac87-1b15ab96550c", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "732a6431-e412-4db6-a5ec-bd9913699bab", "ip_address": "172.16.12.207"}]} | False | False |
+--------------------------------------+----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+

3、创建路由(可以指定tenant-id)

[root@cc07 ~]# neutron router-create hzb-route-test --tenant-id 26a8e1feb372493d831c19d4d9e28d73
Created a new router:
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | |
| description | |
| distributed | False |
| external_gateway_info | |
| ha | False |
| id | 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 |
| name | hzb-route-test |
| routes | |
| rx | - |
| status | ACTIVE |
| tenant_id | 26a8e1feb372493d831c19d4d9e28d73 |
| tx | - |
+-------------------------+--------------------------------------+

4、将路由连接到外部网络(hzb-pub1),设定外部网络网关

[root@cc07 ~]# neutron net-list --tenant-id 26a8e1feb372493d831c19d4d9e28d73
+--------------------------------------+--------------+---------------------------------------------------+
| id | name | subnets |
+--------------------------------------+--------------+---------------------------------------------------+
| 0575cad8-38b0-4d0a-833c-86779f4f43bb | hzb-pub1 | |
| 2193270e-c4c9-469c-99ae-87ebdb4ba535 | hzb-privnet1 | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 10.30.0.0/ |
+--------------------------------------+--------------+---------------------------------------------------+
[root@cc07 ~]# neutron router-gateway-set 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 0575cad8-38b0-4d0a-833c-86779f4f43bb
Set gateway for router 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
[root@cc07 ~]# neutron router-show 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
+-------------------------+-------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------------+-------------------------------------------------------------------------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | nova |
| description | |
| distributed | False |
| external_gateway_info | {"network_id": "0575cad8-38b0-4d0a-833c-86779f4f43bb", "enable_snat": true, "external_fixed_ips": []} |
| ha | False |
| id | 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 |
| name | hzb-route-test |
| routes | |
| rx | - |
| status | ACTIVE |
| tenant_id | 26a8e1feb372493d831c19d4d9e28d73 |
| tx | - |
+-------------------------+-------------------------------------------------------------------------------------------------------+

5、创建内部网络路由接口(绑定子网hzb-sub-net1)

[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/ | {"start": "10.30.0.60", "end": "10.30.0.90"} |
+--------------------------------------+--------------+--------------+----------------------------------------------+
[root@cc07 ~]# neutron router-interface-add 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 0ba19972-c2f6-4cbb-80f6-a642a2f698a8
Bad router request: Subnet for router interface must have a gateway IP.
Neutron server returns request_ids: ['req-95b281ad-fe74-41f9-bc5a-0ce8d7064589']
[root@cc07 ~]#
[root@cc07 ~]#
[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/ |
| created_at | --25T06:: |
| description | |
| dns_nameservers | 8.8.8.8 |
| enable_dhcp | True |
| gateway_ip | |
| host_routes | |
| id | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 |
| ip_version | |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | hzb-sub-net1 |
| network_id | 2193270e-c4c9-469c-99ae-87ebdb4ba535 |
| subnetpool_id | |
| tenant_id | ff2958aa964541679833ddbcc503c5d2 |
| updated_at | --25T06:: |
+-------------------+----------------------------------------------+

出现以上红色字体的错误,是因为子网没有gateway_ip,我们给设置一个

neutron subnet-update 0ba19972-c2f6-4cbb-80f6-a642a2f698a8 --gateway-ip 10.30.0.1
[root@cc07 ~]# neutron router-interface-add 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 0ba19972-c2f6-4cbb-80f6-a642a2f698a8
Added interface e5add0f4-f3c0-41e0-804a-9f4f63f6eb5e to router 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9.
[root@cc07 ~]#
[root@cc07 ~]#
[root@cc07 ~]# neutron router-show 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
+-------------------------+-------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------------+-------------------------------------------------------------------------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | nova |
| description | |
| distributed | False |
| external_gateway_info | {"network_id": "0575cad8-38b0-4d0a-833c-86779f4f43bb", "enable_snat": true, "external_fixed_ips": []} |
| ha | False |
| id | 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 |
| name | hzb-route-test |
| routes | |
| rx | - |
| status | ACTIVE |
| tenant_id | 26a8e1feb372493d831c19d4d9e28d73 |
| tx | - |
+-------------------------+-------------------------------------------------------------------------------------------------------+

6、移除路由接口

[root@cc07 ~]# neutron router-interface-delete 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 0ba19972-c2f6-4cbb-80f6-a642a2f698a8
Removed interface from router 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9.

7、移除路由的默认网关

移除前:

[root@cc07 ~]# neutron router-show 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
+-------------------------+-------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------------+-------------------------------------------------------------------------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | nova |
| description | |
| distributed | False |
| external_gateway_info | {"network_id": "0575cad8-38b0-4d0a-833c-86779f4f43bb", "enable_snat": true, "external_fixed_ips": []} |
| ha | False |
| id | 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 |
| name | hzb-route-test |
| routes | |
| rx | - |
| status | ACTIVE |
| tenant_id | 26a8e1feb372493d831c19d4d9e28d73 |
| tx | - |
+-------------------------+-------------------------------------------------------------------------------------------------------+
[root@cc07 ~]# neutron router-gateway-clear 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
Removed gateway from router 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9

移除后:

[root@cc07 ~]# neutron router-show 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | nova |
| description | |
| distributed | False |
| external_gateway_info | |
| ha | False |
| id | 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9 |
| name | hzb-route-test |
| routes | |
| rx | - |
| status | ACTIVE |
| tenant_id | 26a8e1feb372493d831c19d4d9e28d73 |
| tx | - |
+-------------------------+--------------------------------------+

8、删除路由

neutron router-delete 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9

openstack路由管理命令的更多相关文章

  1. OpenStack云计算快速入门之三:OpenStack镜像管理

    原文:http://blog.chinaunix.net/uid-22414998-id-3272059.html 第三部分 OpenStack镜像管理 一.简介 很多源都有为OpenStack已经编 ...

  2. OpenStack镜像管理3

    第三部分 OpenStack镜像管理 一.简介 很多源都有为OpenStack已经编译好的各种镜像了,您可以直接下载并通过使用这些镜像来熟悉OpenStack. 不过如果是为生产环境进行部署的话,您一 ...

  3. openstack操作之一 命令行

    在openstack环境中提供了多种操作虚拟机的方法,有最简单直接的dashborad界面,有不直观但高效的命令行,还有进阶版的postman调用openstack restfulapi和命令行中使用 ...

  4. Linux就业技术指导(五):Linux运维核心管理命令详解

    一,Linux核心进程管理命令 1.1 ps:查看进程 1.1.1 命令解释 功能说明 ps命令用于列出执行ps命令的那个时刻的进程快照,就像用手机给进程照了一张照片.如果想要动态地显示进程,就需要使 ...

  5. UNIX 系统常用管理命令

    一. 引言 UNIX系统作为一种强大的多用户分时操作系统,在越来越多的场合受到了应用,同时,对UNIX的系统管理的要求也随之越来越多,但目前的书籍对UNIX系统管理命令介绍的并不是很多.本文主要是针对 ...

  6. 云计算:Linux运维核心管理命令详解

    云计算:Linux运维核心管理命令详解 想做好运维工作,人先要学会勤快: 居安而思危,勤记而补拙,方可不断提高: 别人资料不论你用着再如何爽那也是别人的: 自己总结东西是你自身特有的一种思想与理念的展 ...

  7. Linux 系统常用管理命令(精简笔记)

    Linux是一套免费使用和自由传播的类Unix操作系统,下面的笔记是我从鸟菜中摘抄出来的重要命令,并进行了一定的排版,摒弃了一些用不到的乱七八糟的命令,目的是在生产环境中能够快速的定位并查询需要命令的 ...

  8. vue(17)vue-route路由管理的安装与配置

    介绍 Vue Router 是 Vue.js官方的路由管理器.它和 Vue.js 的核心深度集成,让构建单页面应用变得易如反掌.包含的功能有: 嵌套的路由/视图表 模块化的.基于组件的路由配置 路由参 ...

  9. (转)CentOS下开机启动查看管理命令:chkconfig用法

    CentOS下开机启动查看管理命令:chkconfig用法   CentOS下开机启动查看管理的命令是:chkconfig   1. 开机启动列表查看: chkconfig --list     说明 ...

随机推荐

  1. 【linux命令总结】——后续用到的内容持续补充和更新

    比如说:某个文件是go文件,名字叫做 Hello.go 1.通过后台运行某个程序,将结果输出到某个文件, 如果是直接运行go程序:go run Hello.go 后台运行:nohup go run H ...

  2. [剑指Offer]快排

    快排 看到一篇博文提到"东拆西补"的思想,非常贴切了. 这里采用传统的方法,没有采用剑指Offer书上的方法. 细节很多,需巩固. 其他知识点 生成一个范围内随机数 见代码,这里为 ...

  3. eclipse打war包编译文件不更新

    如题.多次打包都不更新,各种clean都试了都不行.重启eclipse也不行.最后重启电脑可以了. 另外eclipse导出war包似乎存在bug,时间比系统时间超前,如下图所示.我17:19导出的包, ...

  4. java 线程Thread 技术--线程方法详解

    Thread 类常用的方法与Object类提供的线程操作方法:(一个对象只有一把锁

  5. FOR ALL ENTRIES的使用

    使用FOR ALL ENTRIES时注意: 1.一定要确定要有是否为空的判断 2.一定要注明两个表之间数据的关系 eg: IF GT_TJ30T[] IS NOT INITIAL.      SELE ...

  6. SQL Server 通过TSQL(存储过程)用MSXML去调用Webservice

    本文为转载:原文地址 在SQL SERVER 2008 R2 上亲测可用, 这个存储过程配合SoapUI使用效果更好:参考地址 前提设置:http://www.cnblogs.com/chenxizh ...

  7. 【教程】教你解决“Windows 资源保护找到了损坏文件但无法修复其中某些文件”的问题【转载】

    转载:http://www.cystc.org/?p=2827 很多人都会用sfc /scannow来解决系统文件损坏的问题,但有时也会遇到连sfc都无法修复的情况,最常见的就是出现“Windows ...

  8. python 数据类型 之 集合

    集合是一个数学概念:由一个或多个确定的元素所构成的整体叫做集合 集合的三个特性: 1.确定性 (element必须可hash,不可变类型是可hash的) 2.互异性(集合中element 不能重复) ...

  9. hdu 1541 (基本树状数组) Stars

    题目http://acm.hdu.edu.cn/showproblem.php?pid=1541 n个星星的坐标,问在某个点左边(横坐标和纵坐标不大于该点)的点的个数有多少个,输出n行,每行有一个数字 ...

  10. Python-多进程VS多线程

    多进程VS多线程 功能: 进程:能够完成多任务,比如,同时运行多个QQ 线程:能够完成多任务,比如一个QQ中的多个聊天窗口 定义 进程:系统进行资源分配和测试的一个独立单位,线程自己基本上不拥有系统资 ...