LoginSignup
4
3

More than 5 years have passed since last update.

OpenStack Heatオーケストレーションを使って、JUNOSルーティングを制御してみる

Last updated at Posted at 2016-12-02

NetOpsCoding Advent Calendar 2016 12/3分のエントリーです

■ 今回、チャレンジするネットワーク運用の自動化ネタ

OpenStackには、"Heat"というオーケストレーション機構が備わっています。
一般に、Heatの活用シーンは、所謂、コンピュートリソース(サーバ、ストレージ、ネットワーク)の実環境へのデプロイになります。

ちなみに、Heatで定義されるリソースモデルは、自由にカスタマイズが可能です。Pythonスクリプトで制御できる素材であれば、Heatオーケストレーションのリソース候補になります。

そこで、Pythonスクリプトで制御できる素材の応用例として、JUNOSルータをNetconfで制御する"Heat Plugin"を拡張してみました。もとネタは、こちらのブログ記事:"Python / JUNOS環境で、NETCONF動作を試してみる"になります。

Heat Architecture.001.jpeg

"Heat Plugin"拡張のやり方は、Heat Resource Plug-in Development Guideを参考にしてください。
NETCONF対応の"Heat Plugin"は、githubリポジトリ:"ttsubo/netconf_heat" にて公開しておきます。

■ NETCONF対応の"Heat Plugin"を試すための環境準備

次のような実験用ネットワークを構築するにあたり、SRX機器(2台)がターゲットになります。
ちなみに、 "192.168.100.0/24"のセグメントの先には、家庭用インタネット環境と繋がっていますので、末端のpc1側から、インタネットに抜けていくことがゴールになります。

(1) 実験用ネットワーク全体構成

OpenStack Heatオーケストレーションを使って、JUNOSルーティングを制御を行う対象装置は、SRX機器2台になります。それ以外のネットワーク機器には、事前に必要な設定が行われている前提です。

                                              < AS65000 >                 < AS65001 >                  < AS65001 >                  < 650002 >
                   +————————+                  +--------+                  +---------+                  +---------+                  +--------+                  +-----+
              .201 |        | .1          .101 |        | .1   e-BGP    .2 |         | .1   i-BGP    .2 |         | .1   e-BGP   .2  |        | .1           .2  |     |
 Internet +-------+|Quagga-1| +--------------+ | SRX-1  | +--------------+ | GoBGP-1 | +--------------+ | GoBGP-3 | +--------------+ |Quagga-2|+----------------+| pc1 |
  192.168.100.0/24 |        |  192.168.3.0/24  |        |  192.168.0.0/24  |         |   172.16.0.0/24  |         |  192.168.2.0/24  |        | 192.168.101.0/24 |     |
                   +------—-+         +        +--------+                  +---------+                  +---------+                  +--------+                  +-----+
                                      |                                                                   .2 +
                                      |                                                                      |
                                     Vrrp                                                                    |
                             (VIP: 192.168.3.100)                                                            |
                                      |                                                                      |
                                      |         +--------+                  +---------+                      |
                                      |    .102 |        | .1   e-BGP    .2 |         | .1      i-BGP        |
                                      +-------+ | SRX-2  | +--------------+ | GoBGP-2 | +--------------------+
                                                |        |  192.168.1.0/24  |         |      172.16.1.0/24
                                                +--------+                  +---------+
                                                < AS65000 >                 < AS65001 >

(2) ターゲット機器

SRX機器は、SRX100H(実機)で試しています。

SRX機器.png

そして、次のような初期コンフィグ状態から、OoenStack Heatオーケストレーションを活用して、BGP動作に必要なコンフィグ追加を行うことにしました。なお、VRRPの設定は、初期状態で設定完了済みとします。

  • SRX機器1号機の初期コンフィグ状態
tsubo@SRX-1> show configuration |display set |except "set security" |except "set system"
set version 12.1X44-D35.5
set interfaces fe-0/0/0 unit 0 family inet address 192.168.200.101/24
set interfaces fe-0/0/1 unit 0 family inet address 192.168.0.1/24
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.101/24 vrrp-group 10 virtual-address 192.168.3.100
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.101/24 vrrp-group 10 priority 254
set interfaces lo0 unit 0 family inet address 10.0.0.1/32
  • SRX機器2号機の初期コンフィグ状態
tsubo@SRX-2> show configuration |display set |except "set security" |except "set system"
set version 12.1X44-D30.4
set interfaces fe-0/0/0 unit 0 family inet address 192.168.200.102/24
set interfaces fe-0/0/1 unit 0 family inet address 192.168.1.1/24
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.102/24 vrrp-group 10 virtual-address 192.168.3.100
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.102/24 vrrp-group 10 priority 200
set interfaces lo0 unit 0 family inet address 10.0.0.2/32

(3) SRX機器での環境整備

  • 今回、OpenStack Heatを使用して、SRX機器のコンフィグ設定を行います。従って、SRX機器側では、NETCONFクライアント環境からの制御を受信できるように準備しておきます。 具体的には、NETCONFプロトコル(830ポート)を有効にしておきます。
tsubo@SRX-1> configure 
Entering configuration mode

[edit]
tsubo@SRX-1# set system services netconf ssh port 830

(4) OpenStack Heatの環境整備

$ sudo apt-get install python-ncclient
  • Heat環境が、netconfプロトコルを介して、JUNOSルータにコンフィグ設定が行えるように、Plugin拡張を行います。ここでの例では、"/sample"配下にPlugin拡張をダウンロードするものとして説明しております。
$ mkdir /sample
$ cd /sample
$ git clone https://github.com/ttsubo/netconf_heat.git
  • Plugin拡張を有効にするため、Heat-engineを停止します。
$ sudo service heat-engine stop
  • Heat設定ファイルに、Plugin拡張ディレクトリ位置をエントリします。
$ sudo vi /etc/heat/heat.conf
/etc/heat/heat.conf
[DEFAULT]
...

info = True
plugin_dirs = /sample/netconf_heat/resources

  • しばらくは、Heat-engineを手動起動して、Plugin拡張が期待通りに動作しているか確認しておきます。
$ sudo python /usr/bin/heat-engine --config-file /etc/heat/heat.conf
...

■ JUNOSコンフィグ設定の自動化を開始してみる ...

いよいよ、Heatを活用して、コンフィグ設定を行います。

(1) SRX機器1号機向けのコンフィグ設定を開始する

  • Heatクライアントを使って、Heatテンプレート定義したパラメータを指定した上で、Heatスタック"SRX_1_stack"作成を開始します。(username=xxxx;password=xxxxは、適時、置き換えてください。)
$ openstack stack create --parameter "router_ipaddr=192.168.200.101;username=xxxx;password=xxxx;router_port=830;policy_name=export-static;group_name=EXTERNAL;bgp_type=external;policy_statement=export-static;neighbor=192.168.0.2;peer_as=65001;static_route=0.0.0.0/0;next_hop=192.168.3.1;router_id=10.0.0.1;my_as=65000" --template junos_netconf.yaml SRX_1_stack
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 34db21af-a024-4953-80ca-cbd5b15f8d06 |
| stack_name          | SRX_1_stack                          |
| description         | Netconf for Junos                    |
|                     |                                      |
| creation_time       | 2016-11-26T06:18:51                  |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+
  • 設定が完了するには、数分の時間を要するので、Heatスタック動作状態を、適時、確認します。 Heatスタックのステータスが、"CREATE_COMPLETE"となれば、完了です。
$ openstack stack list
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| ID                                   | Stack Name  | Stack Status       | Creation Time       | Updated Time |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| 34db21af-a024-4953-80ca-cbd5b15f8d06 | SRX_1_stack | CREATE_IN_PROGRESS | 2016-11-26T06:18:51 | None         |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
...

$ openstack stack list
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| ID                                   | Stack Name  | Stack Status    | Creation Time       | Updated Time |
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| 34db21af-a024-4953-80ca-cbd5b15f8d06 | SRX_1_stack | CREATE_COMPLETE | 2016-11-26T06:18:51 | None         |
+--------------------------------------+-------------+-----------------+---------------------+--------------+
  • Heatスタックの詳細を確認してみます。ちなみに、showコマンドで詳細を確認すると、SRX機器に実際、コンフィグ情報の取得を行うため、コマンド完了に、しばらく時間を要するようです。(outputフィールドを確認してもらえれば、実際、netconf経由で、コンフィグ取得した結果が保持されている様子も確認できます。)
$ openstack stack show SRX_1_stack
+-----------------------+---------------------------------------------------------------------------------------------------------------------------+
| Field                 | Value                                                                                                                     |
+-----------------------+---------------------------------------------------------------------------------------------------------------------------+
| id                    | 34db21af-a024-4953-80ca-cbd5b15f8d06                                                                                      |
| stack_name            | SRX_1_stack                                                                                                               |
| description           | Netconf for Junos                                                                                                         |
|                       |                                                                                                                           |
| creation_time         | 2016-11-26T06:18:51                                                                                                       |
| updated_time          | None                                                                                                                      |
| stack_status          | CREATE_COMPLETE                                                                                                           |
| stack_status_reason   | Stack CREATE completed successfully                                                                                       |
| parameters            | OS::project_id: 6f1763f7643e4ee9bb2d2d9dd9bb0bc6                                                                          |
|                       | OS::stack_id: 34db21af-a024-4953-80ca-cbd5b15f8d06                                                                        |
|                       | OS::stack_name: SRX_1_stack                                                                                               |
|                       | bgp_type: external                                                                                                        |
|                       | group_name: EXTERNAL                                                                                                      |
|                       | my_as: '65000'                                                                                                            |
|                       | neighbor: 192.168.0.2                                                                                                     |
|                       | next_hop: 192.168.3.1                                                                                                     |
|                       | password: xxxx                                                                                                            |
|                       | peer_as: '65001'                                                                                                          |
|                       | policy_name: export-static                                                                                                |
|                       | policy_statement: export-static                                                                                           |
|                       | router_id: 10.0.0.1                                                                                                       |
|                       | router_ipaddr: 192.168.200.101                                                                                            |
|                       | router_port: '830'                                                                                                        |
|                       | static_route: 0.0.0.0/0                                                                                                   |
|                       | username: xxxx                                                                                                            |
|                       |                                                                                                                           |
| outputs               | - description: display config_routing_options                                                                             |
|                       |   output_key: display_routing_options                                                                                     |
|                       |   output_value:                                                                                                           |
|                       |     config_routing_options: "\n## Last changed: 2016-11-26 15:19:04 JST\nrouting-options\                                 |
|                       |       \ {\n    static {\n        route 0.0.0.0/0 next-hop 192.168.3.1;\n    }\n  \                                        |
|                       |       \  router-id 10.0.0.1;\n    autonomous-system 65000;\n}\n"                                                          |
|                       | - description: display config_protocols                                                                                   |
|                       |   output_key: display_protocols                                                                                           |
|                       |   output_value:                                                                                                           |
|                       |     config_protocols: "\n## Last changed: 2016-11-26 15:19:04 JST\nprotocols {\n \                                        |
|                       |       \   bgp {\n        group EXTERNAL {\n            type external;\n          \                                        |
|                       |       \  export export-static;\n            neighbor 192.168.0.2 {\n             \                                        |
|                       |       \   peer-as 65001;\n            }\n        }\n    }\n}\n"                                                           |
|                       | - description: display config_policy_options                                                                              |
|                       |   output_key: display_policy_options                                                                                      |
|                       |   output_value:                                                                                                           |
|                       |     config_routing_options: "\n## Last changed: 2016-11-26 15:19:04 JST\npolicy-options\                                  |
|                       |       \ {\n    policy-statement export-static {\n        term 1 {\n            from\                                      |
|                       |       \ protocol static;\n            then accept;\n        }\n    }\n}\n"                                                |
|                       |                                                                                                                           |
| links                 | - href: http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06 |
|                       |   rel: self                                                                                                               |
|                       |                                                                                                                           |
| disable_rollback      | True                                                                                                                      |
| parent                | None                                                                                                                      |
| tags                  | null                                                                                                                      |
|                       | ...                                                                                                                       |
|                       |                                                                                                                           |
| stack_user_project_id | 4d93e1ad2a1045179a492c8d072f5827                                                                                          |
| capabilities          | []                                                                                                                        |
| notification_topics   | []                                                                                                                        |
| timeout_mins          | None                                                                                                                      |
| stack_owner           | None                                                                                                                      |
+-----------------------+---------------------------------------------------------------------------------------------------------------------------+

  • あと、余談ですが、Heatスタックを構成する各種リソース情報も確認することが可能です。
$ openstack stack resource list SRX_1_stack
+-----------------+--------------------------------------+-------------------------------------+-----------------+---------------------+
| resource_name   | physical_resource_id                 | resource_type                       | resource_status | updated_time        |
+-----------------+--------------------------------------+-------------------------------------+-----------------+---------------------+
| policy-options  | cd9b1616-f728-4984-9cbb-97072219269f | OS::Netconf::PolicyOptionsResource  | CREATE_COMPLETE | 2016-11-26T06:18:51 |
| routing-options | 871f05d7-bd3f-49e9-b21f-fa3e6d401365 | OS::Netconf::RoutingOptionsResource | CREATE_COMPLETE | 2016-11-26T06:18:51 |
| protocols       | cb1ae2ad-329b-4225-a0ca-f8138c7b45a5 | OS::Netconf::ProtocolsResource      | CREATE_COMPLETE | 2016-11-26T06:18:51 |
+-----------------+--------------------------------------+-------------------------------------+-----------------+---------------------+

$ openstack stack resource show SRX_1_stack policy-options
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                  | Value                                                                                                                                                                                                                                                                                                                          |
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| attributes             | {u'config_routing_options': u'\n## Last changed: 2016-11-26 15:19:04 JST\npolicy-options {\n    policy-statement export-static {\n        term 1 {\n            from protocol static;\n            then accept;\n        }\n    }\n}\n'}                                                                                       |
| creation_time          | 2016-11-26T06:18:51                                                                                                                                                                                                                                                                                                            |
| description            |                                                                                                                                                                                                                                                                                                                                |
| links                  | [{u'href': u'http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06/resources/policy-options', u'rel': u'self'}, {u'href': u'http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06', u'rel': u'stack'}] |
| logical_resource_id    | policy-options                                                                                                                                                                                                                                                                                                                 |
| physical_resource_id   | cd9b1616-f728-4984-9cbb-97072219269f                                                                                                                                                                                                                                                                                           |
| required_by            | [u'protocols']                                                                                                                                                                                                                                                                                                                 |
| resource_name          | policy-options                                                                                                                                                                                                                                                                                                                 |
| resource_status        | CREATE_COMPLETE                                                                                                                                                                                                                                                                                                                |
| resource_status_reason | state changed                                                                                                                                                                                                                                                                                                                  |
| resource_type          | OS::Netconf::PolicyOptionsResource                                                                                                                                                                                                                                                                                             |
| updated_time           | 2016-11-26T06:18:51                                                                                                                                                                                                                                                                                                            |
+------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

$ openstack stack resource show SRX_1_stack routing-options
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                  | Value                                                                                                                                                                                                                                                                                                                           |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| attributes             | {u'config_routing_options': u'\n## Last changed: 2016-11-26 15:19:04 JST\nrouting-options {\n    static {\n        route 0.0.0.0/0 next-hop 192.168.3.1;\n    }\n    router-id 10.0.0.1;\n    autonomous-system 65000;\n}\n'}                                                                                                   |
| creation_time          | 2016-11-26T06:18:51                                                                                                                                                                                                                                                                                                             |
| description            |                                                                                                                                                                                                                                                                                                                                 |
| links                  | [{u'href': u'http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06/resources/routing-options', u'rel': u'self'}, {u'href': u'http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06', u'rel': u'stack'}] |
| logical_resource_id    | routing-options                                                                                                                                                                                                                                                                                                                 |
| physical_resource_id   | 871f05d7-bd3f-49e9-b21f-fa3e6d401365                                                                                                                                                                                                                                                                                            |
| required_by            | [u'protocols']                                                                                                                                                                                                                                                                                                                  |
| resource_name          | routing-options                                                                                                                                                                                                                                                                                                                 |
| resource_status        | CREATE_COMPLETE                                                                                                                                                                                                                                                                                                                 |
| resource_status_reason | state changed                                                                                                                                                                                                                                                                                                                   |
| resource_type          | OS::Netconf::RoutingOptionsResource                                                                                                                                                                                                                                                                                             |
| updated_time           | 2016-11-26T06:18:51                                                                                                                                                                                                                                                                                                             |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

$ openstack stack resource show SRX_1_stack protocols
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                  | Value                                                                                                                                                                                                                                                                                                                     |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| attributes             | {u'config_protocols': u'\n## Last changed: 2016-11-26 15:19:04 JST\nprotocols {\n    bgp {\n        group EXTERNAL {\n            type external;\n            export export-static;\n            neighbor 192.168.0.2 {\n                peer-as 65001;\n            }\n        }\n    }\n}\n'}                           |
| creation_time          | 2016-11-26T06:18:51                                                                                                                                                                                                                                                                                                       |
| description            |                                                                                                                                                                                                                                                                                                                           |
| links                  | [{u'href': u'http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06/resources/protocols', u'rel': u'self'}, {u'href': u'http://localhost:8004/v1/6f1763f7643e4ee9bb2d2d9dd9bb0bc6/stacks/SRX_1_stack/34db21af-a024-4953-80ca-cbd5b15f8d06', u'rel': u'stack'}] |
| logical_resource_id    | protocols                                                                                                                                                                                                                                                                                                                 |
| physical_resource_id   | cb1ae2ad-329b-4225-a0ca-f8138c7b45a5                                                                                                                                                                                                                                                                                      |
| required_by            | []                                                                                                                                                                                                                                                                                                                        |
| resource_name          | protocols                                                                                                                                                                                                                                                                                                                 |
| resource_status        | CREATE_COMPLETE                                                                                                                                                                                                                                                                                                           |
| resource_status_reason | state changed                                                                                                                                                                                                                                                                                                             |
| resource_type          | OS::Netconf::ProtocolsResource                                                                                                                                                                                                                                                                                            |
| updated_time           | 2016-11-26T06:18:51                                                                                                                                                                                                                                                                                                       |
+------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

(2) SRX機器2号機向けのコンフィグ設定を開始する

  • SRX機器2号機向けに、Heatテンプレート定義したパラメータを指定した上で、Heatスタック"SRX_2_stack"作成を開始します。
$ openstack stack create --parameter "router_ipaddr=192.168.200.102;username=xxxx;password=xxxx;router_port=830;policy_name=export-static;group_name=EXTERNAL;bgp_type=external;policy_statement=export-static;neighbor=192.168.1.2;peer_as=65001;static_route=0.0.0.0/0;next_hop=192.168.3.1;router_id=10.0.0.2;my_as=65000" --template junos_netconf.yaml SRX_2_stack
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| id                  | 1435cb65-0923-492f-b485-e5e1a3a266e3 |
| stack_name          | SRX_2_stack                          |
| description         | Netconf for Junos                    |
|                     |                                      |
| creation_time       | 2016-11-26T06:29:29                  |
| updated_time        | None                                 |
| stack_status        | CREATE_IN_PROGRESS                   |
| stack_status_reason | Stack CREATE started                 |
+---------------------+--------------------------------------+
  • 適時、Heatスタック作成の様子を確認します。
$ openstack stack list
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| ID                                   | Stack Name  | Stack Status       | Creation Time       | Updated Time |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| 1435cb65-0923-492f-b485-e5e1a3a266e3 | SRX_2_stack | CREATE_IN_PROGRESS | 2016-11-26T06:29:29 | None         |
| 34db21af-a024-4953-80ca-cbd5b15f8d06 | SRX_1_stack | CREATE_COMPLETE    | 2016-11-26T06:18:51 | None         |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
...

$ openstack stack list
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| ID                                   | Stack Name  | Stack Status    | Creation Time       | Updated Time |
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| 1435cb65-0923-492f-b485-e5e1a3a266e3 | SRX_2_stack | CREATE_COMPLETE | 2016-11-26T06:29:29 | None         |
| 34db21af-a024-4953-80ca-cbd5b15f8d06 | SRX_1_stack | CREATE_COMPLETE | 2016-11-26T06:18:51 | None         |
+--------------------------------------+-------------+-----------------+---------------------+--------------+

■ 実験用ネットワーク環境が整ったので、しばらく、遊んでみる。

もう一度、実験用ネットワーク全体構成図を再掲しておきます。

                                              < AS65000 >                 < AS65001 >                  < AS65001 >                  < 650002 >
                   +————————+                  +--------+                  +---------+                  +---------+                  +--------+                  +-----+
              .201 |        | .1          .101 |        | .1   e-BGP    .2 |         | .1   i-BGP    .2 |         | .1   e-BGP   .2  |        | .1           .2  |     |
 Internet +-------+|Quagga-1| +--------------+ | SRX-1  | +--------------+ | GoBGP-1 | +--------------+ | GoBGP-3 | +--------------+ |Quagga-2|+----------------+| pc1 |
  192.168.100.0/24 |        |  192.168.3.0/24  |        |  192.168.0.0/24  |         |   172.16.0.0/24  |         |  192.168.2.0/24  |        | 192.168.101.0/24 |     |
                   +------—-+         +        +--------+                  +---------+                  +---------+                  +--------+                  +-----+
                                      |                                                                   .2 +
                                      |                                                                      |
                                     Vrrp                                                                    |
                             (VIP: 192.168.3.100)                                                            |
                                      |                                                                      |
                                      |         +--------+                  +---------+                      |
                                      |    .102 |        | .1   e-BGP    .2 |         | .1      i-BGP        |
                                      +-------+ | SRX-2  | +--------------+ | GoBGP-2 | +--------------------+
                                                |        |  192.168.1.0/24  |         |      172.16.1.0/24
                                                +--------+                  +---------+
                                                < AS65000 >                 < AS65001 >

(1) まずは、コンフィグ情報を確認します。

  • SRX機器1号機から ...
tsubo@SRX-1> show configuration |display set |except "set security" |except "set system"
set version 12.1X44-D35.5
set interfaces fe-0/0/0 unit 0 family inet address 192.168.200.101/24
set interfaces fe-0/0/1 unit 0 family inet address 192.168.0.1/24
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.101/24 vrrp-group 10 virtual-address 192.168.3.100
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.101/24 vrrp-group 10 priority 254
set interfaces lo0 unit 0 family inet address 10.0.0.1/32
set routing-options static route 0.0.0.0/0 next-hop 192.168.3.1
set routing-options router-id 10.0.0.1
set routing-options autonomous-system 65000
set protocols bgp group EXTERNAL type external
set protocols bgp group EXTERNAL export export-static
set protocols bgp group EXTERNAL neighbor 192.168.0.2 peer-as 65001
set policy-options policy-statement export-static term 1 from protocol static
set policy-options policy-statement export-static term 1 then accept
  • つづいて、SRX機器2号機 ...
tsubo@SRX-2> show configuration |display set |except "set security" |except "set system"
set version 12.1X44-D30.4
set interfaces fe-0/0/0 unit 0 family inet address 192.168.200.102/24
set interfaces fe-0/0/1 unit 0 family inet address 192.168.1.1/24
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.102/24 vrrp-group 10 virtual-address 192.168.3.100
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.102/24 vrrp-group 10 priority 200
set interfaces lo0 unit 0 family inet address 10.0.0.2/32
set routing-options static route 0.0.0.0/0 next-hop 192.168.3.1
set routing-options router-id 10.0.0.2
set routing-options autonomous-system 65000
set protocols bgp group EXTERNAL type external
set protocols bgp group EXTERNAL export export-static
set protocols bgp group EXTERNAL neighbor 192.168.1.2 peer-as 65001
set policy-options policy-statement export-static term 1 from protocol static
set policy-options policy-statement export-static term 1 then accept
  • GoBGP3号機でのBGPテーブルを確認してみる。
pi@gobgp3:~ $ gobgp global rib
    Network             Next Hop             AS_PATH              Age        Attrs
*>  0.0.0.0/0           172.16.0.1           65000                00:28:23   [{Origin: i} {LocalPref: 100}]
*   0.0.0.0/0           172.16.1.1           65000                00:17:36   [{Origin: i} {LocalPref: 100}]
*>  192.168.101.0/24    192.168.2.2          65002                00:59:49   [{Origin: i} {Med: 0}]

はい、SRX機器で配信されたデフォルトルートが、GoBGP3号機で正しく学習できているようです。

(2) エンドエンドで、通信してみる

  • まずは、pc1側から、定番のping確認してみると ...
$ ping 192.168.100.1
PING 192.168.100.1 (192.168.100.1): 56 data bytes
64 bytes from 192.168.100.1: icmp_seq=0 ttl=250 time=1.964 ms
64 bytes from 192.168.100.1: icmp_seq=1 ttl=250 time=1.982 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=250 time=1.889 ms
64 bytes from 192.168.100.1: icmp_seq=3 ttl=250 time=1.958 ms
^C
--- 192.168.100.1 ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 1.889/1.948/1.982/0.035 ms
  • さらに、pc1側から、YouTubeを閲覧してみました ...

youtube.png

おっ!! 懐かしの、ナイトレンジャーだ!

(3) ついで、BGP経路冗長の動作も確認してみる。

  • SRX機器1号機側で、物理IFを断線させると、ICMP ECHO Replyパケット4発程度の取りこぼしが発生しましたが、その後、復旧しています。
$ ping 192.168.100.1
PING 192.168.100.1 (192.168.100.1): 56 data bytes
64 bytes from 192.168.100.1: icmp_seq=0 ttl=250 time=1.860 ms
64 bytes from 192.168.100.1: icmp_seq=1 ttl=250 time=1.922 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=250 time=1.963 ms
64 bytes from 192.168.100.1: icmp_seq=3 ttl=250 time=1.973 ms
64 bytes from 192.168.100.1: icmp_seq=4 ttl=250 time=2.260 ms
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 7
Request timeout for icmp_seq 8
64 bytes from 192.168.100.1: icmp_seq=9 ttl=250 time=1.945 ms
64 bytes from 192.168.100.1: icmp_seq=10 ttl=250 time=2.064 ms
64 bytes from 192.168.100.1: icmp_seq=11 ttl=250 time=2.156 ms
64 bytes from 192.168.100.1: icmp_seq=12 ttl=250 time=1.992 ms
^C
  • この時、GoBGP3号機でのBGPテーブルを確認してみると、経路が切り替わったことが確認できました。
pi@gobgp3:~ $ gobgp global rib
    Network             Next Hop             AS_PATH              Age        Attrs
*>  0.0.0.0/0           172.16.1.1           65000                00:05:31   [{Origin: i} {LocalPref: 100}]
*>  192.168.101.0/24    192.168.2.2          65002                00:05:40   [{Origin: i} {Med: 0}]

■ 後作業として、SRX機器のコンフィグ環境を元に戻しておく ...

楽しい、ネットワーク実験が終わったので、最後に後片付けです。
OpenStack Heatオーケストレーションを活用しているので、ここでは、Heatスタックを削除するだけです!!

(1) Heatスタックを削除します。

  • まずは、SRX機器1号機から ...
$ openstack stack delete SRX_1_stack
Are you sure you want to delete this stack(s) [y/N]? y
  • 削除設定が完了するには、数分の時間を要するので、Heatスタック動作状態を、適時、確認します。Heatスタックのレコードが削除されていれば、完了です。
openstack stack list
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| ID                                   | Stack Name  | Stack Status       | Creation Time       | Updated Time |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
| 1435cb65-0923-492f-b485-e5e1a3a266e3 | SRX_2_stack | CREATE_COMPLETE    | 2016-11-26T06:29:29 | None         |
| 34db21af-a024-4953-80ca-cbd5b15f8d06 | SRX_1_stack | DELETE_IN_PROGRESS | 2016-11-26T06:18:51 | None         |
+--------------------------------------+-------------+--------------------+---------------------+--------------+
...

$ openstack stack list
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| ID                                   | Stack Name  | Stack Status    | Creation Time       | Updated Time |
+--------------------------------------+-------------+-----------------+---------------------+--------------+
| 1435cb65-0923-492f-b485-e5e1a3a266e3 | SRX_2_stack | CREATE_COMPLETE | 2016-11-26T06:29:29 | None         |
+--------------------------------------+-------------+-----------------+---------------------+--------------+
  • つづいて、SRX機器2号機 ...
$ openstack stack delete SRX_2_stack
Are you sure you want to delete this stack(s) [y/N]? y
  • はい、Heatスタックは、すべて削除されました。
$ openstack stack list

(2) いちおう、コンフィグ情報を確認します。

  • まずは、SRX機器1号機から ...
tsubo@SRX-1> show configuration |display set |except "set security" |except "set system"
set version 12.1X44-D35.5
set interfaces fe-0/0/0 unit 0 family inet address 192.168.200.101/24
set interfaces fe-0/0/1 unit 0 family inet address 192.168.0.1/24
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.101/24 vrrp-group 10 virtual-address 192.168.3.100
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.101/24 vrrp-group 10 priority 254
set interfaces lo0 unit 0 family inet address 10.0.0.1/32
  • つづいて、SRX機器2号機 ...
tsubo@SRX-2> show configuration |display set |except "set security" |except "set system"
set version 12.1X44-D30.4
set interfaces fe-0/0/0 unit 0 family inet address 192.168.200.102/24
set interfaces fe-0/0/1 unit 0 family inet address 192.168.1.1/24
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.102/24 vrrp-group 10 virtual-address 192.168.3.100
set interfaces fe-0/0/2 unit 0 family inet address 192.168.3.102/24 vrrp-group 10 priority 200
set interfaces lo0 unit 0 family inet address 10.0.0.2/32

期待通りに、最初のコンフィグ状態に戻りましたね!:grinning:

■ 最後に ...

OpenStack Heatを活用すれば、従来のネットワーク機器さえも、オーケストレーション対応のコンフィグ設定の自動化が実現できてしまう時代になりました。
ただし、難点なのが、各自の環境に即したHeatテンプレートを記述するスキルの習得が必要不可欠です。
日本OpenStackユーザ会 第28回勉強会では、”Heat によるオーケストレーション入門”をテーマとして取り上げられておりましたので、学習素材として大変有益だと思いました。

■ その他、参考にしたURL情報

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3