↓ メインコンテンツへスキップ
  1. ネットワーク 記事一覧/
  2. MPLS-VPN記事一覧/

MPLS VPNのRTによる経路制御(extranet / import・export map)

目次

MPLS VPNのRTによる経路制御

RTは「その経路をどのVRFに入れるか」を決める属性です(MPLS VPNのRT(Route Target))。VRFもRDも変えずに、RTの付け方だけで「どのサイトとどのサイトが通信できるか」を作り分けられます。

RFC 4364の4.3.1は、まずRTが2種類あることを述べています。

There is a set of Route Targets that a PE router attaches to a route received from site S; these may be called the “Export Targets”. And there is a set of Route Targets that a PE router uses to determine whether a route received from another PE router could be placed in the VRF associated with site S; these may be called the “Import Targets”. The two sets are distinct, and need not be the same.

exportとimportは別物で、同じである必要はありません。 経路がVRFに入る条件はこうです。

Note that a particular VPN-IPv4 route is only eligible for installation in a particular VRF if there is some Route Target that is both one of the route’s Route Targets and one of the VRF’s Import Targets.

経路に付いているRTのどれかが、VRFのimport Targetのどれかと一致すること。 この1行だけで、以降の設計がすべて決まります。

同じRTならフルメッシュ

4.3.5は、この属性でVPNをどう組み立てるかを2つの例で説明しています。1つ目は全拠点が互いに通信できる形です。

Suppose it is desired to create a fully meshed closed user group, i.e., a set of sites where each can send traffic directly to the other, but traffic cannot be sent to or received from other sites. Then each site is associated with a VRF, a single Route Target attribute is chosen, that Route Target is assigned to each VRF as both the Import Target and the Export Target, and that Route Target is not assigned to any other VRFs as either the Import Target or the Export Target.

1つのRTを選んで、全VRFのexportにもimportにも付ける。 これがいちばん単純な形で、MPLS VPNの既定の姿でもあります。

非対称にすると拠点同士が切れる

2つ目は、RTを2つ使って中央拠点を経由する形にする例です。

Alternatively, suppose one desired, for whatever reason, to create a “hub and spoke” kind of VPN. This could be done by the use of two Route Target values, one meaning “Hub” and one meaning “Spoke”. At the VRFs attached to the hub sites, “Hub” is the Export Target and “Spoke” is the Import Target. At the VRFs attached to the spoke site, “Hub” is the Import Target and “Spoke” is the Export Target.

表にするとこうなります。

VRFexportimport
中央拠点(Hub)HubSpoke
拠点(Spoke)SpokeHub

拠点が出した経路にはSpokeが付きます。ほかの拠点はどれもSpokeをimportしていないので、拠点同士は互いの経路を受け取りません。中央拠点だけがSpokeをimportしているので、中央とはやりとりできます。

この形で止まるのは「拠点同士の直接の通信」までです。 中央拠点を経由して拠点間を通したい場合は、中央のCEで経路を広告し直す仕組みが別に要ります(MPLS VPNのハブアンドスポークで解説しています)。

エクストラネットも同じ仕組み

別の顧客のVRFとRTを交換すれば、顧客をまたいで一部だけを見せられます。エクストラネットと呼ばれる形です。同じPEの中のVRF同士でも同じで、4.3.6が明示しています。

the decision to distribute a particular route from one VRF to another within a single PE is the same decision that would be made if the VRFs were on different PEs. That is, it depends on the Route Target attribute that is assigned to the route … and the import target of the second VRF.

RTを足すだけだと、相手のVRFの経路が全部入ってきます。 一部だけにしたい場合は、importするときにプレフィックスで絞ります。IOS XRではimport route-policyを使います。

importするときに絞る(IOS XR)
prefix-set B-PRIVATE
  10.2.8.1/32
end-set
!
route-policy EXTRANET-IN
  if destination in B-PRIVATE then
    drop
  else
    pass
  endif
end-policy
!
vrf CUST-A
 address-family ipv4 unicast
  import route-target
   65001:200
  !
  import route-policy EXTRANET-IN

このポリシーはimportする経路すべてに効きます。 「共有する分だけを通す」と書くと自分のVPNの経路まで落ちるので、落としたいものだけをdropして残りはpassする書き方にします。

検証構成

顧客Aは中央拠点(CE-HUB)と2つの拠点(CE-SP1 / CE-SP2)、顧客Bは別の VRF です。2つの拠点は別々の PE に置いてあります。 同じ PE の同じ VRF に並べると、RT の設定に関係なく同じ経路表の中で通信できてしまい、遮断を見せられないからです。PE-CE は eBGP で、CE ごとに別の AS にしてあります。

STEP操作確かめること
0初期状態(全 VRF が 65001:100)フルメッシュ。 拠点1から拠点2へ ping が通る
1非対称 RT(ハブ export 65001:1000 / import 65001:1001、拠点はその逆)中央とは通じるが、拠点同士は不通。 相手の経路が BGP テーブルから消える
2拠点1の VRF にだけ import 65001:1001 を足す経路は入るのに ping は通らない。 import は受け取る側の設定なので、戻りが無い
3STEP 2 を戻すSTEP 1 の状態に戻る
4エクストラネット(ハブが 65001:200 を import + import route-policy、CUST-B がハブを import)ハブと顧客Bの共有分だけ通じる。 非共有の 10.2.8.1/32 は入らない。拠点は顧客Bと通じない
5STEP 4 を戻す(最終状態)元に戻る

同じRTならフルメッシュ

初期状態では、すべての VRF が 65001:100 を export にも import にも持っています。

STEP 0 PE1 の VRF(抜粋)
VRF CUST-A; RD 65001:1; VPN ID not set
VRF mode: Regular
Description not set
Interfaces:
  GigabitEthernet0/0/0/0
Address family IPV4 Unicast
  Import VPN route-target communities:
    RT:65001:100
  Export VPN route-target communities:
    RT:65001:100
  No import route policy
  No export route policy

拠点1の BGP テーブルには、中央拠点(10.1.1.1/32)と相手の拠点(10.1.3.1/32)の両方が入っています。

STEP 0 CE-SP1 の BGP テーブル
RP/0/RP0/CPU0:CE-SP1#show bgp
Mon Oct 12 23:50:55.966 UTC
BGP router identifier 12.12.12.12, local AS number 65102
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 8
BGP main routing table version 8
BGP NSR Initial initsync version 3 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 10.1.1.1/32        172.16.2.1                             0 65001 65101 i
*> 10.1.2.1/32        0.0.0.0                  0         32768 i
*> 10.1.3.1/32        172.16.2.1                             0 65001 65103 i
*> 172.16.1.0/24      172.16.2.1                             0 65001 ?
*> 172.16.2.0/24      172.16.2.1               0             0 65001 ?
*> 172.16.3.0/24      172.16.2.1                             0 65001 ?

Processed 6 prefixes, 6 paths

拠点1から拠点2へ ping が通ります。

STEP 0 CE-SP1 から CE-SP2 への ping
RP/0/RP0/CPU0:CE-SP1#ping 10.1.3.1 source 10.1.2.1 count 10 timeout 1
Mon Oct 12 23:47:46.834 UTC
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 10.1.3.1 timeout is 1 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 12/14/22 ms

非対称にすると拠点同士が切れる

中央拠点の VRF は 65001:1000 を export、65001:1001 を import にします。拠点側はその逆です。

STEP 1 PE1(中央拠点側)に投入した設定
vrf CUST-A
 address-family ipv4 unicast
  import route-target
   no 65001:100
   65001:1001
  !
  export route-target
   no 65001:100
   65001:1000
  !
 !
!
end
STEP 1 PE2(拠点側)に投入した設定
vrf CUST-A
 address-family ipv4 unicast
  import route-target
   no 65001:100
   65001:1000
  !
  export route-target
   no 65001:100
   65001:1001
  !
 !
!
end

VPNv4 の UPDATE に載る RT も変わります。中央拠点が出した経路には 65001:1000 が付いています。添付の STEP 1 のキャプチャーの No.9 です。

STEP 1 No.9 VPNv4 UPDATE(PE1 → P1)の Extended Communities(tshark -V の抜粋)
        Path Attribute - EXTENDED_COMMUNITIES
            Flags: 0xc0, Optional, Transitive, Complete
                1... .... = Optional: Set
                .1.. .... = Transitive: Set
                ..0. .... = Partial: Not set
                ...0 .... = Extended-Length: Not set
                .... 0000 = Unused: 0x0
            Type Code: EXTENDED_COMMUNITIES (16)
            Length: 8
            Carried extended communities: (1 community)
                Route Target: 65001:1000 [Transitive 2-Octet AS-Specific]
                    Type: Transitive 2-Octet AS-Specific (0x00)
                        0... .... = IANA Authority: Allocated on First Come First Serve Basis
                        .0.. .... = Transitive across ASes: Transitive
                    Subtype (AS2): Route Target (0x02)
                    2-Octet AS: 65001
                    4-Octet AN: 1000
上のtshark出力のパケット(No.9 VPNv4 UPDATE)のpcapをダウンロード

拠点1の BGP テーブルから、相手の拠点の経路が消えました。中央拠点の経路は残っています。

STEP 1 CE-SP1 の BGP テーブル
RP/0/RP0/CPU0:CE-SP1#show bgp
Mon Oct 12 23:58:18.400 UTC
BGP router identifier 12.12.12.12, local AS number 65102
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 14
BGP main routing table version 14
BGP NSR Initial initsync version 3 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 10.1.1.1/32        172.16.2.1                             0 65001 65101 i
*> 10.1.2.1/32        0.0.0.0                  0         32768 i
*> 172.16.1.0/24      172.16.2.1                             0 65001 ?
*> 172.16.2.0/24      172.16.2.1               0             0 65001 ?

Processed 4 prefixes, 4 paths

ping も通らなくなります。

STEP 1 CE-SP1 から CE-SP2 への ping
RP/0/RP0/CPU0:CE-SP1#ping 10.1.3.1 source 10.1.2.1 count 10 timeout 1
Mon Oct 12 23:54:50.213 UTC
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 10.1.3.1 timeout is 1 seconds:
..........
Success rate is 0 percent (0/10)

importは受け取る側の設定

拠点1の VRF にだけ、相手の拠点が export している 65001:1001 を足します。

STEP 2 PE2 に投入した設定
vrf CUST-A
 address-family ipv4 unicast
  import route-target
   65001:1001
  !
 !
!
end

拠点1の BGP テーブルに相手の拠点の経路が戻りました。

STEP 2 CE-SP1 の BGP テーブル
RP/0/RP0/CPU0:CE-SP1#show bgp
Tue Oct 13 00:05:30.410 UTC
BGP router identifier 12.12.12.12, local AS number 65102
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 16
BGP main routing table version 16
BGP NSR Initial initsync version 3 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 10.1.1.1/32        172.16.2.1                             0 65001 65101 i
*> 10.1.2.1/32        0.0.0.0                  0         32768 i
*> 10.1.3.1/32        172.16.2.1                             0 65001 65103 i
*> 172.16.1.0/24      172.16.2.1                             0 65001 ?
*> 172.16.2.0/24      172.16.2.1               0             0 65001 ?
*> 172.16.3.0/24      172.16.2.1                             0 65001 ?

Processed 6 prefixes, 6 paths

それでも ping は通りません。

STEP 2 CE-SP1 から CE-SP2 への ping
RP/0/RP0/CPU0:CE-SP1#ping 10.1.3.1 source 10.1.2.1 count 10 timeout 1
Tue Oct 13 00:01:48.348 UTC
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 10.1.3.1 timeout is 1 seconds:
..........
Success rate is 0 percent (0/10)

import は受け取る側の VRF の設定です。拠点1は相手の経路を受け取れるようになりましたが、拠点2は拠点1の経路を受け取っていないので、戻りのパケットが帰ってきません。片側だけ足しても通信にはならない、ということです。

エクストラネット

中央拠点の VRF に顧客Bの RT(65001:200)を import し、import route-policy で非共有のプレフィックスを落とします。

STEP 4 PE1 に投入した設定
vrf CUST-A
 address-family ipv4 unicast
  import route-policy EXTRANET-IN
  import route-target
   65001:200
  !
 !
!
prefix-set B-PRIVATE
  10.2.8.1/32
end-set
!
route-policy EXTRANET-IN
  if destination in B-PRIVATE then
    drop
  else
    pass
  endif
end-policy
!
end

顧客B側も、中央拠点の export(65001:1000)を import します。

STEP 4 PE3 に投入した設定
vrf CUST-B
 address-family ipv4 unicast
  import route-target
   65001:1000
  !
 !
!
end

中央拠点の BGP テーブルに、顧客Bの共有分(10.2.9.1/32)だけが入りました。非共有の 10.2.8.1/32 は入っていません。

STEP 4 CE-HUB の BGP テーブル
RP/0/RP0/CPU0:CE-HUB#show bgp
Tue Oct 13 00:19:07.218 UTC
BGP router identifier 11.11.11.11, local AS number 65101
BGP generic scan interval 60 secs
Non-stop routing is enabled
BGP table state: Active
Table ID: 0xe0000000   RD version: 18
BGP main routing table version 18
BGP NSR Initial initsync version 3 (Reached)
BGP NSR/ISSU Sync-Group versions 0/0
BGP scan interval 60 secs

Status codes: s suppressed, d damped, h history, * valid, > best
              i - internal, r RIB-failure, S stale, N Nexthop-discard
Origin codes: i - IGP, e - EGP, ? - incomplete
   Network            Next Hop            Metric LocPrf Weight Path
*> 10.1.1.1/32        0.0.0.0                  0         32768 i
*> 10.1.2.1/32        172.16.1.1                             0 65001 65102 i
*> 10.1.3.1/32        172.16.1.1                             0 65001 65103 i
*> 10.2.9.1/32        172.16.1.1                             0 65001 65201 i
*> 172.16.1.0/24      172.16.1.1               0             0 65001 ?
*> 172.16.2.0/24      172.16.1.1                             0 65001 ?
*> 172.16.3.0/24      172.16.1.1                             0 65001 ?
*> 172.16.4.0/24      172.16.1.1                             0 65001 ?

Processed 8 prefixes, 8 paths

ping でも同じです。共有分には届き、非共有には届きません。

STEP 4 CE-HUB から 10.2.9.1 への ping
RP/0/RP0/CPU0:CE-HUB#ping 10.2.9.1 source 10.1.1.1 count 10 timeout 1
Tue Oct 13 00:15:29.309 UTC
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 10.2.9.1 timeout is 1 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 12/23/71 ms
STEP 4 CE-HUB から 10.2.8.1 への ping
RP/0/RP0/CPU0:CE-HUB#ping 10.2.8.1 source 10.1.1.1 count 10 timeout 1
Tue Oct 13 00:15:30.334 UTC
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 10.2.8.1 timeout is 1 seconds:
..........
Success rate is 0 percent (0/10)

拠点からは顧客Bへ届きません。 顧客Bの RT を import しているのは中央拠点の VRF だけだからです。

STEP 4 CE-SP1 から 10.2.9.1 への ping
RP/0/RP0/CPU0:CE-SP1#ping 10.2.9.1 source 10.1.2.1 count 10 timeout 1
Tue Oct 13 00:16:11.037 UTC
Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 10.2.9.1 timeout is 1 seconds:
..........
Success rate is 0 percent (0/10)

検証Configおよびshow結果

各STEPで8台すべてから、次の種類をルータごとに分けて取得しています。検証Configはこの..._run.txtです(最終状態は最後のSTEPのもの)。

ファイル内容
..._show.txtshow version / show interface description / OSPF・LDP・BGP・VRFの各showなど
..._log.txtそのSTEPの範囲だけに絞ったshow logging
..._run.txtそのSTEP時点のshow running-config(=そのSTEPの検証Config)
..._ping.txtそのSTEPのpingとtraceroute(全CEから全CEへ)
..._trace.txtshow bgp trace(PEのみ)
..._commit.cfgそのSTEPで実際にcommitされた設定(変更したルータのみ)

STEP 0:初期状態(全 VRF が 65001:100)

ルータshow出力syslogrunning-configpingtrace投入した設定
CE-HUBshowlogrunping--
PE1showlogrunpingtrace-
P1showlogrunping--
PE2showlogrunpingtrace-
CE-SP1showlogrunping--
PE3showlogrunpingtrace-
CE-SP2showlogrunping--
CE-Bshowlogrunping--

STEP 1:非対称 RT(ハブ export 65001:1000 / import 65001:1001、拠点はその逆)

ルータshow出力syslogrunning-configpingtrace投入した設定
CE-HUBshowlogrunping--
PE1showlogrunpingtracecommit
P1showlogrunping--
PE2showlogrunpingtracecommit
CE-SP1showlogrunping--
PE3showlogrunpingtracecommit
CE-SP2showlogrunping--
CE-Bshowlogrunping--

STEP 2:拠点1の VRF にだけ import 65001:1001 を足す

ルータshow出力syslogrunning-configpingtrace投入した設定
CE-HUBshowlogrunping--
PE1showlogrunpingtrace-
P1showlogrunping--
PE2showlogrunpingtracecommit
CE-SP1showlogrunping--
PE3showlogrunpingtrace-
CE-SP2showlogrunping--
CE-Bshowlogrunping--

STEP 3:STEP 2 を戻す

ルータshow出力syslogrunning-configpingtrace投入した設定
CE-HUBshowlogrunping--
PE1showlogrunpingtrace-
P1showlogrunping--
PE2showlogrunpingtracecommit
CE-SP1showlogrunping--
PE3showlogrunpingtrace-
CE-SP2showlogrunping--
CE-Bshowlogrunping--

STEP 4:エクストラネット(ハブが 65001:200 を import + import route-policy、CUST-B がハブを import)

ルータshow出力syslogrunning-configpingtrace投入した設定
CE-HUBshowlogrunping--
PE1showlogrunpingtracecommit
P1showlogrunping--
PE2showlogrunpingtrace-
CE-SP1showlogrunping--
PE3showlogrunpingtracecommit
CE-SP2showlogrunping--
CE-Bshowlogrunping--

STEP 5:STEP 4 を戻す(最終状態)

ルータshow出力syslogrunning-configpingtrace投入した設定
CE-HUBshowlogrunping--
PE1showlogrunpingtracecommit
P1showlogrunping--
PE2showlogrunpingtrace-
CE-SP1showlogrunping--
PE3showlogrunpingtracecommit
CE-SP2showlogrunping--
CE-Bshowlogrunping--

パケットキャプチャーはSTEPごとに取得しています。

STEPPE1-P1間PE2-CE-SP1間
0pcappcap
1pcappcap
2pcappcap
3pcappcap
4pcappcap
5pcappcap

まとめ