• openstack路由管理命令


    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-6766-49ed-a044-2e960a38710a | test           | null                                                                                                                                                                                      | False       | False |
    | 4fe00052-9158-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-4273-49c3-8013-11e50c719858 | wh-router2     | null                                                                                                                                                                                      | False       | False |
    | 9ef43a4b-1e96-4952-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-4468-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                      | -1                                   |
    | status                  | ACTIVE                               |
    | tenant_id               | 26a8e1feb372493d831c19d4d9e28d73     |
    | tx                      | -1                                   |
    +-------------------------+--------------------------------------+

    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/24 |
    +--------------------------------------+--------------+---------------------------------------------------+
    [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                      | -1                                                                                                    |
    | status                  | ACTIVE                                                                                                |
    | tenant_id               | 26a8e1feb372493d831c19d4d9e28d73                                                                      |
    | tx                      | -1                                                                                                    |
    +-------------------------+-------------------------------------------------------------------------------------------------------+

    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/24 | {"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/24                                 |
    | created_at        | 2018-10-25T06:25:23                          |
    | description       |                                              |
    | dns_nameservers   | 8.8.8.8                                      |
    | enable_dhcp       | True                                         |
    | gateway_ip        |                                              |
    | host_routes       |                                              |
    | id                | 0ba19972-c2f6-4cbb-80f6-a642a2f698a8         |
    | ip_version        | 4                                            |
    | ipv6_address_mode |                                              |
    | ipv6_ra_mode      |                                              |
    | name              | hzb-sub-net1                                 |
    | network_id        | 2193270e-c4c9-469c-99ae-87ebdb4ba535         |
    | subnetpool_id     |                                              |
    | tenant_id         | ff2958aa964541679833ddbcc503c5d2             |
    | updated_at        | 2018-10-25T06:42:27                          |
    +-------------------+----------------------------------------------+

    出现以上红色字体的错误,是因为子网没有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                      | -1                                                                                                    |
    | status                  | ACTIVE                                                                                                |
    | tenant_id               | 26a8e1feb372493d831c19d4d9e28d73                                                                      |
    | tx                      | -1                                                                                                    |
    +-------------------------+-------------------------------------------------------------------------------------------------------+

    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                      | -1                                                                                                    |
    | status                  | ACTIVE                                                                                                |
    | tenant_id               | 26a8e1feb372493d831c19d4d9e28d73                                                                      |
    | tx                      | -1                                                                                                    |
    +-------------------------+-------------------------------------------------------------------------------------------------------+
    [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                      | -1                                   |
    | status                  | ACTIVE                               |
    | tenant_id               | 26a8e1feb372493d831c19d4d9e28d73     |
    | tx                      | -1                                   |
    +-------------------------+--------------------------------------+

    8、删除路由

    neutron router-delete 6d61e9a4-76f3-4f33-90b3-21703d7fdfd9
  • 相关阅读:
    jQuery插件开发入门
    [转]JS学习总结-技巧、方法、细节
    JS无法获取display为none的隐藏元素的宽度和高度的解决方案
    vuejs2.0运用原生js实现简单的拖拽元素功能
    HTML5效果:Canvas 实现圆形进度条并显示数字百分比
    git常用命令总结以及用github来展示你的前端页面
    jQuery 对AMD的支持(Require.js中如何使用jQuery)
    vue+springboot上传和下载附件功能
    springboot+vue实现文件上传
    Spring boot+Vue全栈开发---Spring Boot文件上传
  • 原文地址:https://www.cnblogs.com/boshen-hzb/p/9850112.html
Copyright © 2020-2023  润新知