分类: 系统运维
2013-07-01 10:15:10
1试验目的:
懂得策略路由的使用,知道策略路由的作用及应用方式
2.试验拓扑3.1基于源的策略路由试验背景
在该实验中,我们要控制B1的1.1.X.0/24网络选择通过B4 的Serial 0接口访问.0/24网络,并且按原路返回。
基本配置
B1的配置命令:
B1(config)#interface serial 0
B1(config-if)#ip address .1 255.255.255.0
B1(config-if)#clock rate 64000
B1(config-if)#ip address .1 255.255.255.0 secondary
B1(config-if)#ip address .1 255.255.255.0 secondary
B1(config-if)#ip address .1 255.255.255.0 secondary
B1(config-if)#ip address .1 255.255.255.0 secondary
B1(config-if)#ip address .1 255.255.255.0
B1(config)#router ospf 10
B1(config-router)#router-id .1
B1(config-router)#network .0 255.255.255.255 area 0
B4的配置命令:
B4(config-if)#interface serial 0
B4(config-if)#ip address .2 255.255.255.0
B4(config)#interface loopback 0
B4(config-if)#ip address .2 255.255.255.0
B4(config-if)#ip ospf network point-to-point
B4(config-if)#interface serial 1
B4(config-if)#ip address .2 255.255.255.0
B4(config)#router ospf 10
B4(config-router)#router-id .2
B4(config-router)#network .0 255.255.255.255 area 0
B9的配置命令:
B9(config-if)#interface serial 0
B9(config-if)#ip address .3 255.255.255.0
B9(config)#interface loopback 0
B9(config-if)#ip address .3 255.255.255.0
B9(config-if)#ip ospf network point-to-point
B9(config-if)#interface eth 0
B9(config-if)#ip address 213.1.1.3 255.255.255.0
B9(config)#router ospf 10
B9(config-router)#router-id .3
B9(config-router)#network .0 255.255.255.255 area 0
监视与测试配置
在当前的路由状态喜爱,B1的网络访问B9的路径如下:
B1#traceroute .3
Type escape sequence to abort.
Tracing the route to .3
1 .2 16 msec 16 msec 20 msec
2 .3 36 msec 28 msec *
即B1首先到达B4的serial 1 在通过以太网接口到达B9.我们可以用ping的record选项来跟踪返回的路径。
B1#ping
Protocol [ip]: .3
% Unknown protocol - ".3", type "ping ?" for help
B1#ping
Protocol [ip]:
Target IP address: .3
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: .1
Type of service [0]:
Loose, Strict, Record, Timestamp, Verbose[none]: record
Number of hops [ 9 ]:
Loose, Strict, Record, Timestamp, Verbose[RV]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to .3, timeout is 2 seconds:
Packet has IP options: Total option bytes= 39, padded length=40
Record route: <*>
(.0)
(.0)
(.0)
(.0)
(.0)
(.0)
(.0)
(.0)
(.0)
Reply to request 0 (64 ms). Received packet has options
Total option bytes= 40, padded length=40
Record route:
(.1)
(213.1.1.2)
(.3)
(213.1.1.3)
.2)
(.1) <*>
(.0)
(.0)
(.0)
End of list
从以上可见数据报文通过以太网接口原路返回。这符合ospf的选路原则(以太网接口开销较低)。接下来我们要用策略路由控制,B1的4个网络1.1..X.0/24通过B4的s0接口访问B9,在B4上面配置,在进站接口s1应用策略路由。
定义访问列表,内容为B1源地址:
B4(config)#access-list 10 permit .0 0.0.3.255
用route-map引用访问列表,设置下一跳:
B4(config)#route-map to-B9
B4(config-route-map)#match ip address 10
B4(config-route-map)#set ip next-ho.3
在接口下应用策略:
B4(config)#interface serial 1
B4(config-if)#ip policy route-map to-B9
我们在B1上面做验证,并在B4上面打开debug ip policy
B4#debug ip policy
Policy routing debugging is on
B1#traceroute
Protocol [ip]:
Target IP address: .3
Source address: .1
Numeric display [n]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to .3
1 .2 16 msec 16 msec 20 msec
2 .3 48 msec 44 msec *