帮助我们改善您的体验。

让我们了解您的想法。

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

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 仅提供英文版.

示例:配置路由策略以向内部对等方播发最佳外部路由

date_range 18-Jan-25

RFC 1771 中定义的 BGP 协议规范规定,BGP 对等方应向其内部对等方播发更高优先级的外部路径,即使此路径不是总体最佳路径(换句话说,即使最佳路径是内部路径)。实际上,部署的 BGP 实现不遵循此规则。偏离规范的原因如下:

  • 最大限度地减少广告信息量。BGP 根据可用路径的数量进行扩展。

  • 避免路由和转发环路。

但是,在某些情况下,RFC 1771 中指定的播发最佳外部路由的行为可能是有益的。限制路径信息并不总是可取的,因为路径多样性可能有助于缩短恢复时间。通告最佳外部路径还可以解决内部 BGP (IBGP) 路由振荡问题,如 RFC 3345 边界 网关协议 (BGP) 持续路由振荡条件中所述。

advertise-external 语句修改了 BGP 说话方的行为,以向 IBGP 对等方播发最佳外部路径,即使最佳整体路径是内部路径也是如此。

注:

advertise-external 语句在组和邻居级别均受支持。如果在邻居级别配置语句,则必须为组中的所有邻居配置该语句。否则,该组将自动拆分为不同的组。

conditional 选项会限制设置的行为 advertise-external ,以便仅当路由选择过程到达评估多出口鉴别器 (MED) 指标的点时,才会播发外部路由。因此,如果外部路由的 AS 路径比活动路径更差(更长),则不会播发外部路由。该 conditional 选项将外部路径播发限制为最佳外部路径和活动路径相等,直到路由选择过程的 MED 步骤。请注意,无论是否配置了选项, conditional 用于选择最佳外部路径的条件都是相同的。

Junos OS 还支持配置与播发路由状态匹配的 BGP 导出策略。您可以匹配活动或非活动路由,如下所示:

content_copy zoom_out_map
policy-options {
    policy-statement name{
        from state (active|inactive);
    }
}

此限定符仅在导出策略上下文中使用时匹配。当路由由可以通告非活动路由的协议(如 BGP)播发时, state inactive 匹配由于 and advertise-inactiveadvertise-external 语句播发的路由。

例如,以下配置可用作对内部对等方的 BGP 导出策略,以标记由于用户定义的社区设置而 advertise-external 播发的路由。接收路由器稍后可以使用该社区从转发表中过滤掉此类路由。此类机制可用于解决发送方未用于转发的广告路径可能导致转发循环的问题。

content_copy zoom_out_map
user@host# show policy-options
policy-statement mark-inactive {
    term inactive {
        from state inactive;
        then {
            community set comm-inactive;
        }
    }
    term default {
        from protocol bgp;
        then accept;
    }
    then reject;
}
community comm-inactive members 65536:65284;

要求

需要 Junos OS 9.3 或更高版本。

概述

此示例显示了三个路由设备。设备 R2 具有到设备 R1 的外部 BGP (EBGP) 连接。设备 R2 与设备 R3 具有 IBGP 连接。

设备 R1 播发 172.16.6.0/24。设备 R2 不会在导入策略中为设备 R1 的路由设置本地首选项,因此 172.16.6.0/24 的默认本地首选项为 100。

设备 R3 播发 172.16.6.0/24,本地优先级为 200。

advertise-external如果未在设备 R2 上配置语句,则设备 R2 不会向设备 R3 通告 172.16.6.0/24。

在设备 R2 上朝向设备 R3 的会话上配置语句 advertise-external 时,设备 R2 将向设备 R3 通告 172.16.6.0/24。

advertise-external conditional 面向设备 R3 的会话上的设备 R2 上配置 时,设备 R2 不会向设备 R3 通告 172.16.6.0/24。如果移除 then local-preference 200 设备 R3 上的设置并添加 path-selection as-path-ignore 设备 R2 上的设置(从而使路径选择标准相等,直到路由选择过程的 MED 步骤),则设备 R2 将向设备 R3 播发 172.16.6.0/24。

注:

要在路由反射器上配置 advertise-external 语句,必须使用该语句禁用 no-client-reflect 群集内反射,并且客户端群集必须完全网状化以防止发送冗余路由通告。

将路由设备配置为集群的路由反射器时,如果路由反射器通告的路由是从具有相同集群标识符的内部对等方接收的,或者两个对等方均未配置集群标识符,则该路由反射器通告的路由被视为内部路由。从属于另一个集群(即具有不同集群标识符)的内部对等方接收的路由被视为外部路由。

拓扑学

图 1 显示了示例网络。

图 1: 用于通告外部的 BGP 拓扑用于通告外部的 BGP 拓扑

CLI 快速配置 显示了 中 图 1所有设备的配置。

#configuration148__policy-advertise-external-st本节介绍设备 R2 上的步骤。

配置

CLI 快速配置

要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit] 中。

设备 R1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 description to-R2
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30
set interfaces lo0 unit 0 family inet address 192.168.0.1/32
set protocols bgp group ext type external
set protocols bgp group ext export send-static
set protocols bgp group ext peer-as 200
set protocols bgp group ext neighbor 10.0.0.2
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 from route-filter 172.16.6.0/24 exact
set policy-options policy-statement send-static term 1 then accept
set policy-options policy-statement send-static term 2 then reject
set routing-options static route 172.16.6.0/24 reject
set routing-options router-id 192.168.0.1
set routing-options autonomous-system 100

设备 R2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 description to-R1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30
set interfaces fe-1/2/1 unit 0 description to-R3
set interfaces fe-1/2/1 unit 0 family inet address 10.0.0.5/30
set interfaces lo0 unit 0 family inet address 192.168.0.2/32
set protocols bgp group ext type external
set protocols bgp group ext peer-as 100
set protocols bgp group ext neighbor 10.0.0.1
set protocols bgp group int type internal
set protocols bgp group int local-address 192.168.0.2
set protocols bgp group int advertise-external
set protocols bgp group int neighbor 192.168.0.3
set protocols ospf area 0.0.0.0 interface fe-1/2/1.0
set protocols ospf area 0.0.0.0 interface lo0.0 passive
set routing-options router-id 192.168.0.2
set routing-options autonomous-system 200

设备 R3

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 6 family inet address 10.0.0.6/30
set interfaces lo0 unit 0 family inet address 192.168.0.3/32
set protocols bgp group int type internal
set protocols bgp group int local-address 192.168.0.3
set protocols bgp group int export send-static
set protocols bgp group int neighbor 192.168.0.2
set protocols ospf area 0.0.0.0 interface fe-1/2/0.6
set protocols ospf area 0.0.0.0 interface lo0.0 passive
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then local-preference 200
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 172.16.6.0/24 reject
set routing-options static route 0.0.0.0/0 next-hop 10.0.0.5
set routing-options autonomous-system 200

程序

分步过程

以下示例要求您在配置层次结构中导航各个级别。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器

要配置设备 R2:

  1. 配置设备接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R2# set fe-1/2/0 unit 0 description to-R1
    user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30
    user@R2# set fe-1/2/1 unit 0 description to-R3
    user@R2# set fe-1/2/1 unit 0 family inet address 10.0.0.5/30
    user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
    
  2. 配置 OSPF 或其他内部网关协议 (IGP)。

    content_copy zoom_out_map
    [edit protocols ospf area 0.0.0.0]
    user@R2# set interface fe-1/2/1.0
    user@R2# set interface lo0.0 passive
    
  3. 配置与设备 R1 的 EBGP 连接。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R2# set type external
    user@R2# set peer-as 100
    user@R2# set neighbor 10.0.0.1
    
  4. 配置与设备 R3 的 IBGP 连接。

    content_copy zoom_out_map
    [edit protocols bgp group int]
    user@R2# set type internal
    user@R2# set local-address 192.168.0.2
    user@R2# set neighbor 192.168.0.3
    
  5. 将该 advertise-external 语句添加到 IBGP 组对等会话。

    content_copy zoom_out_map
    [edit protocols bgp group int]
    user@R2# set advertise-external
    
  6. 配置自治系统 (AS) 编号和路由器 ID。

    content_copy zoom_out_map
    [edit routing-options ]
    user@R2# set router-id 192.168.0.2
    user@R2# set autonomous-system 200
    

结果

在配置模式下,输入 show interfacesshow protocolsshow policy-optionsshow routing-options 命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

content_copy zoom_out_map
user@R2# show interfaces
fe-1/2/0 {
    unit 0{
        description to-R1;
        family inet {
            address 10.0.0.2/30;
        }
    }
}
fe-1/2/1 {
    unit 0 {
        description to-R3;
        family inet {
            address 10.0.0.5/30;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.2/32;
        }
    }
}
content_copy zoom_out_map
user@R2# show protocols
bgp {
    group ext {
        type external;
        peer-as 100;
        neighbor 10.0.0.1;
    }
    group int {
        type internal;
        local-address 192.168.0.2;
        advertise-external;
        neighbor 192.168.0.3;
    }
}
ospf {
    area 0.0.0.0 {
        interface fe-1/2/1.0;
        interface lo0.0 {
            passive;
        }
    }
}
content_copy zoom_out_map
user@R2# show routing-options
router-id 192.168.0.2;
autonomous-system 200;

如果完成设备配置,请从配置模式输入 commit

验证

确认配置工作正常。

验证 BGP 活动路径

目的

在设备 R2 上,确保 172.16.6.0/24 前缀位于路由表中,并且具有预期的活动路径。

操作

content_copy zoom_out_map
user@R2> show route 172.16.6

inet.0: 8 destinations, 9 routes (8 active, 1 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

172.16.6.0/24      *[BGP/170] 00:00:07, localpref 200, from 192.168.0.3
                      AS path: I, validation-state: unverified
                    > to 10.0.0.6 via fe-1/2/1.0
                    [BGP/170] 03:23:03, localpref 100
                      AS path: 100 I, validation-state: unverified
                    > to 10.0.0.1 via fe-1/2/0.0

意义

设备 R2 从设备 R1 和设备 R3 接收 172.16.6.0/24 路由。来自设备 R3 的路由是活动路径,由星号 (*) 指定。活动路径具有最高的本地优先级。即使两个路由的本地优先级相等,来自设备 R3 的路由也会保持活动状态,因为它具有最短的 AS 路径。

验证外部路由通告

目的

在设备 R2 上,确保向设备 R3 播发 172.16.6.0/24 路由。

操作

content_copy zoom_out_map
user@R2> show route advertising-protocol bgp 192.168.0.3

inet.0: 8 destinations, 9 routes (8 active, 1 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
  172.16.6.0/24           10.0.0.1                     100        100 I

意义

设备 R2 正在向设备 R3 播发 172.16.6.0/24 路由。

验证设备 R3 上的路由

目的

确保 172.16.6.0/24 前缀位于设备 R3 的路由表中。

操作

content_copy zoom_out_map
user@R3> show route 172.16.6.0/24

inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

172.16.6.0/24      *[Static/5] 03:34:14
                      Reject
                    [BGP/170] 06:34:43, localpref 100, from 192.168.0.2
                      AS path: 100 I, validation-state: unverified
                    > to 10.0.0.5 via fe-1/2/0.6

意义

设备 R3 具有静态路由和 172.16.6.0/24 的 BGP 路由。

请注意,如果无法访问路由或无法解析下一跃点,则设备 R3 上的 BGP 路由将隐藏。为满足此要求,此示例在设备 R3 ()static route 0.0.0.0/0 next-hop 10.0.0.5 上包含一个静态默认路由。

试验条件选项

目的

了解该 conditional 选项在 BGP 路径选择算法上下文中的工作原理。

操作

  1. 在设备 R2 上,添加 conditional 选项。

    content_copy zoom_out_map
    [edit  protocols bgp group int]
    user@R2# set advertise-external conditional
    user@R2# commit
    
  2. 在设备 R2 上,检查 172.16.6.0/24 路由是否播发到设备 R3。

    content_copy zoom_out_map
    user@R2> show route advertising-protocol bgp 192.168.0.3
    
    

    正如预期的那样,该路由不再播发。您可能需要等待几秒钟才能看到此结果。

  3. 在设备 R3 上,停用 then local-preference 策略操作。

    content_copy zoom_out_map
    [edit policy-options policy-statement send-static term 1]
    user@R3# deactivate logical-systems R3 then local-preference 
    user@R3# commit
    
  4. 在设备 R2 上,确保两条路径的本地首选项相等。

    content_copy zoom_out_map
    user@R2> show route 172.16.6.0/24
    
    inet.0: 8 destinations, 9 routes (8 active, 0 holddown, 0 hidden)
    + = Active Route, - = Last Active, * = Both
    
    172.16.6.0/24      *[BGP/170] 08:02:59, localpref 100
                          AS path: 100 I, validation-state: unverified
                        > to 10.0.0.1 via fe-1/2/0.0
                        [BGP/170] 00:07:51, localpref 100, from 192.168.0.3
                          AS path: I, validation-state: unverified
                        > to 10.0.0.6 via fe-1/2/1.0
  5. 在设备 R2 上,添加 as-path-ignore 语句。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@R2# set path-selection as-path-ignore 
    user@R2# commit
    
  6. 在设备 R2 上,检查 172.16.6.0/24 路由是否播发到设备 R3。

    content_copy zoom_out_map
    user@R2> show route advertising-protocol bgp 192.168.0.3
    
    inet.0: 8 destinations, 9 routes (8 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 172.16.6.0/24           10.0.0.1                     100        100 I

    正如预期一样,路由现已播发,因为 AS 路径长度被忽略,并且本地优先级相等。

footer-navigation