VRF間的重分佈

這篇博文將描述如何在一臺路由器上使用VRF,雙向重分佈EIGRP路由。EIGRP在多個域中(這顯然不是一個好的設計)。

這是一種在單臺路由器重分佈不同VRF間路由的方法,但路由協議不僅僅限於EIGRP,經筆者測試,EIGRP和EIGRP,OSPF和OSPF,EIGRP和OSPF之間的重分佈都是沒有問題的。本文僅爲EIGRP爲例進行演示。


拓撲如下:

wKiom1W9oCGgNuAZAAIsGPHwFpA289.jpg基本配置如下:

R1(config)#int s1/1
R1(config-if)#ip add 12.1.1.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int lo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R2(config)#int s1/0
R2(config-if)#ip add 12.1.1.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int s1/1
R2(config-if)#ip add 23.1.1.2 255.255.255.0
R2(config-if)#no shut
R3(config)#int s1/0
R3(config-if)#ip add 23.1.1.3 255.255.255.0
R3(config-if)#no shut
R3(config-if)#int lo 0
R3(config-if)#ip add 3.3.3.3 255.255.255.0


在R1和R3上啓用分別啓用EIGRP:

R1:

router eigrp 100
 network 1.1.1.0 0.0.0.255
 network 12.1.1.0 0.0.0.255
 no auto-summary

R3:

router eigrp 200
 network 3.3.3.0 0.0.0.255
 network 23.1.1.0 0.0.0.255
 no auto-summary

在R2上啓用VRF,將S1/0接口劃入"EIGRP100"的VRF,將S1/1接口劃入"EIGRP200"的VRF,並啓用EIGRP,分別與R1和R3建立鄰居關係。

ip vrf EIGRP100
 rd 100:100
ip vrf EIGRP200
 rd 200:200
interface Serial1/0
 ip vrf forwarding EIGRP100
 ip address 12.1.1.2 255.255.255.0
interface Serial1/1
 ip vrf forwarding EIGRP200
 ip address 23.1.1.2 255.255.255.0
router eigrp 6000
 no auto-summary
 !
 address-family ipv4 vrf EIGRP200
 network 23.1.1.0 0.0.0.255        //宣告路由
 no auto-summary
 autonomous-system 200            //在VRF中一定要指定AS號,不然無法建立鄰居
 exit-address-family
 !
 address-family ipv4 vrf EIGRP100
 network 12.1.1.0 0.0.0.255
 no auto-summary
 autonomous-system 100
 exit-address-family


查看鄰居關係

wKioL1W9o1-CjQC8AAIBwb-iTG8477.jpg

配置重分佈:

在VRF中配置route-target的導入和導出,如果是多個VRF,一定要注意該項。

ip vrf EIGRP100

 rd 100:100

 route-target export 100:100

 route-target import 200:200

!         

ip vrf EIGRP200

 rd 200:200

 route-target export 200:200

 route-target import 100:100

配置BGP,通過BGP來傳遞路由信息。

router bgp 5000

 no synchronization

 bgp router-id 2.2.2.2     //這裏配置僅僅是確保BGP正常運行,路由器不需要有這個地址

 bgp log-neighbor-changes

 no auto-summary

 !

 address-family ipv4 vrf EIGRP200

 redistribute eigrp 200

 no auto-summary

 no synchronization

 exit-address-family

 !

 address-family ipv4 vrf EIGRP100

 redistribute eigrp 100

 no auto-summary

 no synchronization

 exit-address-family

配置完後,查看BGP表,查看路由是否已經被重分佈進BGP中。


2#show ip bgp ***v4 all 

BGP table version is 13, local router ID is 2.2.2.2

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              r RIB-failure, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete


   Network          Next Hop            Metric LocPrf Weight Path

Route Distinguisher: 100:100 (default for vrf EIGRP100)

*> 1.1.1.0/24       12.1.1.1           2297856         32768 ?

*> 3.3.3.0/24       23.1.1.3           2297856         32768 ?

*> 12.1.1.0/24      0.0.0.0                  0         32768 ?

*> 23.1.1.0/24      0.0.0.0                  0         32768 ?

Route Distinguisher: 200:200 (default for vrf EIGRP200)

*> 1.1.1.0/24       12.1.1.1           2297856         32768 ?

*> 3.3.3.0/24       23.1.1.3           2297856         32768 ?

*> 12.1.1.0/24      0.0.0.0                  0         32768 ?

*> 23.1.1.0/24      0.0.0.0                  0         32768 ?

配置EIGRP,將BGP的路由重分佈進EIGRP。

router eigrp 6000

 !

 address-family ipv4 vrf EIGRP200

 redistribute bgp 5000 metric 1000 100 255 1 1500

 !

 address-family ipv4 vrf EIGRP100

 redistribute bgp 5000 metric 1000 100 255 1 1500


查看R1和R3的路由,分別是否學習到對方路由:

R1的路由表:

R1#show ip route 

   1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

     3.0.0.0/24 is subnetted, 1 subnets

D EX    3.3.3.0 [170/3097600] via 12.1.1.2, 00:23:54, Serial1/1

     23.0.0.0/24 is subnetted, 1 subnets

D EX    23.1.1.0 [170/3097600] via 12.1.1.2, 00:23:54, Serial1/1

     12.0.0.0/24 is subnetted, 1 subnets

C       12.1.1.0 is directly connected, Serial1/1

R3的路由表:

R3#show ip route 

     1.0.0.0/24 is subnetted, 1 subnets

D EX    1.1.1.0 [170/3097600] via 23.1.1.2, 00:24:06, Serial1/0

     3.0.0.0/24 is subnetted, 1 subnets

C       3.3.3.0 is directly connected, Loopback0

     23.0.0.0/24 is subnetted, 1 subnets

C       23.1.1.0 is directly connected, Serial1/0

     12.0.0.0/24 is subnetted, 1 subnets

D EX    12.1.1.0 [170/3097600] via 23.1.1.2, 00:24:06, Serial1/0

ping測試:

R1#ping 3.3.3.3 source 1.1.1.1


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1 

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/60/80 ms


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章