您的位置:首页 > 职场人生

基于原地址的策略路由

2010-01-07 19:01 393 查看
一、拓扑图:



二、配置及说明:
1、图中我用R0模拟帧中继,我只想让它们都参与到帧中继网中,R3我没有用子接口来做,因为我只要能学到全网内的路由。我并不要他们各自ping 通自己接口地址。我用路由器模拟帧中继,有利于我们更好的理解其原理。(为节省篇幅,帧中继的配置我就不写了。)其它的在帧中继网中的路由器都指map。好了。下面来看一下R0的frame-relay route:


FRSW#sh frame-relay route
Input Intf Input Dlci Output Intf Output Dlci Status
Serial1/0 343 Serial1/1 434 active
Serial1/0 363 Serial1/2 636 active
Serial1/1 434 Serial1/0 343 active
Serial1/2 636 Serial1/0 363 active
2、我用R1和R2模拟成主机并指默认路由到下一跳192.168.1.1网关。
3、在R3,R4,R5,R6各路由器中都运行动态路由协议RIP V2 ,保证全网的互联性。
4、配置完成之后,再来看一下R3的路由表:

R3#sh ip route
Codes: 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

Gateway of last resort is not set

172.16.0.0/24 is subnetted, 2 subnets
R 172.16.1.0 [120/1] via 10.1.1.2, 00:00:07, Serial1/2
R 172.16.2.0 [120/1] via 10.1.1.3, 00:00:12, Serial1/2
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, Serial1/2
130.130.0.0/24 is subnetted, 1 subnets
R 130.130.1.0 [120/2] via 10.1.1.3, 00:00:12, Serial1/2
[120/2] via 10.1.1.2, 00:00:07, Serial1/2 (发现有两条负载链路)
C 192.168.1.0/24 is directly connected, FastEthernet0/0
R3#
4、把R3上的cef (Cisco Express Forwarding,Cisco快速交换)和route-cache 关掉,我们来traceroute 130.130.1.1看一下它的路径走向:

R3(config)#int s1/2
R3(config-if)#no ip cef
R3(config)#int s1/2
R3(config-if)#no ip route-cache

R3#traceroute 130.130.1.1

Type escape sequence to abort.
Tracing the route to 130.130.1.1

1 10.1.1.2 64 msec
10.1.1.3 80 msec
10.1.1.2 12 msec
2 172.16.2.1 16 msec
172.16.1.2 28 msec * (发现通过R4和R6两条链路走)
5、我再到R3上的F0/0接口上去关闭一下cef 和route-cache ,我再到R1和R2主机上去traceroute 看一下负载均衡路径的明细走向:

R3(config)#int f0/0
R3(config-if)#no ip cef
R3(config)#int f0/0
R3(config-if)#no ip route-cache

R1#traceroute 130.130.1.1

Type escape sequence to abort.
Tracing the route to 130.130.1.1

1 192.168.1.1 60 msec 44 msec 12 msec
2 10.1.1.2 44 msec
10.1.1.3 68 msec
10.1.1.2 24 msec
3 172.16.2.1 48 msec
172.16.1.2 48 msec * (都是通过两条链路来走的)

R2#traceroute 130.130.1.1

Type escape sequence to abort.
Tracing the route to 130.130.1.1

1 192.168.1.1 56 msec 24 msec 12 msec
2 10.1.1.2 80 msec
10.1.1.3 20 msec
10.1.1.2 72 msec
3 172.16.2.1 80 msec
172.16.1.2 4 msec * (都是通过两条链路来走的)
R2#
三、那么我要在R3上做策略路由实现:
1、R1主机àR3àR4àR5à130.130.1.1/24
2、R2主机àR3àR6àR5à130.130.1.1/24
四、在R3上做策略路由的配置:

R3(config)#access-list 10 per host 192.168.1.10
R3(config)#access-list 20 per host 192.168.1.20(先建两个ACL)
R3(config)#route-map pbr permit 10 (建立route-map pbr 序号为10)
R3(config-route-map)#match ip add 10 (匹配acl 10)
R3(config-route-map)#set ip next-hop 10.1.1.2(设置下一点为R4)
R3(config)#route-map pbr permit 20(再建一个route-map pbr 序号为20)
R3(config-route-map)#match ip add 20(匹配acl 20)
R3(config-route-map)#set ip next-hop 10.1.1.3(设置下一跳为R6)
R3(config)#int f0/0
R3(config-if)#ip policy route-map pbr (把策略路由往接口上挂,这样它就不从路由表走,而是从设定的下一跳走)
五、我们再来跟踪一下R1和R2的路由走向:

R1#traceroute 130.130.1.1

Type escape sequence to abort.
Tracing the route to 130.130.1.1

1 192.168.1.1 40 msec 68 msec 28 msec
2 10.1.1.2 48 msec 28 msec 24 msec (从R4走了)
3 172.16.1.2 52 msec * 104 msec

R2#traceroute 130.130.1.1

Type escape sequence to abort.
Tracing the route to 130.130.1.1

1 192.168.1.1 68 msec 20 msec 16 msec
2 10.1.1.3 64 msec 40 msec 48 msec (从R6走了)
3 172.16.2.1 36 msec * 100 msec
六、通过上面的操作我们可以对某些路由不从自己的路由表走,而是从设定的下一跳走。这就是策略路由。需要记住跟踪路径的时候要关闭cef和ip route-cache。以便能够跟踪到详细的路径。配置FR的时候map注意一点就行了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息