Routing Context を指定し、都度の VRF 指定を省略する
ネットワーク機器では一台で複数のルーティングテーブルを保有出来る機器があります。こういった機能のことは各社毎に呼び名が異なります。一例を挙げると以下の通りです。
メーカー |
呼び名 |
Cisco |
VRF (Virtual Routing Forwarding) |
Juniper |
Routing Instance |
F5 Networks |
Route Domain |
Cisco 製品を例にとると、通常は実行するコマンド毎に参照するルーティングテーブルが所属する VRF 名を指定します。IOSv で「VRF-1 のルーティングテーブルを参照して Ping を実行する」場合は以下のようになります。
| IOSv# ping vrf VRF-1 10.0.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.1, timeout is 2 seconds:
!!!!!
|
これを連続して実行すると以下のようになります。数が多くなってくると都度、VRF 名を指定するのが面倒になってきます (操作ミスも増えます)。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 | IOSv# ping vrf VRF-1 10.0.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/3 ms
IOSv# ping vrf VRF-1 10.0.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/7 ms
IOSv# ping vrf VRF-1 10.0.1.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.0.1.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/5 ms
|
このような場合、以下のコマンドで「VRF 名の指定を省略した場合に参照されるデフォルト VRF」を指定することが出来ます。
|
IOSv / IOS-XE / NX-OSv |
IOS-XRv |
RoutingContext を指定 VRF に変更する |
routing-context vrf VRF-NAME |
set default-vrf VRF-NAME |
RoutingContext を default/global に戻す |
routing-context vrf default |
set default-vrf none |
尚、このコマンドは 1 セッションの間のみ、有効です。例えば、Routing Context を変更後にログアウトし、再ログインすると default/global VRF に戻ります。以下の環境で試してみます。
検証環境
構成は以下の通りです。ルータ毎に「default/global 側」と「VRF-1 側」に接続しています。「default/global」は明示的に VRF を指定しない場合に参照されます。
コンフィグ
IOSv
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | hostname IOSv
!
ip vrf VRF-1
!
interface GigabitEthernet0/1
ip address 10.0.0.1 255.255.255.0
no shutdown
!
interface GigabitEthernet0/2
ip vrf forwarding VRF-1
ip address 10.0.1.1 255.255.255.0
no shutdown
!
end
|
CSR1000v
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | hostname CSR1000v
!
ip vrf VRF-1
!
interface GigabitEthernet2
ip address 10.0.0.2 255.255.255.0
no shutdown
!
interface GigabitEthernet3
ip vrf forwarding VRF-1
ip address 10.0.1.2 255.255.255.0
no shutdown
!
end
|
XRv
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | hostname XRv
!
vrf VRF-1
!
interface GigabitEthernet0/0/0/0
ipv4 address 10.0.0.3 255.255.255.0
no shutdown
!
interface GigabitEthernet0/0/0/1
vrf VRF-1
ipv4 address 10.0.1.3 255.255.255.0
no shutdown
!
end
|
NX-OSv
1
2
3
4
5
6
7
8
9
10
11
12 | hostname NX-OSv
!
interface Ethernet2/1
ip address 10.0.0.4/24
no shutdown
!
interface Ethernet2/2
vrf member VRF-1
ip address 10.0.1.4/24
no shutdown
!
end
|
状態確認
IOSv
default/global
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | IOSv# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/24 is directly connected, GigabitEthernet0/1
L 10.0.0.1/32 is directly connected, GigabitEthernet0/1
|
VRF-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | IOSv# routing-context vrf VRF-1
IOSv%VRF-1# show ip route
Routing Table: VRF-1
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.1.0/24 is directly connected, GigabitEthernet0/2
L 10.0.1.1/32 is directly connected, GigabitEthernet0/2
|
CSR1000v
default/global
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | CSR1000v# show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.0.0/24 is directly connected, GigabitEthernet2
L 10.0.0.2/32 is directly connected, GigabitEthernet2
|
VRF-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | CSR1000v# routing-context vrf VRF-1
CSR1000v%VRF-1# show ip route
Routing Table: VRF-1
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.0.1.0/24 is directly connected, GigabitEthernet3
L 10.0.1.2/32 is directly connected, GigabitEthernet3
|
XRv
default/global
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | RP/0/0/CPU0:XRv# show default-afi-safi-vrf
Fri Apr 1 17:24:08.009 UTC
%% Default AFI/SAFI/VRF for this session is:
Address Family Identifier: ipv4
Sub-Address Family Identifier: unicast
Virtual Routing/Forwarding:
RP/0/0/CPU0:XRv# show route
Fri Apr 1 17:24:11.979 UTC
Codes: C - connected, S - static, R - RIP, B - BGP, (>) - Diversion path
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - ISIS, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, su - IS-IS summary null, * - candidate default
U - per-user static route, o - ODR, L - local, G - DAGR, l - LISP
A - access/subscriber, a - Application route
M - mobile route, r - RPL, (!) - FRR Backup path
Gateway of last resort is not set
C 10.0.0.0/24 is directly connected, 00:37:09, GigabitEthernet0/0/0/0
L 10.0.0.3/32 is directly connected, 00:37:09, GigabitEthernet0/0/0/0
|
VRF-1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | RP/0/0/CPU0:XRv# set default-vrf VRF-1
Fri Apr 1 17:24:21.258 UTC
RP/0/0/CPU0:XRv# show default-afi-safi-vrf
Fri Apr 1 17:25:01.195 UTC
%% Default AFI/SAFI/VRF for this session is:
Address Family Identifier: ipv4
Sub-Address Family Identifier: unicast
Virtual Routing/Forwarding: VRF-1
%% Default Virtual Routing/Forwarding is set to VRF-1
RP/0/0/CPU0:XRv# show route
Fri Apr 1 17:24:23.248 UTC
Codes: C - connected, S - static, R - RIP, B - BGP, (>) - Diversion path
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - ISIS, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, su - IS-IS summary null, * - candidate default
U - per-user static route, o - ODR, L - local, G - DAGR, l - LISP
A - access/subscriber, a - Application route
M - mobile route, r - RPL, (!) - FRR Backup path
Gateway of last resort is not set
C 10.0.1.0/24 is directly connected, 00:36:27, GigabitEthernet0/0/0/1
L 10.0.1.3/32 is directly connected, 00:36:27, GigabitEthernet0/0/0/1
|
NX-OSv
default/global
| NX-OSv%VRF-1# show ip route
IP Route Table for VRF "VRF-1"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>
10.0.1.0/24, ubest/mbest: 1/0, attached
*via 10.0.1.4, Eth2/2, [0/0], 00:35:16, direct
10.0.1.4/32, ubest/mbest: 1/0, attached
*via 10.0.1.4, Eth2/2, [0/0], 00:35:16, local
|
VRF-1
1
2
3
4
5
6
7
8
9
10
11
12 | NX-OSv%VRF-1# routing-context vrf VRF-1
NX-OSv%VRF-1# show ip route
IP Route Table for VRF "VRF-1"
'*' denotes best ucast next-hop
'**' denotes best mcast next-hop
'[x/y]' denotes [preference/metric]
'%<string>' in via output denotes VRF <string>
10.0.1.0/24, ubest/mbest: 1/0, attached
*via 10.0.1.4, Eth2/2, [0/0], 00:35:28, direct
10.0.1.4/32, ubest/mbest: 1/0, attached
*via 10.0.1.4, Eth2/2, [0/0], 00:35:28, local
|
参考 URL