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.
表にするとこうなります。
| VRF | export | import |
|---|---|---|
| 中央拠点(Hub) | Hub | Spoke |
| 拠点(Spoke) | Spoke | Hub |
拠点が出した経路には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を使います。
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 は受け取る側の設定なので、戻りが無い |
| 3 | STEP 2 を戻す | STEP 1 の状態に戻る |
| 4 | エクストラネット(ハブが 65001:200 を import + import route-policy、CUST-B がハブを import) | ハブと顧客Bの共有分だけ通じる。 非共有の 10.2.8.1/32 は入らない。拠点は顧客Bと通じない |
| 5 | STEP 4 を戻す(最終状態) | 元に戻る |
同じRTならフルメッシュ
初期状態では、すべての VRF が 65001:100 を export にも import にも持っています。
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)の両方が入っています。
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 が通ります。
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 にします。拠点側はその逆です。
vrf CUST-A
address-family ipv4 unicast
import route-target
no 65001:100
65001:1001
!
export route-target
no 65001:100
65001:1000
!
!
!
endvrf CUST-A
address-family ipv4 unicast
import route-target
no 65001:100
65001:1000
!
export route-target
no 65001:100
65001:1001
!
!
!
endVPNv4 の UPDATE に載る RT も変わります。中央拠点が出した経路には 65001:1000 が付いています。添付の STEP 1 のキャプチャーの No.9 です。
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拠点1の 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 pathsping も通らなくなります。
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 を足します。
vrf CUST-A
address-family ipv4 unicast
import route-target
65001:1001
!
!
!
end拠点1の 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 は通りません。
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 で非共有のプレフィックスを落とします。
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 します。
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 は入っていません。
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 pathsping でも同じです。共有分には届き、非共有には届きません。
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 msRP/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 だけだからです。
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.txt | show 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.txt | show bgp trace(PEのみ) |
..._commit.cfg | そのSTEPで実際にcommitされた設定(変更したルータのみ) |
STEP 0:初期状態(全 VRF が 65001:100)
| ルータ | show出力 | syslog | running-config | ping | trace | 投入した設定 |
|---|---|---|---|---|---|---|
| CE-HUB | show | log | run | ping | - | - |
| PE1 | show | log | run | ping | trace | - |
| P1 | show | log | run | ping | - | - |
| PE2 | show | log | run | ping | trace | - |
| CE-SP1 | show | log | run | ping | - | - |
| PE3 | show | log | run | ping | trace | - |
| CE-SP2 | show | log | run | ping | - | - |
| CE-B | show | log | run | ping | - | - |
STEP 1:非対称 RT(ハブ export 65001:1000 / import 65001:1001、拠点はその逆)
| ルータ | show出力 | syslog | running-config | ping | trace | 投入した設定 |
|---|---|---|---|---|---|---|
| CE-HUB | show | log | run | ping | - | - |
| PE1 | show | log | run | ping | trace | commit |
| P1 | show | log | run | ping | - | - |
| PE2 | show | log | run | ping | trace | commit |
| CE-SP1 | show | log | run | ping | - | - |
| PE3 | show | log | run | ping | trace | commit |
| CE-SP2 | show | log | run | ping | - | - |
| CE-B | show | log | run | ping | - | - |
STEP 2:拠点1の VRF にだけ import 65001:1001 を足す
| ルータ | show出力 | syslog | running-config | ping | trace | 投入した設定 |
|---|---|---|---|---|---|---|
| CE-HUB | show | log | run | ping | - | - |
| PE1 | show | log | run | ping | trace | - |
| P1 | show | log | run | ping | - | - |
| PE2 | show | log | run | ping | trace | commit |
| CE-SP1 | show | log | run | ping | - | - |
| PE3 | show | log | run | ping | trace | - |
| CE-SP2 | show | log | run | ping | - | - |
| CE-B | show | log | run | ping | - | - |
STEP 3:STEP 2 を戻す
| ルータ | show出力 | syslog | running-config | ping | trace | 投入した設定 |
|---|---|---|---|---|---|---|
| CE-HUB | show | log | run | ping | - | - |
| PE1 | show | log | run | ping | trace | - |
| P1 | show | log | run | ping | - | - |
| PE2 | show | log | run | ping | trace | commit |
| CE-SP1 | show | log | run | ping | - | - |
| PE3 | show | log | run | ping | trace | - |
| CE-SP2 | show | log | run | ping | - | - |
| CE-B | show | log | run | ping | - | - |
STEP 4:エクストラネット(ハブが 65001:200 を import + import route-policy、CUST-B がハブを import)
| ルータ | show出力 | syslog | running-config | ping | trace | 投入した設定 |
|---|---|---|---|---|---|---|
| CE-HUB | show | log | run | ping | - | - |
| PE1 | show | log | run | ping | trace | commit |
| P1 | show | log | run | ping | - | - |
| PE2 | show | log | run | ping | trace | - |
| CE-SP1 | show | log | run | ping | - | - |
| PE3 | show | log | run | ping | trace | commit |
| CE-SP2 | show | log | run | ping | - | - |
| CE-B | show | log | run | ping | - | - |
STEP 5:STEP 4 を戻す(最終状態)
| ルータ | show出力 | syslog | running-config | ping | trace | 投入した設定 |
|---|---|---|---|---|---|---|
| CE-HUB | show | log | run | ping | - | - |
| PE1 | show | log | run | ping | trace | commit |
| P1 | show | log | run | ping | - | - |
| PE2 | show | log | run | ping | trace | - |
| CE-SP1 | show | log | run | ping | - | - |
| PE3 | show | log | run | ping | trace | commit |
| CE-SP2 | show | log | run | ping | - | - |
| CE-B | show | log | run | ping | - | - |
パケットキャプチャーはSTEPごとに取得しています。
| STEP | PE1-P1間 | PE2-CE-SP1間 |
|---|---|---|
| 0 | pcap | pcap |
| 1 | pcap | pcap |
| 2 | pcap | pcap |
| 3 | pcap | pcap |
| 4 | pcap | pcap |
| 5 | pcap | pcap |
まとめ
- MPLS VPN(L3VPN)とは
- MPLS VPNのVRF(Virtual Routing and Forwarding)
- MPLS VPNのRD(Route Distinguisher)
- MPLS VPNのRT(Route Target)
- MPLS VPNのMP-BGP(VPNv4経路の伝搬)
- MPLS VPNのVPNラベルの割り当て(per-prefix / per-CE / per-VRF)
- MPLS VPNの2段ラベルの転送(トランスポートラベルとVPNラベル)
- MPLS VPNのPE-CEルーティング(スタティック)
- MPLS VPNのPE-CEルーティング(eBGP)
- MPLS VPNで複数拠点が同じAS番号を使う場合(as-override)
- MPLS VPNのSoO(Site of Origin)
- MPLS VPNのPE-CEルーティング(OSPF)
- MPLS VPNのOSPFのDNビットとDomain Tag
- MPLS VPNのSham Link(バックドアリンク対策)
- MPLS VPNのRTによる経路制御(extranet / import・export map)
- MPLS VPNのハブアンドスポーク