一、实验内容
实验任务一 基于源IP地址的策略路由(PBR)
实验拓扑
实验步骤及配置命令
1.R1、R2和R3的IP地址和路由协议配置
路由协议要求配置RIPv2,关闭自动汇总,路由器IP地址参考配置如下:
R1(config)#interface f0/0
R1(config-if)#ip address 192.1.1.3 255.255.255.0
R1(config)#interface serial 1/0
R1(config-if)#ip address 150.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#interface serial 1/1
R1(config-if)#ip address 151.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R2(config)#interface s0/1
R2(config-if)#ip address 150.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#clock rate 64000
R2(config-if)#exit
R2(config)#interface s0/2
R2(config-if)#ip address 151.1.1.2 255.255.255.0
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#interface loopback 0
R2(config-if)#ip address 152.1.1.1 255.255.255.0
R2(config-if)#exit
R3(config)#interface f1/0
R3(config-if)#ip address 192.1.1.1 255.255.255.0
R3(config-if)#ip address 192.1.1.2 255.255.255.0 secondary
- 配置基于源IP的PBR
R1(config)#access-list 1 permit 192.1.1.1 0.0.0.0
R1(config)#access-list 2 permit 192.1.1.2 0.0.0.0
定义两台服务器的IP
R1(config)#route-map lab1 permit 10
R1(config-route-map)#match ip address 1
R1(config-route-map)#set ip next-hop 150.1.1.2
R1(config-route-map)#exit
Route Map表lab1的第一条语句,服务器192.1.1.1的数据经过下一跳地址是150.1.1.2即s0/1发送,条件语句嵌套ACL1
R1(config)#route-map lab1 permit 20
R1(config-route-map)#match ip address 2
R1(config-route-map)#set ip next-hop 151.1.1.2
R1(config-route-map)#exit
Route Map表lab1的第二条语句,服务器192.1.1.2的数据经过下一跳地址是151.1.1.2即s0/2发送,条件语句嵌套ACL2
R1(config)#interface f 0/0
R1(config-if)#ip policy route-map lab1
在f 0/0接口上应用名字是lab1的Route Map表
R1(config)#ip local policy route-map lab1
要求路由器本身产生的数据包也接受策略路由的管理
3.测试
在R1上使用debug ip policy命令来监视策略路由
R1#debug ip policy
Policy routing debugging is on
R3上使用扩展的ping命令
R3#ping
Protocol [ip]:
Target IP address: 152.1.1.1
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 192.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 152.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 192.1.1.1
!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/51/128 ms
这样路由器R1会输出debug ip policy监视所得的结果。
该命令显示定义的所有路由策略及路由策略匹配的情况。
R1#show route-map 查看定义的所有路由策略及路由策略匹配的情况
R1#show ip policy 查看策略路由及作用的接口
另一种测试源IP地址的策略路由
扩展的traceroute 命令
R3#traceroute ip
Target IP address: 152.1.1.1
Source address: 192.1.1.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 152.1.1.1
R3#traceroute ip
Target IP address: 152.1.1.1
Source address: 192.1.1.2
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 152.1.1.1
实验任务二 基于报文大小的策略路由(PBR)
实验拓扑
本实验设计如下:在路由器R1的f0/0接口应用IP策略路由CCNP,使得对大小为64-100字节的数据包设置出接口为s1/0;大小为101-1000 字节的数据包设置出接口为s1/1,所有其它的数据包正常转发,整个网络运行RIPv2路由协议。
请自己按照实际拓扑的描述设计实验模拟拓扑。
实验参考命令
步骤1:先去掉上一个任务中R1的策略路由的相关配置
R1(config)#no ip local policy route-map lab1
R1(config)#interface f 0/0
R1(config-if)#no ip policy route-map lab1
R1(config)#no route-map lab1
R1(config)#no access-list 1
R1(config)#no access-list 2
步骤2:
配置路由器R1
R1(config)#route-map CCNP permit 10
R1(config-route-map)#match length 64 100
R1(config-route-map)#set interface s1/0
R1(config)#route-map CCNP permit 20
R1(config-route-map)#match length 101 1000
R1(config-route-map)#set interface s1/1
R1(config)#interface f0/0
R1(config-if)#ip policy route-map CCNP
实验调试
(1)执行扩展ping 命令,数据包的长度为90,源地址为192.1.1.1(路由器R3的以太
口地址),路由器R1上开启调试。
R1#debug ip policy
R3#ping
Protocol [ip]:
Target IP address: 152.1.1.1
Repeat count [5]: 1
Datagram size [100]: 90
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 192.1.1.1
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Type escape sequence to abort.
R1调试信息
(2)执行扩展ping 命令,数据包的长度为300, 源地址为192.1.1.1
R3#ping
(3)执行扩展ping 命令,数据包的长度为1200, 源地址为192.1.1.1
R3#ping
(4)R1上查看定义的所有路由策略及路由策略匹配的情况 show route-map
(5)R1上查看策略路由及作用的接口show ip policy