免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1471 | 回复: 0
打印 上一主题 下一主题

由于源目标IP策略路由 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-04-10 22:00 |只看该作者 |倒序浏览

    我们在写流量工程式的时候,可以用策略路由来做流量工量转发路径的控制。
一。实验拓朴:


二。实验目的
1。学会灵活使用ACL 2。用策略路由使数据包走不同的数据线路传输 3。让R1的1.1.1.0/24走R2与R2的串行口 3。让数据包大于200字节的数据包走R2与R3的F0/0走。
三。实验步骤
  1。基本配置,R1 R2 R3配置IP地址,启用OSPF协议,在R1上建立四个网段用于测试用:1.1.1.0/24 1.1.2.0/24 1.1.3.0/24 1.1.4.0/24.
  2。在R2上做策略路由
  3。配置文档 只是一部分的配置,废话就不用发到上面了占地方,追求精,准,快
R1#show run
Building configuration...
Current configuration : 1110 bytes!
version 12.3!
ip cef
interface Loopback0
ip address 1.1.2.1 255.255.255.0 secondary  主要用于测试用
ip address 1.1.3.1 255.255.255.0 secondary
ip address 1.1.4.1 255.255.255.0 secondary
ip address 1.1.1.1 255.255.255.0
ip ospf network point-to-point   指定为p2p网络类型,就不会出现/32的主机路由
!
interface Serial1/0
ip address 12.1.1.1 255.255.255.0
serial restart-delay 0
clock rate 64000
!
router ospf 10
router-id 1.1.1.1
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
R2#sh run
Building configuration..
interface Serial1/0
ip address 12.1.1.2 255.255.255.0
ip policy route-map tor3   一个接口下只能绑定一个route-map ,但可以通过顺序号建立多个条目
serial restart-delay 0
clock rate 64000
!
interface Serial1/1
ip address 23.1.1.2 255.255.255.0
serial restart-delay 0
clock rate 64000
router ospf 10
router-id 2.2.2.2
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
default-information originate always 一指一条默认路由到R1与R3的路由表中
O*E2 0.0.0.0/0 [110/1] via 12.1.1.2, 00:12:04, Serial1/0
!         
ip classless
no ip http server
no ip http secure-server
!
!
access-list 1 permit 1.1.1.0 0.0.0.255  通过ACL控制那些数据采用策略路由转发
access-list 2 permit 1.1.4.0 0.0.0.255
!
route-map tor3 permit 1
match ip address 1  绑定ACL 1
set ip next-hop 23.1.1.3   下一次地址
!
route-map tor3 permit 2
match ip address 2
match length 200 300   基于数据包大小的条件大于200 小于300
set ip next-hop 213.1.1.3
!

R3#sh run
Building configuration...
Current configuration : 1147 bytes
interface Loopback0
ip address 3.3.3.3 255.255.255.0
ip ospf network point-to-point
!
interface Serial1/0
ip address 23.1.1.3 255.255.255.0
serial restart-delay 0
clock rate 64000
router ospf 10
router-id 3.3.3.3
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
ip local policy route-map tor1 我们不能将策路路由绑定在接口上,因为路由器产生的数据包不会基于策略路由转发 所以要在全局下起用。ip local policy route-map tor1
route-map tor1 permit 10
match ip address 2
set ip next-hop 23.1.1.2

四。数据分析
1。在做完基本配置后,我们traceroute 3.3.3.3
R1# traceroute 3.3.3.3
Type escape sequence to abort.
Tracing the route to 3.3.3.3
  1 12.1.1.2 524 msec 16 msec 164 msec
  2 213.1.1.3 936 msec 704 msec 148 msec 可以看出我们的下一条不是23.1.1.3 而是F0/0出去的
R1#ping    在这里就不讲扩展PING的命令格式了,用多了就知道了     
Protocol [ip]:
Target IP address: 3.3.3.3
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface:
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]: re
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.3.3.3, timeout is 2 seconds:
Packet has IP options:  Total option bytes= 39, padded length=40
Record route:
   (12.1.1.1)  但要注意,我们现在traceroute ping 的源地址不是1.1.1.1,而是12.1.1.1
   (213.1.1.2)
   (3.3.3.3)
   (213.1.1.3)
   (12.1.1.2)
   (12.1.1.1)
   (0.0.0.0)
   (0.0.0.0)
   (0.0.0.0)
End of list

2。在R2做基于源IP的策略路由后,以下是R2 的debug ip policy
*Mar 31 19:13:08.183: IP: s=1.1.1.1 (Serial1/0), d=3.3.3.3, len 68, policy match
*Mar 31 19:13:08.183: IP: route map tor3, item 10, permit
*Mar 31 19:13:08.187: IP: s=1.1.1.1 (Serial1/0), d=3.3.3.3 (Serial1/1), len 68, policy routed
*Mar 31 19:13:08.187: IP: Serial1/0 to Serial1/1 23.1.1.3

3。在R3所有转发的数据包转发到set next-hop 23.1.1.2
*Mar 31 19:30:14.815: IP: s=3.3.3.3 (local), d=1.1.1.1, len 100, policy match
*Mar 31 19:30:14.819: IP: route map tor1, item 10, permit
*Mar 31 19:30:14.819: IP: s=3.3.3.3 (local), d=1.1.1.1 (FastEthernet0/0), len 100, policy routed
*Mar 31 19:30:14.819: IP: local to FastEthernet0/0 213.1.1.2

4.R1用1.1.4.0/24去PING R3,可以看到我们基于数据包大小的判定。
*Mar 31 20:09:07.755: IP: s=1.1.4.1 (Serial1/0), d=3.3.3.3, len 210, policy match
*Mar 31 20:09:07.755: IP: route map tor3, item 2, permit
*Mar 31 20:09:07.759: IP: s=1.1.4.1 (Serial1/0), d=3.3.3.3 (FastEthernet0/0), len 210, policy routed
*Mar 31 20:09:07.759: IP: Serial1/0 to FastEthernet0/0 213.1.1.3

五:试验总结:
1。一个接口下只能配置一个策略条目
2#sh route-map
route-map tor3, permit, sequence 1   可以使用多个顺序号,默认以10为步进值。
Match clauses:
    ip address (access-lists): 1
  Set clauses:
    ip next-hop 23.1.1.3
  Policy routing matches: 3 packets, 210 bytes
route-map tor3, permit, sequence 2
  Match clauses:
    ip address (access-lists): 2
    length 200 300
  Set clauses:
    ip next-hop 213.1.1.3
  Policy routing matches: 13 packets, 2354 bytes


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/35811/showart_275187.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP