• 产品与解决方案
  • 行业解决方案
  • 服务
  • 支持
  • 合作伙伴
  • 新华三人才研学中心
  • 关于我们

06-三层技术-IP路由配置举例

目录

02-H3C SR8800 策略路由典型配置举例

本章节下载 02-H3C SR8800 策略路由典型配置举例  (207.79 KB)

docurl=/cn/Service/Document_Software/Document_Center/Routers/Catalog/SR_Router/SR8800/Configure/Typical_Configuration_Example/H3C_SR8800-R3725-6W100/06/201407/834712_30005_0.htm

02-H3C SR8800 策略路由典型配置举例

H3C SR8800 队列调度策略典型配置举例

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Copyright © 2014 杭州华三通信技术有限公司 版权所有,保留一切权利。

非经本公司书面许可,任何单位和个人不得擅自摘抄、复制本文档内容的部分或全部,

并不得以任何形式传播。本文档中的信息可能变动,恕不另行通知。

H3C_彩色.emf

目  录

1 简介

2 配置前提

3 使用限制

4 指定报文转发下一跳配置举例

4.1 组网需求

4.2 配置思路

4.3 使用版本

4.4 配置注意事项

4.5 配置步骤

4.6 验证配置

4.7 配置文件

5 报文转发到指定VPN配置举例

5.1 组网需求

5.2 配置思路

5.3 使用版本

5.4 配置注意事项

5.5 配置步骤

5.6 验证配置

5.7 配置文件

6 相关资料

 


1  简介

本文档介绍了策略路由的配置举例。

普通报文是根据目的IP地址来查找路由表转发的,策略路由是一种依据用户制定的策略进行路由选择的机制。策略路由可以基于到达报文的源地址、目的地址、IP优先级、协议类型等字段灵活地进行路由选择。

策略路由的优先级高于普通路由。配置了策略路由后,报文的转发流程如下(分4种情况):

(1)     策略节点的匹配模式为permit,该节点下ACL规则动作为permit

·     匹配成功:若策略路由设置的出接口或下一跳有效,则按策略路由转发;若策略路由设置的出接口或下一跳无效,则按照普通路由表转发;

·     匹配失败:继续下一个节点的匹配。

(2)     策略节点的匹配模式为permit,该节点下ACL规则动作为deny

·     匹配成功:若策略路由设置的出接口或下一跳有效,则按策略路由转发;若策略路由设置的出接口或下一跳无效,则按照普通路由表转发;

·     匹配失败:继续下一个节点的匹配。

(3)     策略节点的匹配模式为deny,该节点下ACL规则动作为permit

·     匹配成功:按照普通路由表转发;

·     匹配失败:继续下一个节点的匹配。

(4)     策略节点的匹配模式为deny,该节点下ACL规则动作为deny

·     匹配成功:按照普通路由表转发;

·     匹配失败:继续下一个节点的匹配。

2  配置前提

本文档中的配置均是在实验室环境下进行的配置和验证,配置前设备的所有参数均采用出厂时的缺省配置。如果您已经对设备进行了配置,为了保证配置效果,请确认现有配置和以下举例中的配置不冲突。

本文假设您已了解策略路由特性。

3  使用限制

在SPE单板的接口上应用策略路由时,策略中ACL规则所包含的信息必须是该接口下发的流模板中所定义信息的子集。比如,流模板定义了源IP地址、目的IP地址、源TCP端口、目的TCP端口等限制,只有在上述范围内的ACL规则可以正确下发到硬件中,用于策略路由;否则ACL规则将不能下发到硬件中,导致策略路由功能不能引用此ACL规则。

4  指定报文转发下一跳配置举例

4.1  组网需求

图1所示,缺省情况下,Router的GE3/1/1端口上收到的所有报文根据路由表转发的下一跳均为10.4.1.2。

现要求在Router上配置策略路由,具体实现要求如下:

(1)     首先匹配GE3/1/1端口上收到的源IP为10.2.1.1的报文,将该报文的下一跳重定向到10.5.1.2;

(2)     其次匹配GE3/1/1端口上收到的源IP不为10.2.1.1的TCP报文,将该报文的下一跳重定向到10.3.1.2;

(3)     最后匹配GE3/1/1端口上收到的源IP为10.1.1.1的报文,当下一跳10.4.1.2不可达时,将该报文的下一跳重定向到10.3.1.2。

图1 指定报文转发下一跳配置组网图

 

4.2  配置思路

·     为了确保能同时满足对于三种不同类型的报文重定向到不同的下一跳,需要配置三个访问控制列表,一个用于匹配GE3/1/1端口上收到的源IP为10.2.1.1的报文,一个用于匹配GE3/1/1端口上收到的源IP不为10.2.1.1的TCP报文,最后一个用于匹配GE3/1/1端口上收到的源IP为10.1.1.1的非TCP报文,并在策略路由中创建三个节点,分别对匹配上的报文进行重定向;

·     同一条策略路由中,创建的节点编号越小,优先级越高。为了确保GE3/1/1端口上收到源IP为10.2.1.1的报文下一跳能优先被重定向到10.5.1.2,需要在策略路由中配置该策略使用较小的节点编号(本例中使用0号节点)。

·     为了确保匹配GE3/1/1端口上收到的源IP为10.1.1.1的非TCP报文先按照普通路由表转发,只有当10.4.1.2不可达时(即路由表中不存在明细路由),才被重定向到10.3.1.2,需要在策略路由中为匹配上的报文配置缺省下一跳。

4.3  使用版本

本举例是在SR8800-CMW520-R3725版本上进行配置和验证的。

4.4  配置注意事项

·     配置重定向到下一跳时,不能将匹配IPv4规则报文的下一跳重定向到IPv6地址,反之亦然。

·     SPC单板和MPE单板不支持设置报文缺省下一跳。

4.5  配置步骤

# 请按照图1配置各接口的IP地址和子网掩码,具体配置过程略。

# 定义访问控制列表ACL 3005,用于匹配源IP为10.2.1.1的报文。

<Router> system-view

[Router] acl number 3005

[Router-acl-adv-3005] rule 0 permit ip source 10.2.1.1 0

[Router-acl-adv-3005] quit

# 创建策略路由pbr1的0号节点,将匹配ACL 3005的报文下一跳重定向到10.5.1.2。

[Router] policy-based-route pbr1 permit node 0

[Router-pbr-pbr1-0] if-match acl 3005

[Router-pbr-pbr1-0] apply ip-address next-hop 10.5.1.2

[Router-pbr-pbr1-0] quit

# 定义访问控制列表ACL 3006,用于匹配源IP不为10.2.1.1的TCP报文。由于ACL 3005已匹配源IP10.2.1.1.TCP报文,因此其他的TCP报文均为源IP不为10.2.1.1的TCP报文。

[Router] acl number 3006

[Router-acl-adv-3006] rule 0 permit tcp

[Router-acl-adv-3006] quit

# 创建策略路由pbr1的1号节点,将匹配ACL 3006的报文下一跳重定向到10.3.1.2。

[Router] policy-based-route pbr1 permit node 1

[Router-pbr-pbr1-1] if-match acl 3006

[Router-pbr-pbr1-1] apply ip-address next-hop 10.3.1.2

[Router-pbr-pbr1-1] quit

# 定义访问控制列表ACL 3007,用于匹配源IP为10.1.1.1的报文。

[Router] acl number 3007

[Router-acl-adv-3007] rule 0 permit ip source 10.1.1.1 0

[Router-acl-adv-3007] quit

# 创建策略路由pbr1的2号节点,将匹配ACL 3007的报文缺省下一跳为10.3.1.2。

[Router] policy-based-route pbr1 permit node 2

[Router-pbr-pbr1-2] if-match acl 3007

[Router-pbr-pbr1-2] apply ip-address default next-hop 10.3.1.2

[Router-pbr-pbr1-2] quit

# 在路由器的入接口GigabitEthernet3/1/1上应用策略。

[Router] interface gigabitethernet 3/1/1

[Router-GigabitEthernet3/1/1] ip policy-based-route pbr1

[Router-GigabitEthernet3/1/1] quit

4.6  验证配置

通过display ip policy-based-route statistics命令可以查看到当前策略路由配置已经配置成功。

[Router] display ip policy-based-route statistics interface GigabitEthernet 3/1/1

 policy-based-route: pbr1

   permit node 0:

     if-match acl 3005

     apply ip-address next-hop 10.5.1.2

   matched: 0

   permit node 1:

     if-match acl 3006

     apply ip-address next-hop 10.3.1.2

   matched: 0

   permit node 2:

     if-match acl 3007

     apply ip-address default next-hop 10.3.1.2

   matched: 0

 Total matched: 0

4.7  配置文件

#

 version 5.20, Release 3725

#

 sysname Router

#

acl number 3005

 rule 0 permit ip source 10.2.1.1 0

acl number 3006

 rule 0 permit tcp

acl number 3007

 rule 0 permit ip source 10.1.1.1 0

#

policy-based-route pbr1 permit node 0

 if-match acl 3005

 apply ip-address next-hop 10.5.1.2

policy-based-route pbr1 permit node 1

 if-match acl 3006

 apply ip-address next-hop 10.3.1.2

policy-based-route pbr1 permit node 2

 if-match acl 3007

 apply ip-address default next-hop 10.3.1.2

#

interface GigabitEthernet3/1/1

 port link-mode route

 ip policy-based-route pbr1

#

return

5  报文转发到指定VPN配置举例

5.1  组网需求

图2所示,某公司内有3个部门:部门A、部门B和部门C,三个部门属于三个不同的VPN,部门之间不能互访。

现要求通过策略路由实现如下功能:

·     部门A中的PC1与部门C中的Server可以互访;

·     部门B中的PC2与部门C中的Server可以互访。

图2 配置报文在指定VPN实例中转发配置组网图

 

5.2  配置思路

为了实现PC1、PC2能和Server互访,需要在Router A配置如下策略路由:

·     将PC1或PC2发给Server的报文重定向到VPN3中;

·     将Server发给PC1的报文重定向到VPN1中,Server发给PC2的报文重定向到VPN2中。

5.3  使用版本

本举例是在SR8800-CMW520-R3725版本上进行配置和验证的。

5.4  配置注意事项

·     配置接口绑定VPN后,之前配置的IP地址信息会丢失,需要重新配置接口的IP地址。

·     在某个策略节点中配置apply access-vpn vpn-instance后,请不要再配置其他apply子句,否则该策略节点将会失效,按照普通路由表转发。

5.5  配置步骤

说明

Router B的配置和Router A的配置除接口IP地址不同,其他都相同,此处仅以Router A的配置为例。详细配置可参见配置文件

 

(1)     配置接口绑定VPN并配置接口的IP地址

# 配置VPN。

<RouterA> system-view

[RouterA] ip vpn-instance vpn1

[RouterA-vpn-instance-vpn1] route-distinguisher 10:1

[RouterA-vpn-instance-vpn1] quit

[RouterA] ip vpn-instance vpn2

[RouterA-vpn-instance-vpn2] route-distinguisher 10:2

[RouterA-vpn-instance-vpn2] quit

[RouterA] ip vpn-instance vpn3

[RouterA-vpn-instance-vpn3] route-distinguisher 30:1

[RouterA-vpn-instance-vpn3] quit

# 配置接口绑定VPN并配置接口的IP地址

[RouterA] interface gigabitethernet 3/1/1

[RouterA-GigabitEthernet3/1/1] ip binding vpn-instance vpn1

[RouterA-GigabitEthernet3/1/1] ip address 10.1.1.1 24

[RouterA-GigabitEthernet3/1/1] quit

[RouterA] interface gigabitethernet 3/1/2

[RouterA-GigabitEthernet3/1/2] ip binding vpn-instance vpn2

[RouterA-GigabitEthernet3/1/2] ip address 10.2.1.1 24

[RouterA-GigabitEthernet3/1/2] quit

[RouterA] interface gigabitethernet 3/1/3

[RouterA-GigabitEthernet3/1/3] ip binding vpn-instance vpn3

[RouterA-GigabitEthernet3/1/3] ip address 30.1.1.1 24

[RouterA-GigabitEthernet3/1/3] quit

(2)     创建策略路由实现PC1与Server的互访

# 定义访问控制列表ACL 3000,用于匹配PC1发给Server的报文。

[RouterA] acl number 3000

[RouterA-acl-adv-3000] rule permit ip source 10.1.1.10 0 destination 30.1.1.100 0

[RouterA-acl-adv-3000] quit

# 定义访问控制列表ACL 3100,用于匹配Server发给PC1的报文。

[RouterA] acl number 3100

[RouterA-acl-adv-3100] rule permit ip source 30.1.1.100 0 destination 10.1.1.10 0

[RouterA-acl-adv-3100] quit

# 创建策略路由vpn1-to-vpn3的0号节点,将匹配ACL 3000的报文下一跳重定向到VPN3。

[RouterA] policy-based-route vpn1-to-vpn3 permit node 0

[RouterA-pbr-vpn1-to-vpn3-0] if-match acl 3000

[RouterA-pbr-vpn1-to-vpn3-0] apply access-vpn vpn-instance vpn3

[RouterA-pbr-vpn1-to-vpn3-0] quit

# 创建策略路由vpn3-to-other的0号节点,将匹配ACL 3100的报文下一跳重定向到VPN1。

[RouterA] policy-based-route vpn3-to-other permit node 0

[RouterA-pbr-vpn3-to-other-0] if-match acl 3100

[RouterA-pbr-vpn3-to-other-0] apply access-vpn vpn-instance vpn1

[RouterA-pbr-vpn3-to-other-0] quit

(3)     创建策略路由实现PC2与Server的互访

# 定义访问控制列表ACL 3001,用于匹配PC2发给Server的报文。

[RouterA] acl number 3001

[RouterA-acl-adv-3001] rule permit ip source 10.2.1.10 0 destination 30.1.1.100 0

[RouterA-acl-adv-3001] quit

# 定义访问控制列表ACL 3101,用于匹配Server发给PC2的报文。

[RouterA] acl number 3101

[RouterA-acl-adv-3101] rule permit ip source 30.1.1.100 0 destination 10.2.1.10 0

[RouterA-acl-adv-3101] quit

# 创建策略路由vpn2-to-vpn3的0号节点,将匹配ACL 3001的报文下一跳重定向到VPN3。

[RouterA] policy-based-route vpn2-to-vpn3 permit node 0

[RouterA-pbr-vpn2-to-vpn3-0] if-match acl 3001

[RouterA-pbr-vpn2-to-vpn3-0] apply access-vpn vpn-instance vpn3

[RouterA-pbr-vpn2-to-vpn3-0] quit

# 创建策略路由vpn3-to-other的1号节点,将匹配ACL 3101的报文下一跳重定向到VPN2。

[RouterA] policy-based-route vpn3-to-other permit node 1

[RouterA-pbr-vpn3-to-other-1] if-match acl 3101

[RouterA-pbr-vpn3-to-other-1] apply access-vpn vpn-instance vpn2

[RouterA-pbr-vpn3-to-other-1] quit

(4)     在路由器的入接口上应用策略

# 在接口GigabitEthernet 3/1/1上应用策略vpn1-to-vpn3

[RouterA] interface gigabitethernet 3/1/1

[RouterA-GigabitEthernet3/1/1] ip policy-based-route vpn1-to-vpn3

[RouterA-GigabitEthernet3/1/1] quit

# 在接口GigabitEthernet 3/1/2上应用策略vpn2-to-vpn3

[RouterA] interface gigabitethernet 3/1/2

[RouterA-GigabitEthernet3/1/2] ip policy-based-route vpn2-to-vpn3

[RouterA-GigabitEthernet3/1/2] quit

# 在接口GigabitEthernet 3/1/3上应用策略vpn3-to-other

[RouterA] interface gigabitethernet 3/1/3

[RouterA-GigabitEthernet3/1/3] ip policy-based-route vpn3-to-other

[RouterA-GigabitEthernet3/1/3] quit

5.6  验证配置

通过display ip policy-based-route statistics命令可以查看到当前策略路由配置已经配置成功。

[RouterA] display ip policy-based-route statistics interface GigabitEthernet 3/1/1

 Interface GigabitEthernet3/1/1 policy based routing statistics information:

 policy-based-route: vpn1-to-vpn3

   permit node 0:

     if-match acl 3000

     apply access-vpn vpn-instance vpn3

   matched: 0

 Total matched: 0

[RouterA] display ip policy-based-route statistics interface GigabitEthernet 3/1/2

 Interface GigabitEthernet3/1/2 policy based routing statistics information:

 policy-based-route: vpn2-to-vpn3

   permit node 0:

     if-match acl 3001

     apply access-vpn vpn-instance vpn3

   matched: 0

 Total matched:

[RouterA] display ip policy-based-route statistics interface GigabitEthernet 3/1/3

 Interface GigabitEthernet3/1/3 policy based routing statistics information:

 policy-based-route: vpn3-to-other

   permit node 0:

     if-match acl 3100

     apply access-vpn vpn-instance vpn1

   matched: 0

   permit node 1:

     if-match acl 3101

     apply access-vpn vpn-instance vpn2

   matched: 0

 Total matched: 0

# 从PC 1 ping Server,可以ping通。

C:\>ping 30.1.1.100

 

Pinging 30.1.1.100 with 32 bytes of data:

 

Reply from 30.1.1.100: bytes=32 time=37ms TTL=128

Reply from 30.1.1.100: bytes=32 time=1ms TTL=128

Reply from 30.1.1.100: bytes=32 time=1ms TTL=128

Reply from 30.1.1.100: bytes=32 time=1ms TTL=128

 

Ping statistics for 30.1.1.100:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 1ms, Maximum = 37ms, Average = 10ms

 

C:\>

# 从PC 2 ping Server,可以ping通。

C:\>ping 30.1.1.100

 

Pinging 30.1.1.100 with 32 bytes of data:

 

Reply from 30.1.1.100: bytes=32 time=37ms TTL=128

Reply from 30.1.1.100: bytes=32 time=1ms TTL=128

Reply from 30.1.1.100: bytes=32 time=1ms TTL=128

Reply from 30.1.1.100: bytes=32 time=1ms TTL=128

 

Ping statistics for 30.1.1.100:

    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

    Minimum = 1ms, Maximum = 37ms, Average = 10ms

 

C:\>

# 从PC 1 ping PC 2,无法ping通。

C:\>ping 10.2.1.10

 

Pinging 10.2.1.10 with 32 bytes of data:

 

Request timed out.

Request timed out.

Request timed out.

Request timed out.

 

Ping statistics for 10.2.1.10:

    Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

 

C:\>

5.7  配置文件

·     Router A

#

 version 5.20, Release 3725

#

 sysname RouterA

#

ip vpn-instance vpn1

 route-distinguisher 10:1

#

ip vpn-instance vpn2

 route-distinguisher 10:2

#

ip vpn-instance vpn3

 route-distinguisher 30:1

#

acl number 3000

 rule 0 permit ip source 10.1.1.10 0 destination 30.1.1.100 0

acl number 3001

 rule 0 permit ip source 10.2.1.10 0 destination 30.1.1.100 0

acl number 3100

 rule 0 permit ip source 30.1.1.100 0 destination 10.1.1.10 0

acl number 3101

 rule 0 permit ip source 30.1.1.100 0 destination 10.2.1.10 0

#

policy-based-route vpn1-to-vpn3 permit node 0

 if-match acl 3000

 apply access-vpn vpn-instance vpn3

#

policy-based-route vpn3-to-other permit node 0

 if-match acl 3100

 apply access-vpn vpn-instance vpn1

policy-based-route vpn3-to-other permit node 1

 if-match acl 3101

 apply access-vpn vpn-instance vpn2

#

policy-based-route vpn2-to-vpn3 permit node 0

 if-match acl 3001

 apply access-vpn vpn-instance vpn3

#

interface GigabitEthernet3/1/1

 port link-mode route

 ip binding vpn-instance vpn1

 ip address 10.1.1.1 255.255.255.0

 ip policy-based-route vpn1-to-vpn3

#

interface GigabitEthernet3/1/2

 port link-mode route

 ip binding vpn-instance vpn2

 ip address 10.2.1.1 255.255.255.0

 ip policy-based-route vpn2-to-vpn3

#

interface GigabitEthernet3/1/3

 port link-mode route

 ip binding vpn-instance vpn3

 ip address 30.1.1.1 255.255.255.0

 ip policy-based-route vpn3-to-other

#

return

·     Router B

#

 version 5.20, Release 3725

#

 sysname RouterB

#

ip vpn-instance vpn1

 route-distinguisher 10:1

#

ip vpn-instance vpn2

 route-distinguisher 10:2

#

ip vpn-instance vpn3

 route-distinguisher 30:1

#

acl number 3000

 rule 0 permit ip source 10.1.1.10 0 destination 30.1.1.100 0

acl number 3001

 rule 0 permit ip source 10.2.1.10 0 destination 30.1.1.100 0

acl number 3100

 rule 0 permit ip source 30.1.1.100 0 destination 10.1.1.10 0

acl number 3101

 rule 0 permit ip source 30.1.1.100 0 destination 10.2.1.10 0

#

policy-based-route vpn1-to-vpn3 permit node 0

 if-match acl 3000

 apply access-vpn vpn-instance vpn3

#

policy-based-route vpn3-to-other permit node 0

 if-match acl 3100

 apply access-vpn vpn-instance vpn1

policy-based-route vpn3-to-other permit node 1

 if-match acl 3101

 apply access-vpn vpn-instance vpn2

#

policy-based-route vpn2-to-vpn3 permit node 0

 if-match acl 3001

 apply access-vpn vpn-instance vpn3

#

interface GigabitEthernet3/1/1

 port link-mode route

 ip binding vpn-instance vpn1

 ip address 10.1.1.2 255.255.255.0

 ip policy-based-route vpn1-to-vpn3

#

interface GigabitEthernet3/1/2

 port link-mode route

 ip binding vpn-instance vpn2

 ip address 10.2.1.2 255.255.255.0

 ip policy-based-route vpn2-to-vpn3

#

interface GigabitEthernet3/1/3

 port link-mode route

 ip binding vpn-instance vpn3

 ip address 30.1.1.2 255.255.255.0

 ip policy-based-route vpn3-to-other

#

return

6  相关资料

·     《H3C SR8800万兆核心路由器 三层技术-IP路由命令参考》中的“策略路由”

·     《H3C SR8800万兆核心路由器 三层技术-IP路由配置指导》中的“策略路由”

 

不同款型规格的资料略有差异, 详细信息请向具体销售和400咨询。H3C保留在没有任何通知或提示的情况下对资料内容进行修改的权利!

新华三官网
联系我们