这篇博文将描述如何在一台路由器上使用VRF,双向重分布EIGRP路由。EIGRP在多个域中(这显然不是一个好的设计)。
这是一种在单台路由器重分布不同VRF间路由的方法,但路由协议不仅仅限于EIGRP,经笔者测试,EIGRP和EIGRP,OSPF和OSPF,EIGRP和OSPF之间的重分布都是没有问题的。本文仅为EIGRP为例进行演示。
拓扑如下:
R1(config)#int s1/1R1(config-if)#ip add 12.1.1.1 255.255.255.0R1(config-if)#no shutR1(config-if)#int lo 0R1(config-if)#ip add 1.1.1.1 255.255.255.0
R2(config)#int s1/0R2(config-if)#ip add 12.1.1.2 255.255.255.0R2(config-if)#no shutR2(config-if)#int s1/1R2(config-if)#ip add 23.1.1.2 255.255.255.0R2(config-if)#no shut
R3(config)#int s1/0R3(config-if)#ip add 23.1.1.3 255.255.255.0R3(config-if)#no shutR3(config-if)#int lo 0R3(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:100ip vrf EIGRP200 rd 200:200
interface Serial1/0 ip vrf forwarding EIGRP100 ip address 12.1.1.2 255.255.255.0interface 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
查看邻居关系
配置重分布:
在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
有兴趣朋友可以了解更多java教程