openstack 命令行管理十四 - 路由管理 (备忘)



帮助

[root@station140 ~(network_admin)]# neutron help | grep route
  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.

查询 tenant

[root@station140 ~(network_admin)]#  keystone tenant-list
+----------------------------------+----------+---------+
|                id                |   name   | enabled |
+----------------------------------+----------+---------+
| 9467f30b8bba4770a06a687e4584636b |  cloud   |   True  |
+----------------------------------+----------+---------+

创建路由连接到外部网络, 这个路由可以与内部网络进行连接
你可以创建过程中指定一个 tenant, 利用参数 --tenant-id 9467f30b8bba4770a06a687e4584636b 进行定义

创建路由

neutron router-create ext-to-int --tenant-id 9467f30b8bba4770a06a687e4584636b
Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| external_gateway_info |                                      |
| id                    | b83f43cd-bf8f-42f8-812a-708c2c372820 |
| name                  | ext-to-int                           |
| status                | ACTIVE                               |
| tenant_id             | 9467f30b8bba4770a06a687e4584636b     |
+-----------------------+--------------------------------------+

查询方法

[root@station140 ~(keystone_admin)]# neutron router-list | grep -v router1
+--------------------------------------+------------+------------------------+
| id                                   | name       | external_gateway_info  |
+--------------------------------------+------------+------------------------+
| b83f43cd-bf8f-42f8-812a-708c2c372820 | ext-to-int | null                   |
+--------------------------------------+------------+------------------------+

查询外部网络

[root@station140 ~(keystone_admin)]# neutron net-list | grep pub1
+--------------------------------------+---------+------------------------------------------------------+
| id                                   | name    | subnets                                              |
+--------------------------------------+---------+------------------------------------------------------+
| aebe75f0-6013-4a5e-bbd9-cb81e1f017bc | pub1    | 59cc431b-498e-49a0-bc60-4a8ca1ca6f48 192.168.48.0/24 |
+--------------------------------------+---------+------------------------------------------------------+

连接路由到外部网络, 设定外部网络网关

# neutron router-gateway-set b83f43cd-bf8f-42f8-812a-708c2c372820 aebe75f0-6013-4a5e-bbd9-cb81e1f017bc

[root@station140 ~(keystone_admin)]# neutron router-list | grep -v router1
+--------------------------------------+------------+-----------------------------------------------------------------------------+
| id                                   | name       | external_gateway_info                                                       |
+--------------------------------------+------------+-----------------------------------------------------------------------------+
| b83f43cd-bf8f-42f8-812a-708c2c372820 | ext-to-int | {"network_id": "aebe75f0-6013-4a5e-bbd9-cb81e1f017bc", "enable_snat": true} |
+--------------------------------------+------------+-----------------------------------------------------------------------------+

列出子网信息

[root@station140 ~(keystone_admin)]# neutron subnet-list | grep terry
+--------------------------------------+----------------+-----------------+------------------------------------------------------+
| id                                   | name           | cidr            | allocation_pools                                     |
+--------------------------------------+----------------+-----------------+------------------------------------------------------+
| 3066c397-bccf-4473-8a94-72b09a97a70a | terry_pri_net1 | 10.0.0.0/8      | {"start": "10.0.0.50", "end": "10.0.0.100"}          |
| 59cc431b-498e-49a0-bc60-4a8ca1ca6f48 | terry_pub_net1 | 192.168.48.0/24 | {"start": "192.168.48.142", "end": "192.168.48.148"} |
+--------------------------------------+----------------+-----------------+------------------------------------------------------+


创建内部网络路由接口

[root@station140 ~(network_admin)]# neutron router-interface-add b83f43cd-bf8f-42f8-812a-708c2c372820 3066c397-bccf-4473-8a94-72b09a97a70a
Added interface c9566299-44ed-4924-b845-4fc48bd4de98bbfe84a2-508e-47a1-a664-27b2e8121893 to router b83f43cd-bf8f-42f8-812a-708c2c372820.

显示路由信息

[root@station140 ~(keystone_admin)]# neutron router-show b83f43cd-bf8f-42f8-812a-708c2c372820
+-----------------------+-----------------------------------------------------------------------------+
| Field                 | Value                                                                       |
+-----------------------+-----------------------------------------------------------------------------+
| admin_state_up        | True                                                                        |
| external_gateway_info | {"network_id": "aebe75f0-6013-4a5e-bbd9-cb81e1f017bc", "enable_snat": true} |
| id                    | b83f43cd-bf8f-42f8-812a-708c2c372820                                        |
| name                  | ext-to-int                                                                  |
| routes                |                                                                             |
| status                | ACTIVE                                                                      |
| tenant_id             | 9467f30b8bba4770a06a687e4584636b                                            |
+-----------------------+-----------------------------------------------------------------------------+


移除路由接口 (interface)

[root@station140 ~(keystone_admin)]# neutron router-interface-delete b83f43cd-bf8f-42f8-812a-708c2c372820 3066c397-bccf-4473-8a94-72b09a97a70a
Removed interface from router b83f43cd-bf8f-42f8-812a-708c2c372820


移除路由的默认网关
查询

[root@station140 ~(keystone_admin)]# neutron router-list | grep network | grep ext-to-int
+--------------------------------------+------------+-----------------------------------------------------------------------------+
| id                                   | name       | external_gateway_info                                                       |
+--------------------------------------+------------+-----------------------------------------------------------------------------+
| b83f43cd-bf8f-42f8-812a-708c2c372820 | ext-to-int | {"network_id": "aebe75f0-6013-4a5e-bbd9-cb81e1f017bc", "enable_snat": true} |
+--------------------------------------+------------+-----------------------------------------------------------------------------+

当 external_gateway_info 则表示具有默认网关

删除网关接口

[root@station140 ~(keystone_admin)]# neutron router-gateway-clear b83f43cd-bf8f-42f8-812a-708c2c372820
Removed gateway from router b83f43cd-bf8f-42f8-812a-708c2c372820

下面显示为不具备网关的路由

[root@station140 ~(keystone_admin)]# neutron router-list | grep ext-to-int
+--------------------------------------+------------+-----------------------+
| id                                   | name       | external_gateway_info |
+--------------------------------------+------------+-----------------------+
| b83f43cd-bf8f-42f8-812a-708c2c372820 | ext-to-int | null          |
+--------------------------------------+------------+-----------------------+

删除路由

[root@station140 ~(keystone_admin)]# neutron router-delete b83f43cd-bf8f-42f8-812a-708c2c372820
Deleted router: b83f43cd-bf8f-42f8-812a-708c2c372820



优秀的个人博客,低调大师

微信关注我们

原文链接:https://yq.aliyun.com/articles/70877

转载内容版权归作者及来源网站所有!

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

相关文章

发表评论

资源下载

更多资源
优质分享Android(本站安卓app)

优质分享Android(本站安卓app)

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Apache Tomcat7、8、9(Java Web服务器)

Apache Tomcat7、8、9(Java Web服务器)

Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。

Java Development Kit(Java开发工具)

Java Development Kit(Java开发工具)

JDK是 Java 语言的软件开发工具包,主要用于移动设备、嵌入式设备上的java应用程序。JDK是整个java开发的核心,它包含了JAVA的运行环境(JVM+Java系统类库)和JAVA工具。

Sublime Text 一个代码编辑器

Sublime Text 一个代码编辑器

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。