策略路由小案例_第1张图片

简介:来自R1的数据包经过R2R4在经过R3出去,数据包回来的时候R3经过R2R1不经过R4


R1:

conf ter

int loo 0

ip add 1.1.1.1255.255.255.0

no shu

ex

int f1/0

ip add 192.168.1.1255.255.255.0

no shu

ex

router rip

ver 2

no au

net 192.168.1.0

net 1.0.0.0

R2:

conf ter

int f1/0

ip add 192.168.1.2255.255.255.0

no shu

ex

int f1/1

ip add 192.168.2.1255.255.255.0

no shu

ex

int f2/0

ip add 192.168.3.2255.255.255.0

no shu

ex

int f2/1

ip add 192.168.4.1255.255.255.0

no shu

ex

router rip

ver 2

no au

net 192.168.1.0

net 192.168.2.0

net 192.168.3.0

net 192.168.4.0

R3:

conf ter

int loo 0

ip add 3.3.3.3255.255.255.0

no shu

ex

int f1/0

ip add 192.168.4.2255.255.255.0

no shu

ex

router rip

ver 2

no au

net 192.168.4.0

net 3.0.0.0

exit

R4:

conf ter

int f1/0

ip add 192.168.2.2255.255.255.0

no shu

ex

int f1/1

ip add 192.168.3.1255.255.255.0

no shu

exit

router rip

ver 2

no au

net 192.168.2.0

net 192.168.3.0

exit

R2:

acc 100 permit iphost 1.1.1.1 host 3.3.3.3

route-map test01permit 10

match ip address 100

set ip next-hop192.168.2.2

exit

int f1/0

ip policy route-maptest01

exit

R4:

acc 120 permit iphost 1.1.1.1 host 3.3.3.3

route-map test01permit 10

match ip address 120

set ip next-hop192.168.3.2

exit

int f1/0

ip policy route-maptest01

exit

测试:

R1#traceroute3.3.3.3 source 1.1.1.1


Type escape sequenceto abort.

Tracing the route to3.3.3.3


 1 192.168.1.2 612 msec 548 msec 376 msec

 2 192.168.2.2 540 msec 576 msec 692 msec

 3 192.168.3.2 448 msec 1104 msec 420 msec

 4 192.168.4.2 656 msec 872 msec 1280 msec

R3#traceroute1.1.1.1 source 3.3.3.3


Type escape sequenceto abort.

Tracing the route to1.1.1.1


 1 192.168.4.1 1064 msec 432 msec 392 msec

 2 192.168.1.1 528 msec *  792 msec

案例延伸:来自R3的数据包经过R4R2在经过R1回去,数据包回来的时候R1经过R2R4到达R3

R2:

acc 110 permit iphost 3.3.3.3 host 1.1.1.1

route-map test03permit 10

match ip address 110

set ip next-hop192.168.3.1

exit

int f2/1

ip policy route-maptest03

exit

R4:

acc 140 permit iphost 3.3.3.3 host 1.1.1.1

route-map test04permit 10

match ip address 140

set ip next-hop192.168.2.1

exit

int f1/1

ip policy route-maptest04

exit        

测试:

R3#traceroute1.1.1.1 source 3.3.3.3


Type escape sequenceto abort.

Tracing the route to1.1.1.1


 1 192.168.4.1 348 msec 144 msec 284 msec

 2 192.168.3.1 668 msec 696 msec 940 msec

 3 192.168.2.1 404 msec 792 msec 472 msec

 4 192.168.1.1 728 msec 576 msec 776msec                                                        

R1#traceroute3.3.3.3 source 1.1.1.1


Type escape sequenceto abort.

Tracing the route to3.3.3.3


 1 192.168.1.2 220 msec 292 msec 1480 msec

 2 192.168.2.2 448 msec 464 msec 440 msec

 3 192.168.3.2 356 msec 588 msec 440 msec

 4 192.168.4.2 760 msec 652 msec 484msec