帮助我们改善您的体验。

让我们了解您的想法。

您是否能抽出两分钟的时间完成一份问卷调查?

Announcement: Try the Ask AI chatbot for answers to your technical questions about Juniper products and solutions.

close
header-navigation
keyboard_arrow_up
close
keyboard_arrow_left
list Table of Contents
keyboard_arrow_right

机器翻译对您有帮助吗?

starstarstarstarstar
Go to English page
免责声明:

我们将使用第三方机器翻译软件翻译本页面。瞻博网络虽已做出相当大的努力提供高质量译文,但无法保证其准确性。如果对译文信息的准确性有任何疑问,请参阅英文版本. 可下载的 PDF 仅提供英文版.

配置 RPD 基础架构中路由前缀的优先级

date_range 18-Jan-25

前缀优先级可帮助用户确定某些路由或前缀的优先级,以实现更好的融合,并提供差异化的服务。在具有大量路由的网络中,由于网络拓扑的变化,控制路由的更新顺序有时非常重要。在系统级别,Junos OS 基于启发式方法实现合理的默认值,以确定路由的更新顺序。但是,默认行为并不总是最佳的。前缀优先级使用户能够控制路由从 LDP 或 OSPF 更新到 rpd 以及从 rpd 更新到内核的顺序。Junos OS 策略语言得到扩展,允许用户通过协议中的现有导入策略为前缀设置相对优先级(高和低)。根据标记的优先级,路由被放置在不同的优先级队列中。如果拓扑发生更改,将首先在路由表中更新高优先级前缀,然后更新低优先级前缀。在同一优先级内,路由将继续按字典顺序更新。未显式分配优先级的路由被视为中等优先级。

在开始在 rpd 中为 OSPF、LDP 和 BGP 等协议配置前缀优先级之前:

  • 配置路由器接口。

  • 配置 MPLS。

  • 配置 OSPF、BGP 和 LDP 协议。

要配置 OSPF 协议的优先级 high ,请执行以下操作:

  1. 配置策略术语。
    content_copy zoom_out_map
    [edit policy-options policy-statement policy-name]
    user@host# set term term-name
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement ospf-prio]
    user@host# set term t1
    
  2. 配置策略术语以接受来自 OSPF 的路由。
    content_copy zoom_out_map
    [edit policy-options policy-statement ospf-prio  term t1]
    user@host# set from protocol ospf
    
  3. 将所需路由指定为要为其设置优先级 high的匹配条件。
    content_copy zoom_out_map
    [edit policy-options policy-statement ospf-prio term t1]
    user@host# set from route-filter destination-prefix match-type
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement ospf-prio term t1]
    user@host# set from route-filter 172.16.25.3/32 exact
    
  4. 指定要接受的路由,如果与前面的条件匹配,则设置路由的优先级 high
    content_copy zoom_out_map
    [edit policy-options policy-statement ospf-prio term t1]
    user@host# set then priority high
    user@host# set then accept
    
  5. 验证配置。
    content_copy zoom_out_map
    [edit]
    user@host# show policy-options
    policy-statement ospf-prio {
        term t1 {
            from {
                route-filter 172.16.25.3/32 exact;
                }
            then {
                    priority high;
                    accept;
                    }
                }
        }
    

LDP 继承自 OSPF。

要配置 LDP 的优先级 high

  1. 配置从 OSPF 导入的策略术语。

    content_copy zoom_out_map
    [edit policy-options policy-statement policy-name]
    user@host# set term term-name
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement ospf-import]
    user@host# set term ospf_ldp
    
  2. 配置术语以接受来自 OSPF 的路由和优先级。

    content_copy zoom_out_map
    [edit policy-options policy-statement ospf_import term ospf_ldp]
    user@host# set from protocol ospf
    user@host# set from route-filter destination-prefix match-type
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement ospf_import term ospf_ldp]
    user@host# set from protocol ospf 
    user@host# set from route-filter 172.16.25.3/32 exact
    
  3. 验证配置。

    content_copy zoom_out_map
    [edit]
    user@host# show policy-options
    policy-statement ospf-import {
        term ospf_ldp {
            from {
                protocol ospf ;
                route-filter 172.16.25.3/32 exact;
                }
            then {
                    priority high;
                    accept;
                    }
                }
        }
    

要配置 BGP 协议的优先级 high ,请执行以下操作:

  1. 配置策略术语。

    content_copy zoom_out_map
    [edit policy-options policy-statement policy-name]
    user@host# set term term-name
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp]
    user@host# set term bgp_prio
    
  2. 将所需路由指定为匹配条件。

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp term bgp_prio]
    user@host# set from protocol bgp
    user@host# set from route-filter destination-prefix match-type
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp term bgp_prio]
    user@host# set from protocol bgp
    user@host# set from route-filter 172.16.50.1/32 exact
    
  3. 指定要接受的路由,如果与前面的条件匹配,则设置路由的优先级 high

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp term bgp_prio]
    user@host# set then priority high
    user@host# set then accept
    
  4. 验证配置。

    content_copy zoom_out_map
    policy-statement prio_for_bgp {
        term bgp_prio {
            from {
                protocol bgp;
                route-filter 172.16.50.1/32 exact;
                }
                    then {
                        priority high;
                        accept;
                        }
        }
    }
    
注:

对于 BGP,对于 L3VPN,您还可以根据路由识别符 (RD) 值配置优先级。例如,您可以使用路由识别符 51.51.51.51.51:111 配置 BGP 的优先级。

要根据路由识别符 (RD) 值配置 BGP 的优先级,请执行以下操作:

  1. 配置策略术语。

    content_copy zoom_out_map
    [edit policy-options policy-statement policy-name]
    user@host# set term term-name
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp]
    user@host# set term bgp_prio
    
  2. 将所需路由指定为匹配条件。

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp term bgp_prio]
    user@host# set from rib bgp.l3vpn.0
    user@host# set from route-filter destination-prefix match-type
    user@host# set from route-distinguisher route-distinguisher value
    

    例如:

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp term bgp_prio]
    user@host# set from rib bgp.l3vpn.0
    user@host# set from route-filter 172.16.1.1/32 exact
    user@host# set from route-distinguisher RD1
    
  3. 指定要接受的路由,如果与前面的条件匹配,则设置路由的优先级 high

    content_copy zoom_out_map
    [edit policy-options policy-statement prio-for-bgp term bgp_prio]
    user@host# set then priority high
    user@host# set then accept
    
  4. 验证配置。

    content_copy zoom_out_map
    policy-statement prio_for_bgp {
        term bgp_prio {
            from {
                protocol rib bgp.l3vpn.0;
                route-filter 172.16.1.1/32 exact;
                route-distinguisher RD1;
                }
                    then {
                        priority high;
                        accept;
                        }
        }
    }
    
注:

低优先级前缀仅安装在路由表中的高优先级前缀之后。您还可以为要设置为低优先级的路由配置优先级 low ,其优先级与优先级 high 类似。

注:

仅当路由从 RIB 推送到 FIB 时,才会应用优先级。因此,您无法修改已安装的路由的优先级。更改已安装路由的优先级没有意义。如果尝试更改已安装路由的优先级,则会显示输出差异:

content_copy zoom_out_map
user@R1> show route 172.16.25.3 extensive | match state
 State: <FlashAll>   
              State:   <Active Int HighPriority>     <=== OSPF                 
        Validation State: unverified
        State: <FlashAll>   
              State:   <Active Int>                  <=== LDP                 
        Validation State: unverified          
    

由于路由已安装在 FIB 中,因此 LDP 不会将优先级显示为高。

重新启动路由守护程序以移除路由并再次添加路由,从 OSPF 和 LDP 协议的角度来看,这反映了正确的优先级。

content_copy zoom_out_map
user@R1> restart routing
Routing protocols process signalled but still running, waiting 8 seconds more
Routing protocols process started, pid 4512

user@R1> show route 172.16.25.3 extensive |match state
 State: <FlashAll>   
              State:   <Active Int HighPriority>     <=== OSPF                 
        Validation State: unverified
        State: <FlashAll>   
              State:   <Active Int HighPriority>     <=== LDP                 
        Validation State: unverified          
    
footer-navigation