Chinaunix首页 | 论坛 | 博客
  • 博客访问: 847737
  • 博文数量: 366
  • 博客积分: 10267
  • 博客等级: 上将
  • 技术积分: 4290
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-24 14:04
文章分类

全部博文(366)

文章存档

2012年(366)

分类: 系统运维

2012-03-01 16:52:26

目前使用的主要的数据流技术,一般有访问控制列表和基于策略的路由。
访问控制列表是如何对数据流进行控制,而基于策略的路由是对路由进行控制。由于实现基于策略的路由的方法有多种,这里我们介绍其中最灵活最广泛的一种——Route Map。
Route Map语句和访问控制列表的区别:
1.应用目的不同
访问控制列表是依据数据包中的条件对数据包进行过滤,考虑的是允许还是禁止数据包的通过。
Route Map语句的应用目的是依据数据包中的条件对数据包的传输方向进行控制,考虑的是数据包应该从什么线路被路由。
2.Route Map语句可以灵活修改
访问控制列表修改非常麻烦。
Route Map语句由于定义有序列号,需要修改时,可以直接指定所要修改的Route Map语句的序列号,从而实现非常简便灵活的修改。
3.对于完全不符合任何条件的数据包操作不同
一个数据包如果不符合访问控制列表中所有语句的条件,则这个数据包会被路由器丢弃。
而如果一个数据包完全不符合Route Map中所有语句的条件,则该数据包按照路由器的路由表路由。
应用基于源IP地址的策略路由
网络拓扑
 
案例背景及需求
某企业总部有两幢办公楼,A座和B座,B座里面有该企业的数据中心,该企业的很多办公数据流都需要访问数据中心中的服务器——192.168.1.1和192.168.1.2.
该企业在两幢办公楼,|A座和B座之间,连接有两条光纤,分别由A、B座的路由器负责连接。
由于A座中办公人员访问数据中心两台服务器的流量很多,这两台服务器每天都需要传输大量的数据到A座。
为了防止两台服务器的数据被占同一条线路造成数据拥塞,企业的网管被要求在路由器B上做一些策略,使得两台服务器发送到A座的数据能够固定地分开在两条线路上,而其他人的数据路由应该正常而不受影响。
案例解决
我们应该在路由器B上定义一个基于源IP地址进行策略路由的Route Map语句,并将这个语句应用于路由器B的以太接口上(即该接口连接着两台服务器及其他主机),以对来自以太接口的数据流进行基于源IP地址的策略路由,让服务器192.168.1.1发出的数据包从S0接口传输,而服务器192.168.1.2发出的数据包从S1接口传输,从而分担开网络负担。
这里我们使用两台路由器搭建一个模拟的环境,对所要应用的Route Map语句进行一些测试。
案例实施:配置步骤及配置实例
1.定义Route Map语句
首先定义Route Map语句,以指定源IP地址及对数据包的操作。
Router(config)#route-map map-name [permit|deny] [sequence-number]
Router(config-route-map)#match ip {source-address}
Router(config-route-map)#set interface interface number
在基于源IP地址的策略路由语句中,条件可以直接写数据包的源IP地址,如何数据包的源IP地址有多个,则可以使用访问控制列表预先定义多个地址,然后在Route Map语句的条件子命令中嵌套这个访问控制列表。
2.在接口上应用Route Map语句
定义好基于源IP地址的策略路由语句后,应该在数据流的进方向接口应用该Route Map语句。
Router(config-if)#ip policy route-map map-name
在接口上应用了该命令后,所有由此接口进入路由器的数据包都会被强制比对条件,以找到需要进行策略路由的数据包。
3.路由器本身产生的数据包也接受基于源IP地址的策略路由的管理
在通常情况下,由路由器本身产生的数据包不受控于策略路由语句,为了让路由器本身产生的数据包也能够接受策略路由的管理,应在路由器的全局模式下使用如下命令:
Router(config)#ip local policy route-map map-name
以下给出了本案的配置实例,以供参考,其中黑体字为关键的配置步骤。
路由器A配置如下:
interface Loopback1
ip address 152.1.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 150.1.1.1 255.255.255.0
!
interface Ethernet0/1
ip address 151.1.1.1 255.255.255.0
!
router rip
version 2
network 150.1.0.0
network 151.1.0.0
network 152.1.0.0
no auto-summary
!
 
 
路由器B配置如下:
interface Ethernet0/0
ip address 150.1.1.2 255.255.255.0
!
interface Ethernet0/1
ip address 151.1.1.2 255.255.255.0
!
interface Ethernet0/2
ip address 192.168.1.2 255.255.255.0 secondary
ip address 192.168.1.10 255.255.255.0 secondary
ip address 192.168.1.1 255.255.255.0
ip policy route-map lable1
!
router rip
version 2
network 150.1.0.0
network 151.1.0.0
network 192.168.1.0
no auto-summary
!
ip local policy route-map lable1
!
access-list 1 permit 192.168.1.1
access-list 2 permit 192.168.1.2
!
route-map lable1 permit 10
match ip address 1
set interface Ethernet0/0
!
route-map lable1 permit 20
match ip address 2
set interface Ethernet0/1
 
 
对策略路由状态进行监测
在路由器B上使用debug ip policy命令监视策略路由
方法一:使用扩展traceroute命令,指定源地址和目标地址测试从路由器B到A的数据包所经过的路径。192.168.1.1——152.1.1.1
RB#traceroute ip
Target IP address: 152.1.1.1
Source address: 192.168.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
1 150.1.1.1 40 msec
*Mar 1 00:17:21.095: IP: s=192.168.1.1 (local), d=152.1.1.1, len 28, policy match
*Mar 1 00:17:21.099: IP: route map lable1, item 10, permit
*Mar 1 00:17:21.099: IP: s=192.168.1.1 (local), d=152.1.1.1 (Ethernet0/0), len 28, policy routed
*Mar 1 00:17:21.099: IP: local to Ethernet0/0 150.1.1.1
RB#
 
 
上表显示:我们可以看到数据包经过了150.1.1.1接口,有也就是说源自192.168.1.1得的从E0/0接口的线路经过了,基于源IP地址的策略路由生效。
用扩展traceroute命令,指定源地址和目标地址测试从路由器B到A的数据包所经过的路径。192.168.1.2——152.1.1.1
RB#traceroute ip
Target IP address: 152.1.1.1
Source address: 192.168.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
1 151.1.1.1 36 msec
*Mar 1 00:21:05.839: IP: s=192.168.1.2 (local), d=152.1.1.1, len 28, policy match
*Mar 1 00:21:05.843: IP: route map lable1, item 20, permit
*Mar 1 00:21:05.843: IP: s=192.168.1.2 (local), d=152.1.1.1 (Ethernet0/1), len28, policy routed
*Mar 1 00:21:05.843: IP: local to Ethernet0/1 151.1.1.1
RB#
 
 
上表显示:我们可以看到数据包经过了151.1.1.1接口,也就是说源自192.168.1.2得的从E0/1接口的线路经过了,基于源IP地址的策略路由生效。
使用扩展traceroute命令,指定源地址和目标地址测试从路由器B到A的数据包所经过的路径。192.168.1.10——152.1.1.1
RB#traceroute ip
Target IP address: 152.1.1.1
Source address: 192.168.1.10
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
1 150.1.1.1 68 msec
151.1.1.1 40 msec
*Mar 1 00:23:31.367: IP: s=192.168.1.10 (local), d=152.1.1.1, len 28, policy rejected -- normal forwarding
RB#
 
 
上表显示:policy rejected -- normal forwarding表示该数据包不符合任何的策略路由语句的条件,则按照路由表中的的路由来处理该数据包。
方法二:用扩展ping命令,指定源地址和目标地址测试从路由器B到A的数据包所经过的路径。192.168.1.1——152.1.1.1
RB#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.168.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.168.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 8/24/56 ms
RB#
*Mar 1 00:32:52.743: IP: s=192.168.1.1 (local), d=152.1.1.1, len 100, policy match
*Mar 1 00:32:52.743: IP: route map lable1, item 10, permit
*Mar 1 00:32:52.743: IP: s=192.168.1.1 (local), d=152.1.1.1 (Ethernet0/0), len100, policy routed
*Mar 1 00:32:52.747: IP: local to Ethernet0/0 150.1.1.1
RB#
 
 
上表显示:“policy match”表示数据包符合一条策略路由语句的条件,“lable1,item 10”表示数据包符合的是Route Map lable1中的第一条语句的条件,“policy routed”表示数据包按照策略路由的规定被发送,其路径经过150.1.1.1。
用扩展ping命令,指定源地址和目标地址测试从路由器B到A的数据包所经过的路径。192.168.1.2——152.1.1.1
RB#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.168.1.2
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.168.1.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/68/124 ms
RB#
*Mar 1 00:36:22.707: IP: s=192.168.1.2 (local), d=152.1.1.1, len 100, policy match
*Mar 1 00:36:22.707: IP: route map lable1, item 20, permit
*Mar 1 00:36:22.707: IP: s=192.168.1.2 (local), d=152.1.1.1 (Ethernet0/1), len100, policy routed
*Mar 1 00:36:22.711: IP: local to Ethernet0/1 151.1.1.1
RB#
 
 
上表显示:“policy match”表示数据包符合一条策略路由语句的条件,“lable1,item 20”表示数据包符合的是Route Map lable1中的第一条语句的条件,“policy routed”表示数据包按照策略路由的规定被发送,其路径经过151.1.1.1。
用扩展ping命令,指定源地址和目标地址测试从路由器B到A的数据包所经过的路径。192.168.1.10——152.1.1.1
RB#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.168.1.10
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.168.1.10
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/59/88 ms
RB#
*Mar 1 00:38:21.719: IP: s=192.168.1.10 (local), d=152.1.1.1, len 100, policy rejected -- normal forwarding
RB#
 
摘自IT者安全网() 原文:
阅读(957) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~