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
时间: 2024-09-20 05:49:52

openstack 命令行管理十四 - 路由管理 (备忘)的相关文章

命令行星期二——第四部分

命令行星期二--第四部分 大家好.新的一周,新的冒险! 今天,我们将会学习使用四个相当简单的命令去操作文件.好,废话少说,我们开始吧. 在开始学习这些命令之前,我们先稍微说些题外话,讲讲"通配符"的用处. 通配符 使用图形工具区复制.粘贴.新建目录等操作也许很容易,但是若想完成一些更复杂的任务,例如仅仅将一个目录下的所有.html文件复制到另一个目录中.或者只复制在某个目录中不存在的文件,这时命令行也许会比较方便.我们回到通配符的学习中,通配符是shell的基本功能,它是一个由一些特殊

使用WMIC从命令行对Windows的全面管理

从Windows 2000开始,WMI(Windows 管理规范)就是Windows系统管理的重要组成部分.WMIC是Windows Management Instrumentation Command-line的简称,在WMIC出现之前,要从命令行访问WMI数据库或WMI名称空间不是一件容易的事情.现在,WMIC利用WMI强大的功能把系统管理扩展到了命令行. 一.什么是WMIC? WMIC扩展WMI,提供了从命令行接口和批命令脚本执行系统管理的支持.在WMIC出现之前,如果要管理WMI系统,必

命令行式的Windows桌面管理需要从零开始吗?

  在涉及到企业的桌面管理时,管理员通常都会依赖于像微软的System Center系列产品这样的工具.然而,许多常见的Windows桌面管理功能都可以通过命令行来执行,而无需投资昂贵的管理软件. 虽然PowerShell是命令行管理的不错的选择,但它不是唯一可用的工具.微软还提供了其它一些值得一看的命令行工具.PowerShell肯定可以处理大部分Windows 7或Windows 8的桌面管理任务,但它往往需要复杂的脚本.例如,微软的"Quick and Dirty"软件清单实际上

openstack 命令行管理十八 - instance管理 (备忘)

Openstak 中, 常用 nova 命令对实例进行管理 常见管理方法有,  创建, 删除,  更改(resize flavor, 冷/热迁移), 查询 等   列出当前 tenant 中的实例 首先需要载入 keystone 验证信息 [root@gz-controller-209131 ~(keystone_admin)]# cat keystonerc_admin export OS_USERNAME=admin export OS_TENANT_NAME=admin export OS

openstack 命令行管理四 - 资源管理 (备忘)

 配额用于对每个 tenants 进行限制, 如浮动 IP, 内存, CPU, 磁盘, 密钥, 安全规则, 云硬盘等 资源管理帮助 [root@station140 ~(keystone_admin)]# nova help | grep quota quota-class-show List the quotas for a quota class. quota-class-update Update the quotas for a quota class. quota-defaults

openstack 命令行管理十六 - 网络测试 (备忘)

 注: 192.168.48.142 为 floating ip ping 测试 [root@station140 ~(keystone_admin)]# ping 192.168.48.142 PING 192.168.48.142 (192.168.48.142) 56(84) bytes of data. 64 bytes from 192.168.48.142: icmp_seq=1 ttl=63 time=1.61 ms ssh 测试 [root@station140 ~(keys

openstack 命令行管理十 - 密钥管理 (备忘)

 帮助 [root@station140 ~(keystone_admin)]# nova help | grep key flavor-key Set or unset extra_spec for a flavor. keypair-add Create a new key pair for use with instances. keypair-delete Delete keypair given by its name. keypair-list Print a list of k

openstack 命令行管理十九 - 日志管理 (备忘)

instance 终端以日志方式输出方法 [root@station140 ~(network_admin)]# nova console-log --length 80 terry_instance1 | tail Starting atd: [ OK ][ OK ] Starting yum-updatesd: [ OK ] Failed to retrieve hostname from instance metadata. This is a soft error so we'll co

openstack 命令行管理二十 - instance novnc 访问管理 (备忘)

查询实例访问方法 [root@station140 nova(keystone_admin)]# nova get-vnc-console terry_instance1 novnc +-------+-------------------------------------------------------------------------------------+ | Type | Url | +-------+--------------------------------------