华为路由器配置 本地策略路由 的基本功能示例(策略路由、PBR)

华为路由器配置 本地策略路由 的基本功能示例(策略路由、PBR)

组网需求

华为路由器配置 本地策略路由 的基本功能示例(策略路由、BPR)(图1)如图所示,RouterA与RouterB间有两条链路相连。
用户希望实现本机下发的不同长度的报文通过不同的下一跳地址进行转发,其中:
    长度为64~1400字节的报文设置192.168.1.2作为下一跳地址。
    长度为1401~1500字节的报文设置192.168.2.2作为下一跳地址。
    所有其它长度的报文都按基于目的地址的方法进行路由选路。
配置思路
采用如下思路配置本地策略路由:
    在RouterA上配置IP报文长度匹配条件,以实现本机下发的不同长度的报文匹配不同的策略点。
    在RouterA上配置本地策略路由的动作,以实现本机下发的不同长度的报文通过不同的下一跳地址进行转发。
    使能本地策略路由。

操作步骤
    配置各接口的IP地址
    # 配置RouterA的各接口的IP地址。
    <Huawei> system-view
    [Huawei] sysname RouterA
    [RouterA] interface gigabitethernet 1/0/0
    [RouterA-GigabitEthernet1/0/0] ip address 192.168.1.1 255.255.255.0
    [RouterA-GigabitEthernet1/0/0] quit
    [RouterA] interface gigabitethernet 2/0/0
    [RouterA-GigabitEthernet2/0/0] ip address 192.168.2.1 255.255.255.0
    [RouterA-GigabitEthernet2/0/0] quit
    [RouterA] interface loopback 0
    [RouterA-LoopBack0] ip address 10.1.1.1 255.255.255.0
    [RouterA-LoopBack0] quit

# 配置RouterB的各接口的IP地址。
    <Huawei> system-view
    [Huawei] sysname RouterB
    [RouterB] interface gigabitethernet 1/0/0
    [RouterB-GigabitEthernet1/0/0] ip address 192.168.1.2 255.255.255.0
    [RouterB-GigabitEthernet1/0/0] quit
    [RouterB] interface gigabitethernet 2/0/0
    [RouterB-GigabitEthernet2/0/0] ip address 192.168.2.2 255.255.255.0
    [RouterB-GigabitEthernet2/0/0] quit
    [RouterB] interface loopback 0
    [RouterB-LoopBack0] ip address 10.1.2.1 255.255.255.0
    [RouterB-LoopBack0] quit

配置静态路由
    # 在RouterA上配置静态路由。
    [RouterA] ip route-static 10.1.2.0 24 192.168.1.2
    [RouterA] ip route-static 10.1.2.0 24 192.168.2.2
    # 在RouterB上配置静态路由。
    [RouterB] ip route-static 10.1.1.0 24 192.168.1.1
    [RouterB] ip route-static 10.1.1.0 24 192.168.2.1

配置策略路由
    # 配置名称为lab1的策略路由。
    [RouterA] policy-based-route lab1 permit node 10
    [RouterA-policy-based-route-lab1-10] if-match packet-length 64 1400
    [RouterA-policy-based-route-lab1-10] apply ip-address next-hop 192.168.1.2
    [RouterA-policy-based-route-lab1-10] quit
    [RouterA] policy-based-route lab1 permit node 20
    [RouterA-policy-based-route-lab1-20] if-match packet-length 1401 1500
    [RouterA-policy-based-route-lab1-20] apply ip-address next-hop 192.168.2.2
    [RouterA-policy-based-route-lab1-20] quit

# 使能本地策略路由。
    [RouterA] ip local policy-based-route lab1

验证配置结果
# 清空RouterB接口统计信息。
    <RouterB> reset counters interface gigabitethernet 1/0/0
    <RouterB> reset counters interface gigabitethernet 2/0/0
# 查看RouterB接口统计信息。
华为路由器配置 本地策略路由 的基本功能示例(策略路由、BPR)(图2)华为路由器配置 本地策略路由 的基本功能示例(策略路由、BPR)(图3)华为路由器配置 本地策略路由 的基本功能示例(策略路由、BPR)(图4)

    # 在RouterA上Ping RouterB的Loopback0,并将报文数据字段长度设为80字节。

    <RouterA> ping -s 80 10.1.2.1

      PING 10.1.2.1: 80  data bytes, press CTRL_C to break                          
        Reply from 10.1.2.1: bytes=80 Sequence=1 ttl=255 time=2 ms                  
        Reply from 10.1.2.1: bytes=80 Sequence=2 ttl=255 time=2 ms                  
        Reply from 10.1.2.1: bytes=80 Sequence=3 ttl=255 time=2 ms                  
        Reply from 10.1.2.1: bytes=80 Sequence=4 ttl=255 time=2 ms                  
        Reply from 10.1.2.1: bytes=80 Sequence=5 ttl=255 time=2 ms                  
                                                                                    
      --- 10.1.2.1 ping statistics ---                                              
        5 packet(s) transmitted                                                     
        5 packet(s) received                                                        
        0.00% packet loss                                                           
        round-trip min/avg/max = 2/2/2 ms                                           

                                          

    # 查看RouterB接口统计信息。

    <RouterB> display interface gigabitethernet 1/0/0
    GigabitEthernet1/0/0 current state : UP                                         
    Line protocol current state : UP                                                
    Last line protocol up time : 2012-07-30 11:23:24                                
    Description:HUAWEI, AR Series, GigabitEthernet1/0/0 Interface                   
    Route Port,The Maximum Transmit Unit is 1500                                    
    Internet Address is 192.168.1.2/24                                                
    IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0819-a6ce-7d4c
    Last physical up time   : 2012-07-30 11:23:24                                   
    Last physical down time : 2012-07-24 16:54:19                                   
    Current system time: 2012-07-30 15:00:15                                        
    Port Mode: COMMON COPPER                                                        
    Speed : 1000,  Loopback: NONE                                                   
    Duplex: FULL,  Negotiation: ENABLE                                              
    Mdi   : AUTO                                                                    
    Last 300 seconds input rate 152 bits/sec, 0 packets/sec                         
    Last 300 seconds output rate 16 bits/sec, 0 packets/sec                         
    Input peak rate 7568 bits/sec,Record time: 2012-07-30 12:57:02                  
    Output peak rate 1008 bits/sec,Record time: 2012-07-30 12:42:42                 
                                                                                    
    Input:  135403 packets, 118911125 bytes                                         
      Unicast:             107066,  Multicast:               10468                  
      Broadcast:            17869,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      CRC:                      0,  Giants:                      0                  
      Jabbers:                  0,  Throttles:                   0                  
      Runts:                    0,  Symbols:                     0                  
      Ignoreds:                 0,  Frames:                      0                  
                                                                                    
    Output:  59070 packets, 14217739 bytes                                          
      Unicast:              37581,  Multicast:               21485                  
      Broadcast:                4,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      Collisions:               0,  ExcessiveCollisions:         0                  
      Late Collisions:          0,  Deferreds:                   0                  
                                                                                    
        Input bandwidth utilization threshold : 100.00%                             
        Output bandwidth utilization threshold: 100.00%                             
        Input bandwidth utilization  : 0.01%                                        
        Output bandwidth utilization : 0.01%    

    <RouterB> display interface gigabitethernet 2/0/0
    GigabitEthernet2/0/0 current state : UP                                         
    Line protocol current state : UP                                                
    Last line protocol up time : 2012-07-30 11:23:29                                
    Description:HUAWEI, AR Series, GigabitEthernet2/0/0 Interface                   
    Route Port,The Maximum Transmit Unit is 1500                                    
    Internet Address is 192.168.2.2/24                                                
    IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0819-a6ce-7d4d
    Last physical up time   : 2012-07-30 11:23:29                                   
    Last physical down time : 2012-07-30 11:09:17                                   
    Current system time: 2012-07-30 15:01:02                                        
    Port Mode: COMMON COPPER                                                        
    Speed : 1000,  Loopback: NONE                                                   
    Duplex: FULL,  Negotiation: ENABLE                                              
    Mdi   : AUTO                                                                    
    Last 300 seconds input rate 112 bits/sec, 0 packets/sec                         
    Last 300 seconds output rate 0 bits/sec, 0 packets/sec                          
    Input peak rate 11576 bits/sec,Record time: 2012-07-30 13:46:52                 
    Output peak rate 11576 bits/sec,Record time: 2012-07-30 13:46:52                
                                                                                    
    Input:  135403 packets, 118911125 bytes                                         
      Unicast:             107066,  Multicast:               10468                  
      Broadcast:            17869,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      CRC:                      0,  Giants:                      0                  
      Jabbers:                  0,  Throttles:                   0                  
      Runts:                    0,  Symbols:                     0                  
      Ignoreds:                 0,  Frames:                      0                  
                                                                                    
    Output:  59070 packets, 14217739 bytes                                          
      Unicast:              37581,  Multicast:               21485                  
      Broadcast:                4,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      Collisions:               0,  ExcessiveCollisions:         0                  
      Late Collisions:          0,  Deferreds:                   0                  
                                                                                    
        Input bandwidth utilization threshold : 100.00%                             
        Output bandwidth utilization threshold: 100.00%                             
        Input bandwidth utilization  : 0.01%                                        
        Output bandwidth utilization : 0.01%    

    比较执行命令ping -s 80 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet 1/0/0发送报文总数量增加了5,即RouterB接口GigabitEthernet 1/0/0在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.1.2。

    # 清空RouterB接口统计信息。

    <RouterB> reset counters interface gigabitethernet 1/0/0

    <RouterB> reset counters interface gigabitethernet 2/0/0

    # 查看RouterB接口统计信息。

    <RouterB> display interface gigabitethernet 1/0/0
    GigabitEthernet1/0/0 current state : UP                                         
    Line protocol current state : UP                                                
    Last line protocol up time : 2012-07-30 11:23:24                                
    Description:HUAWEI, AR Series, GigabitEthernet1/0/0 Interface                   
    Route Port,The Maximum Transmit Unit is 1500                                    
    Internet Address is 192.168.1.2/24                                                
    IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0819-a6ce-7d4c
    Last physical up time   : 2012-07-30 11:23:24                                   
    Last physical down time : 2012-07-24 16:54:19                                   
    Current system time: 2012-07-30 16:04:14                                        
    Port Mode: COMMON COPPER                                                        
    Speed : 1000,  Loopback: NONE                                                   
    Duplex: FULL,  Negotiation: ENABLE                                              
    Mdi   : AUTO                                                                    
    Last 300 seconds input rate 0 bits/sec, 0 packets/sec                           
    Last 300 seconds output rate 0 bits/sec, 0 packets/sec                          
    Input peak rate 7568 bits/sec,Record time: 2012-07-30 12:57:02                  
    Output peak rate 1008 bits/sec,Record time: 2012-07-30 12:42:42                 
                                                                                    
    Input:  135403 packets, 118911125 bytes                                         
      Unicast:             107066,  Multicast:               10468                  
      Broadcast:            17869,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      CRC:                      0,  Giants:                      0                  
      Jabbers:                  0,  Throttles:                   0                  
      Runts:                    0,  Symbols:                     0                  
      Ignoreds:                 0,  Frames:                      0                  
                                                                                    
    Output:  59070 packets, 14217739 bytes                                          
      Unicast:              37581,  Multicast:               21485                  
      Broadcast:                4,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      Collisions:               0,  ExcessiveCollisions:         0                  
      Late Collisions:          0,  Deferreds:                   0                  
                                                                                    
        Input bandwidth utilization threshold : 100.00%                             
        Output bandwidth utilization threshold: 100.00%                             
        Input bandwidth utilization  : 0.01%                                        
        Output bandwidth utilization : 0.01%    

    <RouterB> display interface gigabitethernet 2/0/0
    GigabitEthernet2/0/0 current state : UP                                         
    Line protocol current state : UP                                                
    Last line protocol up time : 2012-07-30 11:23:29                                
    Description:HUAWEI, AR Series, GigabitEthernet2/0/0 Interface                   
    Route Port,The Maximum Transmit Unit is 1500                                    
    Internet Address is 192.168.2.2/24                                                
    IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0819-a6ce-7d4d
    Last physical up time   : 2012-07-30 11:23:29                                   
    Last physical down time : 2012-07-30 11:09:17                                   
    Current system time: 2012-07-30 16:04:19                                        
    Port Mode: COMMON COPPER                                                        
    Speed : 1000,  Loopback: NONE                                                   
    Duplex: FULL,  Negotiation: ENABLE                                              
    Mdi   : AUTO                                                                    
    Last 300 seconds input rate 0 bits/sec, 0 packets/sec                           
    Last 300 seconds output rate 0 bits/sec, 0 packets/sec                          
    Input peak rate 11576 bits/sec,Record time: 2012-07-30 13:46:52                 
    Output peak rate 11576 bits/sec,Record time: 2012-07-30 13:46:52                
                                                                                    
    Input:  135403 packets, 118911125 bytes                                         
      Unicast:             107066,  Multicast:               10468                  
      Broadcast:            17869,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      CRC:                      0,  Giants:                      0                  
      Jabbers:                  0,  Throttles:                   0                  
      Runts:                    0,  Symbols:                     0                  
      Ignoreds:                 0,  Frames:                      0                  
                                                                                    
    Output:  59070 packets, 14217739 bytes                                          
      Unicast:              37581,  Multicast:               21485                  
      Broadcast:                4,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      Collisions:               0,  ExcessiveCollisions:         0                  
      Late Collisions:          0,  Deferreds:                   0                  
                                                                                    
        Input bandwidth utilization threshold : 100.00%                             
        Output bandwidth utilization threshold: 100.00%                             
        Input bandwidth utilization  : 0.01%                                        
        Output bandwidth utilization : 0.01%    

    # 在RouterA上Ping RouterB的Loopback0,并将报文数据字段长度设为1401字节。

    <RouterA> ping -s 1401 10.1.2.1

      PING 10.1.2.1: 1401  data bytes, press CTRL_C to break                        
        Reply from 10.1.2.1: bytes=1401 Sequence=1 ttl=255 time=1 ms                
        Reply from 10.1.2.1: bytes=1401 Sequence=2 ttl=255 time=1 ms                
        Reply from 10.1.2.1: bytes=1401 Sequence=3 ttl=255 time=1 ms                
        Reply from 10.1.2.1: bytes=1401 Sequence=4 ttl=255 time=1 ms                
        Reply from 10.1.2.1: bytes=1401 Sequence=5 ttl=255 time=2 ms                
                                                                                    
      --- 10.1.2.1 ping statistics ---                                              
        5 packet(s) transmitted                                                     
        5 packet(s) received                                                        
        0.00% packet loss                                                           
        round-trip min/avg/max = 1/1/2 ms

    # 查看RouterB接口统计信息。

    <RouterB> display interface gigabitethernet 1/0/0
    GigabitEthernet1/0/0 current state : UP                                         
    Line protocol current state : UP                                                
    Last line protocol up time : 2012-07-30 11:23:24                                
    Description:HUAWEI, AR Series, GigabitEthernet1/0/0 Interface                   
    Route Port,The Maximum Transmit Unit is 1500                                    
    Internet Address is 192.168.1.2/24                                                
    IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0819-a6ce-7d4c
    Last physical up time   : 2012-07-30 11:23:24                                   
    Last physical down time : 2012-07-24 16:54:19                                   
    Current system time: 2012-07-30 16:04:50                                        
    Port Mode: COMMON COPPER                                                        
    Speed : 1000,  Loopback: NONE                                                   
    Duplex: FULL,  Negotiation: ENABLE                                              
    Mdi   : AUTO                                                                    
    Last 300 seconds input rate 40 bits/sec, 0 packets/sec                          
    Last 300 seconds output rate 0 bits/sec, 0 packets/sec                          
    Input peak rate 7568 bits/sec,Record time: 2012-07-30 12:57:02                  
    Output peak rate 1008 bits/sec,Record time: 2012-07-30 12:42:42                 
                                                                                    
    Input:  135403 packets, 118911125 bytes                                         
      Unicast:             107066,  Multicast:               10468                  
      Broadcast:            17869,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      CRC:                      0,  Giants:                      0                  
      Jabbers:                  0,  Throttles:                   0                  
      Runts:                    0,  Symbols:                     0                  
      Ignoreds:                 0,  Frames:                      0                  
                                                                                    
    Output:  59070 packets, 14217739 bytes                                          
      Unicast:              37581,  Multicast:               21485                  
      Broadcast:                4,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      Collisions:               0,  ExcessiveCollisions:         0                  
      Late Collisions:          0,  Deferreds:                   0                  
                                                                                    
        Input bandwidth utilization threshold : 100.00%                             
        Output bandwidth utilization threshold: 100.00%                             
        Input bandwidth utilization  : 0.01%                                        
        Output bandwidth utilization : 0.01%    

    <RouterB> display interface gigabitethernet 2/0/0
    GigabitEthernet2/0/0 current state : UP                                         
    Line protocol current state : UP                                                
    Last line protocol up time : 2012-07-30 11:23:29                                
    Description:HUAWEI, AR Series, GigabitEthernet2/0/0 Interface                   
    Route Port,The Maximum Transmit Unit is 1500                                    
    Internet Address is 192.168.2.2/24                                                
    IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 0819-a6ce-7d4d
    Last physical up time   : 2012-07-30 11:23:29                                   
    Last physical down time : 2012-07-30 11:09:17                                   
    Current system time: 2012-07-30 16:04:55                                        
    Port Mode: COMMON COPPER                                                        
    Speed : 1000,  Loopback: NONE                                                   
    Duplex: FULL,  Negotiation: ENABLE                                              
    Mdi   : AUTO                                                                    
    Last 300 seconds input rate 200 bits/sec, 0 packets/sec                         
    Last 300 seconds output rate 192 bits/sec, 0 packets/sec                        
    Input peak rate 11576 bits/sec,Record time: 2012-07-30 13:46:52                 
    Output peak rate 11576 bits/sec,Record time: 2012-07-30 13:46:52                
                                                                                    
    Input:  135403 packets, 118911125 bytes                                         
      Unicast:             107066,  Multicast:               10468                  
      Broadcast:            17869,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      CRC:                      0,  Giants:                      0                  
      Jabbers:                  0,  Throttles:                   0                  
      Runts:                    0,  Symbols:                     0                  
      Ignoreds:                 0,  Frames:                      0                  
                                                                                    
    Output:  59070 packets, 14217739 bytes                                          
      Unicast:              37581,  Multicast:               21485                  
      Broadcast:                4,  Jumbo:                       0                  
      Discard:                  0,  Total Error:                 0                  
                                                                                    
      Collisions:               0,  ExcessiveCollisions:         0                  
      Late Collisions:          0,  Deferreds:                   0                  
                                                                                    
        Input bandwidth utilization threshold : 100.00%                             
        Output bandwidth utilization threshold: 100.00%                             
        Input bandwidth utilization  : 0.01%                                        
        Output bandwidth utilization : 0.01%    
    比较执行命令ping -s 1401 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet 2/0/0发送报文总数量增加了5,即RouterB接口GigabitEthernet 2/0/0在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.2.2。

配置文件
    RouterA的配置文件。
    #
     sysname RouterA
    #                                                                               
    interface GigabitEthernet1/0/0                                                  
     ip address 192.168.1.1 255.255.255.0   
    #                                                                               
    interface GigabitEthernet2/0/0                                                  
     ip address 192.168.2.1 255.255.255.0   
    #                                                                               
    interface LoopBack0                                                             
     ip address 10.1.1.1 255.255.255.0
    #                                                                               
     ip route-static 10.1.2.0 255.255.255.0 192.168.1.2                              
     ip route-static 10.1.2.0 255.255.255.0 192.168.2.2   
    #                                                                               
     policy-based-route lab1 permit node 10                                         
      if-match packet-length 64 1400                                                 
      apply ip-address next-hop 192.168.1.2                                           
     policy-based-route lab1 permit node 20                                         
      if-match packet-length 1401 1500                                              
      apply ip-address next-hop 192.168.2.2
    #                                                                               
     ip local policy-based-route lab1  

RouterB的配置文件。
    #
     sysname RouterB
    #                                                                               
    interface GigabitEthernet1/0/0                                                  
     ip address 192.168.1.2 255.255.255.0   
    #                                                                               
    interface GigabitEthernet2/0/0                                                  
     ip address 192.168.2.2 255.255.255.0   
    #                                                                               
    interface LoopBack0                                                             
     ip address 10.1.2.1 255.255.255.0
    #                                                                               
     ip route-static 10.1.1.0 255.255.255.0 192.168.1.1                              
     ip route-static 10.1.1.0 255.255.255.0 192.168.2.1  


PBR策略路由(列表、list、全)策略路由list、pbrlist
http://www.zh-cjh.com/wenzhangguilei/975.html
文章归类、所有文章列表、LISTLIST
http://www.zh-cjh.com/wangzhangonggao/2195.html

1、本站资源长期持续更新。
2、本资源基本为原创,部分来源其他付费资源平台或互联网收集,如有侵权请联系及时处理。
3、本站大部分文章的截图来源实验测试环境,请不要在生产环境中随意模仿,以免带来灾难性后果。

转载请保留出处:  www.zh-cjh.com珠海陈坚浩博客 » 华为路由器配置 本地策略路由 的基本功能示例(策略路由、PBR)

作者: cjh


手机扫一扫,手机上查看此文章:

一切源于价值!

其他 模板文件不存在: ./template/plugins/comment/pc/index.htm

未雨绸缪、居安思危!

数据安全、有备无患!

注意操作、数据无价!

一切源于价值!