圖中紅色的部分先不管,先配置一下域內的BGP
R2:
router bgp 10
no bgp default ipv4
nei 3.3.3.3 remote 10
nei 3.3.3.3 up lo 0
add ***v4
nei 3.3.3.3 ac
add ipv4 vrf abc
redistribute ospf 2 vrf abc
router ospf 2 vrf abc
net 12.12.12.2 0.0.0.0 a 0
redistribute bgp 10 su
Exit
R3:
router bgp 10
no bgp default ipv4
nei 2.2.2.2 remote 10
nei 2.2.2.2 up lo 0
nei 4.4.4.4 remote 10
nei 4.4.4.4 up lo 0
add ***v4
nei 2.2.2.2 ac
nei 2.2.2.2 route-reflector-c
nei 4.4.4.4 ac
nei 4.4.4.4 route-reflector-c
R4:
router bgp 10
no bgp defa ip
nei 3.3.3.3 remote 10
nei 3.3.3.3 up lo 0
add ***v4
nei 3.3.3.3 ac
同理R5,R6,R7,先把R2,R4之間的鏈路,R5,R7之間的鏈路shut掉。
背靠背的VRF是什麼原理呢?
它在兩個ASBR,R4,R5上創建一個或多個VRF,將BGP的路由導入VRF(redistribute),並且路由通過R4,R5之間的IGP傳遞,然後在對方的VRF表中導出入BGP。
也就是說R2,R3,R4之間傳遞的是***V4的路由,而R4,R5之間傳遞的是IPV4的路由。
在這裏提出一個問題,爲什麼R3上面有***V4的路由,而R4上沒有?難道沒反射?
爲了解決上面的問題,我在R4上創建VRF表:
R4(config)#ip vrf abc
R4(config-vrf)#rd 10:4
R4(config-vrf)#route-target export 10:4
R4(config-vrf)#route-target import 10:2
R4(config-vrf)#route-target import 20:5
然後將路由重分發進OSPF
R4(config)#int fa0/1
R4(config-if)#ip vrf forwarding abc
R4(config-if)#ip address 45.45.45.4 255.255.255.0
R4(config-if)#no shu
R4(config)#router ospf 2 vrf abc
R4(config-router)#net 45.45.45.4 0.0.0.0 a 0
R4(config-router)#redistribute bgp 10 su
在R5上創建VRF表並將BGP路由重分發進OSPF
R5(config)#ip vrf abc
R5(config-vrf)#rd 10:4
R5(config-vrf)#route-target export 20:5
R5(config-vrf)#route-target import 10:4
R5(config-vrf)#route-target import 20:7
然後將路由重分發進OSPF
R5(config)#int fa0/0
R5(config-if)#ip vrf forwarding abc
R5(config-if)#ip address 45.45.45.5 255.255.255.0
R5(config-if)#no shu
R5(config)#router ospf 2 vrf abc
R5(config-router)#net 45.45.45.50.0.0.0 a 0
R5(config-router)#redistribute bgp 10 su
現在查看一下R5的路由表:
R5#show ip route vrf abc
8.0.0.0/32 is subnetted, 1 subnets
B 8.8.8.8 [200/11] via 7.7.7.7, 00:00:12
78.0.0.0/24 is subnetted, 1 subnets
B 78.78.78.0 [200/0] via 7.7.7.7, 00:00:12
45.0.0.0/24 is subnetted, 1 subnets
C 45.45.45.0 is directly connected, FastEthernet0/0
?爲什麼沒有從R4收到路由?
因爲一個特性down bit位,所以要消除down bit的影響.
R5(config-router)#capability vrf-lite (注意我只在R5上配置)
此時再查看一下R5的VRF表
R5#show ip route vrf abc
1.0.0.0/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/21] via 45.45.45.4, 00:00:06, FastEthernet0/0
8.0.0.0/32 is subnetted, 1 subnets
B 8.8.8.8 [200/11] via 7.7.7.7, 00:01:27
78.0.0.0/24 is subnetted, 1 subnets
B 78.78.78.0 [200/0] via 7.7.7.7, 00:01:27
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.12.12.0 [110/11] via 45.45.45.4, 00:00:06, FastEthernet0/0
45.0.0.0/24 is subnetted, 1 subnets
C 45.45.45.0 is directly connected, FastEthernet0/0
這裏再查看一下R4的VRF表:
R4#show ip route vrf abc
1.0.0.0/32 is subnetted, 1 subnets
B 1.1.1.1 [200/11] via 2.2.2.2, 00:11:57
8.0.0.0/32 is subnetted, 1 subnets
O E2 8.8.8.8 [110/11] via 45.45.45.5, 00:00:00, FastEthernet0/1
78.0.0.0/24 is subnetted, 1 subnets
O E2 78.78.78.0 [110/1] via 45.45.45.5, 00:00:00, FastEthernet0/1
12.0.0.0/24 is subnetted, 1 subnets
B 12.12.12.0 [200/0] via 2.2.2.2, 00:11:57
45.0.0.0/24 is subnetted, 1 subnets
C 45.45.45.0 is directly connected, FastEthernet0/1
如果兩邊都配置命令capability vrf-lite ,那麼兩邊都是E2,這是什麼原因呢?
如果只在R5上配置,那麼
R4#show ip route vrf abc 8.8.8.8
Routing entry for 8.8.8.8/32
Known via "ospf 2", distance 110, metric 11
Tag Complete, Path Length == 1, AS 20, , type extern 2, forward metric 10
Last update from 45.45.45.5 on FastEthernet0/1, 00:00:04 ago
Routing Descriptor Blocks:
* 45.45.45.5, from 45.45.45.5, 00:00:04 ago, via FastEthernet0/1
Route metric is 11, traffic share count is 1
Route tag 3489660948
R5#show ip route vrf abc 1.1.1.1
Routing entry for 1.1.1.1/32
Known via "ospf 2", distance 110, metric 21, type inter area
Last update from 45.45.45.4 on FastEthernet0/0, 00:00:04 ago
Routing Descriptor Blocks:
* 45.45.45.4, from 45.45.45.4, 00:00:04 ago, via FastEthernet0/0
Route metric is 21, traffic share count is 1
R5配置了關閉down bit檢查,那麼它發出的路由類型是E2,使用外部路由標記來檢查是否發生了重複宣告進同一個AS的問題。而R4沒有配置,則照常發送。
現在將OSPF路由重分發進BGP:
R4(config)#router bgp 10
R4(config-router)#address-family ipv4 vrf abc
R4(config-router-af)#redistribute ospf 2 vrf abcma in ex
(OSPF默認不將E的路由重分發進BGP)
R4(config-router-af)#exit
R5同理,但是要在R2和R7上添加導入。
最後以traceroute結束option1:
R1#traceroute 8.8.8.8
1 12.12.12.2 64 msec 60 msec 32 msec
2 23.23.23.3 [MPLS: Labels 301/404 Exp 0] 128 msec 120 msec 156 msec
3 45.45.45.4 [MPLS: Label 404 Exp 0] 124 msec 100 msec 96 msec
4 45.45.45.5 172 msec 124 msec 180 msec 中間是IPV4
5 56.56.56.6 [MPLS: Labels 601/703 Exp 0] 232 msec 252 msec 284 msec
6 78.78.78.7 [MPLS: Label 703 Exp 0] 292 msec 220 msec 192 msec
7 78.78.78.8 272 msec * 292 msec