3.2.1.2 路由器配置举例

图片.png

1.1.0.0 à ISP A.

1.2.0.0 à ISP B.

RouterA(config)# access-list 1 permit ip 1.1.0.0 0.0.255.255

RouterA(config)# access-list 2 permit ip 1.2.0.0 0.0.255.255

 

RouterA(config)# route-map access permit 10

RouterA(config-route-map)# match ip address 1

RouterA(config-route-map)# set ip default next-hop 6.6.6.6

RouterA(config-route-map)# route-map access permit 20

RouterA(config-route-map)# match ip address 2

RouterA(config-route-map)# set ip default next-hop 7.7.7.7

RouterA(config-route-map)# route-map access permit 30

RouterA(config-route-map)# set default interface null0

 

RouterA(config)# interface ethernet 0

RouterA(config-if)# ip address 1.1.1.1 255.255.255.0

RouterA(config-if)# ip policy route-map access

 

RouterA(config)# interface serial 0

RouterA(config-if)# ip address 6.6.6.5 255.255.255.0

RouterA(config)# interface serial 1

RouterA(config-if)# ip address 7.7.7.6 255.255.255.0


3.2.2 交换机基本配置

3.2.2.1 交换机配置步骤

1)定义重分布路由图,一个路由图可以由好多策略组成,策略按序号大小排列,只要符合了前面策略,就退出路由图的执行;

2)定义路由图每个策略的匹配规则或条件;

3)定义满足匹配规则后,路由器对符合规则的数据包进行IP优先值和下一跳的设置

4)在指定接口中应用路由图。


3.2.2.2 交换机配置举例

f 0/0口上配置策略路由,使得所有进入的报文都转发到下一跳为192.168.5.5

设备

Ruijie(config)# access-list 1 permit any

Ruijie(config)# route-map name

Ruijie(config-route-map)# match ip address 1

Ruijie(config-route-map)# set ip next-hop 192.168.5.5

Ruijie(config-route-map)# int f 0/0

Ruijie(config-if)# ip policy route-map name


3.2.2.3 交换机配置建议

S6000E系列的交换机使用多业务子卡可实现策略路由。一个接口最多只能配置一个路由图,在同一个接口上多次配置路由图会相互覆盖。

 

在使用策略路由时,每个子路由图建议只配置一个ACL

 

如果配置的子路由图中只有nexthop而没有配置ACL,则等价于所有报文都匹配;

 

如果子路由图中只有ACL而没有nexthop则匹配的报文普通转发;

 

如果子路由图中即没有ACL也没有nexthop,则等价所有报文普通转发。

 

策略路由只支持配置ACL,不支持ACL名字配置

 

如果配置了ACL号但是该ACL不存在,等价所有报文都匹配

3.3 策略路由的验证和调试 

 

显示IP策略应用情况

router#show ip policy

    Interface               Route map

    FastEthernet2           test    

 

 

Debug ip policy

IP: s=1.1.1.2 (FastEthernet 1/1), d=192.168.2.250(<NULL>), len=60, precedence=0, policy match RouteMap test, item = 10, permit

IP: s=1.1.1.2 (FastEthernet 1/1), d=192.168.2.250(FastEthernet 1/0), len=60, precedence=0, policy routed

 

显示所有或指定路由映射的信息

server_r1#show route-map <word>

route-map test, permit, sequence 10

     Match clauses:

     ip address (access-lists): 1

     Set clauses:

     default interface FastEthernet0

     Policy routing matches: 42 packets, 2520 bytes

     route-map test, permit, sequence 20

     Match clauses:

     ip address (access-lists): 2

     Set clauses:

     ip next-hop 10.10.13.3

     Policy routing matches: 12 packets, 720 bytes

显示所有或指定路由映射的信息

 

 

4 策略路由部署应用案例

4.1 策略路由配置案例一

4.1.1 网络拓扑

图片.png

4.1.2 功能需求:

OICQ应用全走电信出口

 

222.200.80.1/24数据流通过教育网上网

 

211.66.88.1/24访问教育网走教育网

非教育网流量走电信

 

 

 

 

4.1.3  配置实现:

route-map test permit 10

match ip address   103

set ip next-hop   172.16.0.1

route-map test permit 20

match ip address   105

set ip next-hop   210.38.0.1

 

ip access-list extended 103

10 permit tcp any any eq 8000

20 permit udp any any eq 8000    //OICQ端口

 

ip access-list extended 105

10 permit ip 222.200.80.1 0.0.0.255 any

20 permit ip any 58.192.0.0 0.1.255.255

30 permit ip any 58.194.0.0 0.1.255.255 省略… //.教育网地址段

 

int ge 1/3

ip policy route-map test     //应用到入接口

4.2 策略路由配置案例二

4.2.1 网络拓扑

图片.png

4.2.2 功能需求:

OICQ应用全走电信出口

222.200.80.1/24数据流通过教育网上网

211.66.88.1/24访问教育网走教育网

非教育网流量走电信

4.2.3  配置实现:

route-map test permit 10

match ip address   103

set ip next-hop   172.16.0.1

route-map test permit 20

match ip address   105

set ip next-hop   210.38.0.1

 

ip access-list extended 103

10 permit tcp any any eq 8000

20 permit udp any any eq 8000    //OICQ端口

 

ip access-list extended 105

10 deny ip any 211.66.88.0 0.0.0.255

20 deny ip any 222.200.80.0 0.0.0.255

30 permit ip 222.200.80.1 0.0.0.255 any

40 permit ip any 58.192.0.0 0.1.255.255   省略… //.教育网地址段

 

int range ge 1/3-4

ip policy route-map test     //应用到入接口

 

4.3 策略路由配置案例三

4.3.1 网络拓扑

图片.png

说明:用户使用NBR2000作为网吧出口路由器,接入线路共3条,两条电信线路,一条网通线路。由于NBR2000只有2WAN口,因此两条电信线路通过一台二层交换机连接到NBR2000WAN 0口上,WAN 0口配置两个IP地址(其中一个为second ip),WAN 1口连接网通线路。IP地址如图所示。

4.3.2 功能需求:

访问网通的网络走网通线路,访问其他网络使用负载均衡的方式分别走两条电信线路。

这是一种以前很少碰到的方案需求。

图片.png

4.3.3  配置实现:

access-list 90 permit 192.168.0.0 0.0.0.254  //定义偶数IP

access-list 91 permit 192.168.0.1 0.0.0.254  //定义奇数IP

 

route-map Telcom permit 10

match ip address 90

set ip default next-hop 202.109.204.1   //定义偶数IP往电信1线路转发

 

route-map Telcom permit 20

match ip address 91

set ip default next-hop 61.154.8.1      //定义奇数IP往电信2线路转发

 

ip nat pool pool1 prefix-length 24

address 202.109.204.2 202.109.204.2 match interface GigabitEthernet 0/1

address 210.51.32.2 210.51.32.2 match interface FastEthernet 0/2

 

ip nat pool pool2 prefix-length 24

address 61.154.8.2 61.154.8.2 match interface GigabitEthernet 0/1

address 210.51.32.2 210.51.32.2 match interface FastEthernet 0/2

!

ip nat inside source list 90 pool pool1

ip nat inside source list 91 pool pool2     //定义奇偶IP nat地址池

!

ip route 58.16.0.0 255.255.0.0 220.249.160.97

省略若干网通路由

ip route 222.160.0.0 255.252.0.0 220.249.160.97    //路由表中只存在网通路由

4.3.4  配置优化:

图片.png

route-map Telcom permit 10

match ip address 90

set ip default next-hop 202.109.204.1 210.51.32.1

!

route-map Telcom permit 20

match ip address 91

set ip default next-hop 61.154.8.1 210.51.32.1

 

来自 <http://blog.163.com/hlz_2599/blog/static/142378474201341271441374/>