【概要】
通常、VRFは同一VRF内でのみ通信が可能で、異なるVRFへの通信はできない。
ただ、通信要件的に異なるVRF間の通信をしなくてはならない場合が出てくることがある。
そこで、BGPを利用してVRF間の通信を可能とする方法の1つをメモ書きする。
構成図
before = 単純なVRF-liteで同一VRF内でしか通信できない。
after = VRF間通信を可能にする。
※矢印は通信可能を表す
同一VRF内だけでなく、他のVRF間も通信できるようにする
config
R1-config click
hostname R1 ! vrf definition VRF-A rd 1:1 ! address-family ipv4 route-target export 1:1 route-target import 2:2 route-target import 3:3 exit-address-family ! vrf definition VRF-B rd 2:2 ! address-family ipv4 route-target export 2:2 route-target import 1:1 route-target import 3:3 exit-address-family ! vrf definition VRF-C rd 3:3 ! address-family ipv4 route-target export 3:3 route-target import 1:1 route-target import 2:2 exit-address-family ! interface Loopback0 ip address 1.1.1.1 255.255.255.255 ! interface GigabitEthernet0/0 vrf forwarding VRF-A ip address 192.168.1.254 255.255.255.0 ! interface GigabitEthernet0/1 vrf forwarding VRF-B ip address 192.168.2.254 255.255.255.0 ! interface GigabitEthernet0/2 vrf forwarding VRF-C ip address 192.168.3.254 255.255.255.0 ! interface GigabitEthernet0/3 vrf forwarding VRF-A ip address 192.168.4.254 255.255.255.0 ! interface GigabitEthernet0/4 vrf forwarding VRF-B ip address 192.168.5.254 255.255.255.0 ! interface GigabitEthernet0/5 vrf forwarding VRF-C ip address 192.168.6.254 255.255.255.0 ! router bgp 1 bgp router-id 1.1.1.1 bgp log-neighbor-changes ! address-family ipv4 vrf VRF-A redistribute connected exit-address-family ! address-family ipv4 vrf VRF-B redistribute connected exit-address-family ! address-family ipv4 vrf VRF-C redistribute connected exit-address-family ! control-plane ! end
BGP設定について
- MP-BGPによりVRF route-leakを実現する (BGP設定を消去するとVRF間通信は不可になる)
- 例の場合、BGP neighbor設定は必要無し(neighborがいない)
- BGP redistribute connectは必須(他staticやOSPFなどが存在する場合、それを再配布する)
- BGP AS番号は任意
- BGPを利用したくない場合、Static-routeなどを利用
route-target
- [route-target export]は自身のVRFルートを広報するこを許可する設定のため自身のrd番号を設定
- [route-target import]は自身のVRFルートへ受入れ許可する設定のため対象rd番号を設定
- leakしたく無いルートがあれば、[route-target]で調整
vrf definition VRF-A rd 1:1 ! address-family ipv4 route-target export 1:1 route-target import 2:2 route-target import 3:3 exit-address-family !
vrf definition VRF-B rd 2:2 ! address-family ipv4 route-target export 2:2 route-target import 1:1 route-target import 3:3 exit-address-family !
vrf definition VRF-C rd 3:3 ! address-family ipv4 route-target export 3:3 route-target import 1:1 route-target import 2:2 exit-address-family
pingによる通信確認
構成図 after通りVRF間のping通信も可能となる。
例)PC1 -> PC2/PC3/PC4/PC5/PC6に対し、pingを実施し応答あり
show コマンドで確認
show ip route vrf-xx
R1#show ip route vrf VRF-A Gateway of last resort is not set C 192.168.1.0/24 is directly connected, GigabitEthernet0/0 //VRF-A B 192.168.2.0/24 is directly connected, 00:49:16, GigabitEthernet0/1 //VRF-B B 192.168.3.0/24 is directly connected, 00:49:16, GigabitEthernet0/2 //VRF-C C 192.168.4.0/24 is directly connected, GigabitEthernet0/3 //VRF-A B 192.168.5.0/24 is directly connected, 00:07:29, GigabitEthernet0/4 //VRF-B B 192.168.6.0/24 is directly connected, 00:07:29, GigabitEthernet0/5 //VRF-C
R1#show ip route vrf VRF-B Gateway of last resort is not set B 192.168.1.0/24 is directly connected, 00:50:37, GigabitEthernet0/0 //VRF-A C 192.168.2.0/24 is directly connected, GigabitEthernet0/1 //VRF-B B 192.168.3.0/24 is directly connected, 00:50:37, GigabitEthernet0/2 //VRF-C B 192.168.4.0/24 is directly connected, 00:08:51, GigabitEthernet0/3 //VRF-A C 192.168.5.0/24 is directly connected, GigabitEthernet0/4 //VRF-B B 192.168.6.0/24 is directly connected, 00:08:50, GigabitEthernet0/5 //VRF-C
R1#show ip route vrf VRF-C Gateway of last resort is not set B 192.168.1.0/24 is directly connected, 00:51:37, GigabitEthernet0/0 //VRF-A B 192.168.2.0/24 is directly connected, 00:51:37, GigabitEthernet0/1 //VRF-B C 192.168.3.0/24 is directly connected, GigabitEthernet0/2 //VRF-C B 192.168.4.0/24 is directly connected, 00:09:51, GigabitEthernet0/3 //VRF-A B 192.168.5.0/24 is directly connected, 00:09:50, GigabitEthernet0/4 //VRF-B C 192.168.6.0/24 is directly connected, GigabitEthernet0/5 //VRF-C
show ip route (おまけ)グローバルルーティングテーブル
R1#show ip route Gateway of last resort is not set C 1.1.1.1 is directly connected, Loopback0
show ip bgp vpnv4 all
各VRFのvpnv4テーブルに各VRFのルートが載っている
R1#show ip bgp vpnv4 all Network Next Hop Metric LocPrf Weight Path Route Distinguisher: 1:1 (default for vrf VRF-A) *> 192.168.1.0 0.0.0.0 0 32768 ? *> 192.168.2.0 0.0.0.0 0 32768 ? *> 192.168.3.0 0.0.0.0 0 32768 ? *> 192.168.4.0 0.0.0.0 0 32768 ? *> 192.168.5.0 0.0.0.0 0 32768 ? *> 192.168.6.0 0.0.0.0 0 32768 ? Route Distinguisher: 2:2 (default for vrf VRF-B) *> 192.168.1.0 0.0.0.0 0 32768 ? *> 192.168.2.0 0.0.0.0 0 32768 ? *> 192.168.3.0 0.0.0.0 0 32768 ? *> 192.168.4.0 0.0.0.0 0 32768 ? *> 192.168.5.0 0.0.0.0 0 32768 ? *> 192.168.6.0 0.0.0.0 0 32768 ? Route Distinguisher: 3:3 (default for vrf VRF-C) *> 192.168.1.0 0.0.0.0 0 32768 ? *> 192.168.2.0 0.0.0.0 0 32768 ? *> 192.168.3.0 0.0.0.0 0 32768 ? *> 192.168.4.0 0.0.0.0 0 32768 ? *> 192.168.5.0 0.0.0.0 0 32768 ? *> 192.168.6.0 0.0.0.0 0 32768 ?