帮助我们改善您的体验。

让我们了解您的想法。

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

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
BGP 用户指南
Table of Contents Expand all
list Table of Contents

机器翻译对您有帮助吗?

starstarstarstarstar
Go to English page
免责声明:

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

BGP 会话的自治系统

date_range 18-Jan-25

了解 BGP 本地 AS 属性

当互联网服务提供商 (ISP) 获取属于不同自治系统 (AS) 的网络时,无法将所获取网络的 BGP 对等方移动到获取 ISP 的 AS。使用新的 AS 编号配置 BGP 对等方的过程可能既耗时又繁琐。有时,客户不想或无法立即修改其对等安排或配置。在这种过渡期间,可以在新的 AS 中配置支持 BGP 的设备,以便在 BGP 更新中使用之前的 AS 编号。此以前的 AS 编号称为本地 AS。

使用本地 AS 编号让所获取网络中的路由设备看起来好像仍属于之前的 AS。

例如,AS 为 65200 的 ISP A 获取 AS 为 65250 的 ISP B。ISP B 有一个不想更改其配置的客户 ISP C。ISP B 成为 ISP A 的一部分后,将配置一个本地 AS 编号 65250,以便在与 ISP C 的 EBGP 对等会话中使用。因此,本地 AS 编号 65 250 要么前置在前面,要么用于代替 AS 路径中的全局 AS 编号 65200,用于将路由导出到 ISP C 中的直接外部对等方。

如果路由是从内部 BGP (IBGP) 对等方接收的,则 AS 路径将包含在全局 AS 编号之前附加的本地 AS 编号。

如果路由是外部路由(例如导入 BGP 的静态路由或内部网关协议 (IGP) 路由),则使用本地 AS 编号代替全局 AS 编号。如果路由是外部的,并且您希望将全局 AS 编号包含在 AS 路径中,则可以应用使用 as-path-expandas-path-prepend的路由策略。使用 as-path-expand 策略操作将全局 AS 编号置于本地 AS 编号之后。使用 as-path-prepend 策略操作将全局 AS 编号置于本地 AS 编号前面。

例如:

content_copy zoom_out_map
user@R2# show policy-options
policy-statement prepend-global {
    term 1 {
        from protocol static;
        then {
            as-path-prepend 65200; # or use as-path-expand
            accept;
        }
    }
}
content_copy zoom_out_map
user@R2# show protocols bgp  
group ext {
    export prepend-global;
    type external;
    local-as 65250;
    neighbor 10.0.0.1 {
        peer-as 65100;
    }
    neighbor 10.1.0.2 {
        peer-as 65300;
    }
}
content_copy zoom_out_map
user@R2# show routing-options
static {
    route 10.1.1.1/32 next-hop 10.0.0.1;
}
autonomous-system 65200;
content_copy zoom_out_map
user@R3# run show route 10.1.1.1 protocol bgp
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.1.1.1/32         *[BGP/170] 00:05:11, localpref 100
                      AS path: 65200 65250 I, validation-state: unverified
                    > to 10.1.0.1 via lt-1/2/0.4

在第 3 层 VPN 场景中,提供商边缘 (PE) 设备使用外部 BGP (EBGP) 与客户边缘 (CE) 设备对等,语句 local-as 的行为与非 VPN 场景中的行为不同。在 VPN 场景中,默认情况下,在主实例中定义的全局 AS 编号会前置到 AS 路径。要覆盖此行为,可以在 PE 设备上配置 no-prepend-global-as 路由实例 BGP 配置,如下所示:

content_copy zoom_out_map
user@R2# show routing-instances
red {
    instance-type vrf;
    interface fe-1/2/0.2;
    route-distinguisher 10:1;
    vrf-target target:10:1;
    protocols {
        bgp {
            group toR1 {
                type external;
                peer-as 65001;
                local-as 65200 no-prepend-global-as;
                neighbor 10.1.1.1;
            }
        }
    }
}

本地 AS 属性的 Junos 操作系统 (Junos OS) 实现支持以下选项:

  • Local AS with private option— 使用该 private 选项时,将在与 EBGP 邻接方建立 BGP 会话期间使用本地 AS,但在发送至其他 IBGP 和 EBGP 对等方的 AS 路径中会隐藏本地 AS。发送至外部对等方的 AS 路径中仅包含全局 AS。

    private 选项可用于与仍配置了其先前 AS 的路由设备建立本地对等关系,或者与尚未修改其对等方安排的特定客户建立对等关系。本地 AS 用于建立与 EBGP 邻接方的 BGP 会话,但隐藏在发送到另一个 AS 中的外部对等方的 AS 路径中。

    包括该 private 选项,以便在发送给外部对等方的 AS 路径中,本地 AS 不会在全局 AS 之前附加。指定该 private 选项时,本地 AS 只会前置在发送到 EBGP 邻接方的 AS 路径中。

    例如,在 中 图 1,路由器 1 和路由器 2 在 AS 64496 中,路由器 4 在 AS 64511 中,路由器 3 在 AS 64510 中。路由器 2 之前属于 AS 64497,后者已与其他网络合并,现在属于 AS 64496。由于路由器 3 仍然使用其以前的 AS (64497) 与路由器 2 对等,因此路由器 2 需要配置本地 AS 64497,以便与路由器 3 保持对等。配置本地 AS 64497 将允许路由器 2 在向路由器 3 播发路由时添加 AS 64497。路由器 3 看到前缀 10/8 的 AS 路径为 64497 64496。

    图 1: 本地 AS 配置本地 AS 配置

    要防止路由器 2 在向其他对等方的公告中添加本地 AS 编号,请使用 local-as 64497 private 该语句。此语句将路由器 2 配置为在向路由器 1 和路由器 4 通告路由时不包含本地 AS 64497。在这种情况下,路由器 4 会看到前缀 10.222/16 的 AS 路径为 64496 64510。

  • Local AS with alias option— 在 Junos OS 9.5 及更高版本中,您可以将本地 AS 配置为别名。在建立 BGP 开放式会话期间,开放式消息中使用的 AS 在本地 AS 和全局 AS 之间交替。如果使用本地 AS 与 EBGP 邻接方连接,则在建立 BGP 对等会话时,只会将本地 AS 前置到 AS 路径。如果使用全局 AS 与 EBGP 邻接方连接,则在建立 BGP 对等会话时,只会将全局 AS 前置到 AS 路径。使用该 alias 选项还意味着,对于从该 EBGP 邻接方获知的任何路由,本地 AS 不会前置到 AS 路径中。因此,本地 AS 对其他外部对等方保持隐藏。

    将已获取网络中的路由设备迁移到新 AS 时,使用该 alias 选项配置本地 AS 特别有用。在迁移过程中,某些路由设备可能配置了新的 AS,而其他设备仍配置之前的 AS。例如,最好先迁移到新的 AS,其中有路由设备充当路由反射器。但是,当您以增量方式迁移路由反射器客户端时,每个路由反射器必须与配置了旧 AS 的路由设备对等,并与配置了新 AS 的路由设备对等。要建立本地对等会话,网络中的 BGP 对等方同时使用本地 AS 和全局 AS 会很有用。同时,您希望对外部对等方隐藏此本地 AS,并在将路由导出到其他 AS 时,仅在 AS 路径中使用全局 AS。在这种情况下,请配置该 alias 选项。

    包括将 alias 本地 AS 配置为在层次结构级别配置 [edit routing-options] 的全局 AS 的别名的选项。将本地 AS 配置为别名时,在建立 BGP 开放式会话期间,开放式消息中使用的 AS 在本地 AS 和全局 AS 之间交替。仅当使用该本地 AS 与 EBGP 邻接方建立对等会话时,才会将本地 AS 前置到 AS 路径。在发送至任何其他外部对等方的 AS 路径中,本地 AS 将会隐藏。当使用全局 AS 建立 BGP 会话时,仅将全局 AS 前置到 AS 路径。

    注:

    privatealias选项是互斥的。不能使用相同的语句配置 local-as 这两个选项。

  • Local AS with option not to prepend the global AS—在 Junos OS 9.6 及更高版本中,您可以配置本地 AS,并提供不前置全局 AS 的选项。在发送至外部对等方的 AS 路径中仅包含本地 AS。

    no-prepend-global-as如果要在虚拟专用网络 (VPN) 方案中从出站 BGP 更新中删除全局 AS 编号,请使用该选项。在 VPN 场景中,当您想对 VPN 隐藏全局 AS 时,此选项很有用。

    包括以下选项以 no-prepend-global-as 从发送到外部对等方的 AS 路径中删除在层次结构级别配置 [edit routing-options] 的全局 AS。使用此选项时,对于发送至客户边缘 (CE) 设备的路由,AS 路径中仅包含本地 AS。

  • Number of loops option— 本地 AS 功能还支持指定在 AS_PATH 属性中检测到 AS 编号导致路由被丢弃或隐藏的次数。例如,如果配置 loops 1,则当在路径中检测到 AS 编号一次或多次时,路由将被隐藏。这是默认行为。如果配置 loops 2,则当在路径中检测到 AS 编号两次或两次以上时,路由将被隐藏。

    loops number对于语句,您可以配置 1 到 10。

    注:

    如果为任何 BGP 组配置本地 AS 值,则将使用所有 BGP 组的 AS 值和本地 AS 值来检测路由环路。

    如果 EBGP 或 IBGP 对等方的本地 AS 与当前 AS 相同,则不要使用该 local-as 语句指定本地 AS 编号。

    在 VRF 中配置本地 AS 时,这会影响 AS 路径环路检测机制。local-as设备上配置的所有语句都是单个 AS 域的一部分。AS 路径环路检测机制基于寻找域中存在的匹配 AS。

示例:为 EBGP 会话配置本地 AS

此示例说明了如何为 BGP 对等方配置本地自治系统 (AS),以便在 BGP 入站和出站更新中使用全局 AS 和本地 AS。

要求

在配置此示例之前,不需要除设备初始化之外的特殊配置。

概述

当 ISP 合并并希望保留客户的配置时,特别是客户配置为与之建立对等关系的 AS,请使用该 local-as 语句。该 local-as 语句模拟客户路由器中已有的 AS 编号,即使 ISP 的路由器已移动到其他 AS 也是如此。

此示例说明如何使用语句配置 local-as 本地 AS。该 local-as 语句在全局、组和邻居层次结构级别支持 BGP。

配置 local-as 语句时,必须指定 AS 编号。可以指定纯数字格式的 1 到 4,294,967,295 之间的数字。在 Junos OS 9.1 及更高版本中,AS 编号的范围得到了扩展,可为 4 字节 AS 编号提供 BGP 支持,如 RFC 4893“四 字节 AS 编号空间的 BGP 支持”中定义。在 Junos OS 9.3 版及更高版本中,您还可以使用 AS 点符号格式(两个整数值加一个句点)配置 4 字节 AS 编号:<16-bit high-order value in decimal>.<16-bit low-order value in decimal>. 例如,以纯数字格式表示的 4 字节 AS 编号 65,546 在 AS 点符号格式中表示为 1.10。可以 AS 点表示法格式指定一个介于 0.0 到 65535.65535 之间的值。Junos OS 继续支持 2 字节 AS 编号。2 字节 AS 编号范围为 1 到 65535(这是 4 字节范围的一个子集)。

图 2 显示了示例拓扑。

图 2: 用于配置本地 AS 的拓扑用于配置本地 AS 的拓扑

在此示例中,设备 R2 原来属于 AS 250,现在属于 AS 200。设备 R1 和设备 R3 配置为与 AS 250 对等,而非与新的 AS 编号 (AS 200) 对等。设备 R2 具有使用该语句配置 autonomous-system 200 的新 AS 编号。要使对等会话正常工作,将在 BGP 配置中添加该 local-as 250 语句。由于已配置,设备 local-as 250 R2 在其 BGP 入站和出站更新中包括全局 AS (200) 和本地 AS (250)。

配置

CLI 快速配置

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

设备 R1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.1/30
set interfaces lo0 unit 1 family inet address 192.168.0.1/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext peer-as 250
set protocols bgp group ext neighbor 10.0.0.2
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 10.1.0.0/30 next-hop 10.0.0.2
set routing-options autonomous-system 100

设备 R2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 2 family inet address 10.0.0.2/30
set interfaces fe-1/2/1 unit 3 family inet address 10.1.0.1/30
set interfaces lo0 unit 2 family inet address 192.168.0.2/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext local-as 250
set protocols bgp group ext neighbor 10.0.0.1 peer-as 100
set protocols bgp group ext neighbor 10.1.0.2 peer-as 300
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options autonomous-system 200

设备 R3

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 4 family inet address 10.1.0.2/30
set interfaces lo0 unit 3 family inet address 192.168.0.3/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext peer-as 250
set protocols bgp group ext neighbor 10.1.0.1
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 10.0.0.0/30 next-hop 10.1.0.1
set routing-options autonomous-system 300

配置设备 R1

分步过程

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

要配置设备 R1:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set fe-1/2/0 unit 1 family inet address 10.0.0.1/30
    user@R1# set lo0 unit 1 family inet address 192.168.0.1/32
    
  2. 配置外部 BGP (EBGP)。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R1# set type external
    user@R1# set export send-direct
    user@R1# set export send-static
    user@R1# set peer-as 250
    user@R1# set neighbor 10.0.0.2
    
  3. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@R1# set policy-statement send-direct term 1 from protocol direct
    user@R1# set policy-statement send-direct term 1 then accept
    user@R1# set policy-statement send-static term 1 from protocol static
    user@R1# set policy-statement send-static term 1 then accept
    
  4. 配置设备 R2 和设备 R3 之间远程网络的静态路由。

    content_copy zoom_out_map
    [edit routing-options]
    user@R1# set static route 10.1.0.0/30 next-hop 10.0.0.2
    
  5. 配置全局 AS 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@R1# set autonomous-system 100
    
结果

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

content_copy zoom_out_map
user@R1# show interfaces
fe-1/2/0 {
    unit 1 {
        family inet {
            address 10.0.0.1/30;
        }
    }
}
lo0 {
    unit 1 {
        family inet {
            address 192.168.0.1/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
policy-statement send-static {
    term 1 {
        from protocol static;
        then accept;
    }
}
content_copy zoom_out_map
user@R1# show protocols
bgp {
    group ext {
        type external;
        export [ send-direct send-static ];
        peer-as 250;
        neighbor 10.0.0.2;
    }
}
content_copy zoom_out_map
user@R1# show routing-options
static {
    route 10.1.0.0/30 next-hop 10.0.0.2;
}
autonomous-system 100;

完成设备配置后,从配置模式输入 commit

配置设备 R2

分步过程

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

要配置设备 R2:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R2# set fe-1/2/0 unit 2 family inet address 10.0.0.2/30
    user@R2# set fe-1/2/1 unit 3 family inet address 10.1.0.1/30
    user@R2# set lo0 unit 2 family inet address 192.168.0.2/32
    
  2. 配置 EBGP。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R2# set type external
    user@R2# set export send-direct
    user@R2# set export send-static
    user@R2# set neighbor 10.0.0.1 peer-as 100
    user@R2# set neighbor 10.1.0.2 peer-as 300
    
  3. 配置本地自治系统 (AS) 编号。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R2# set local-as 250
    
  4. 配置全局 AS 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@R2# set autonomous-system 200
    
  5. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@R2# set policy-statement send-direct term 1 from protocol direct
    user@R2# set policy-statement send-direct term 1 then accept
    user@R2# set policy-statement send-static term 1 from protocol static
    user@R2# set policy-statement send-static term 1 then accept
    
结果

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

content_copy zoom_out_map
user@R2# show interfaces
fe-1/2/0 {
    unit 2 {
        family inet {
            address 10.0.0.2/30;
        }
    }
}
fe-1/2/1 {
    unit 3 {
        family inet {
            address 10.1.0.1/30;
        }
    }
}
lo0 {
    unit 2 {
        family inet {
            address 192.168.0.2/32;
        }
    }
}
content_copy zoom_out_map
user@R2# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
policy-statement send-static {
    term 1 {
        from protocol static;
        then accept;
    }
}
content_copy zoom_out_map
user@R2# show protocols
bgp {
    group ext {
        type external;
        export [ send-direct send-static ];
        local-as 250;
        neighbor 10.0.0.1 {
            peer-as 100;
        }
        neighbor 10.1.0.2 {
            peer-as 300;
        }
    }
}
content_copy zoom_out_map
user@R2# show routing-options
autonomous-system 200;

完成设备配置后,从配置模式输入 commit

配置设备 R3

分步过程

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

要配置设备 R3:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R3# set fe-1/2/0 unit 4 family inet address 10.1.0.2/30
    user@R3# set lo0 unit 3 family inet address 192.168.0.3/32
    
  2. 配置 EBGP。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R3# set type external
    user@R3# set export send-direct
    user@R3# set export send-static
    user@R3# set peer-as 250
    user@R3# set neighbor 10.1.0.1
    
  3. 配置全局自治系统 (AS) 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@R3# set autonomous-system 300
    
  4. 配置设备 R1 和设备 R2 之间远程网络的静态路由。

    content_copy zoom_out_map
    [edit routing-options]
    user@R3# set static route 10.0.0.0/30 next-hop 10.1.0.1
    
  5. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@R3# set policy-statement send-direct term 1 from protocol direct
    user@R3# set policy-statement send-direct term 1 then accept
    user@R3# set policy-statement send-static term 1 from protocol static
    user@R3# set policy-statement send-static term 1 then accept
    
结果

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

content_copy zoom_out_map
user@R3# show interfaces
fe-1/2/0 {
    unit 4 {
        family inet {
            address 10.1.0.2/30;
        }
    }
}
lo0 {
    unit 3 {
        family inet {
            address 192.168.0.3/32;
        }
    }
}
content_copy zoom_out_map
user@R3# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
policy-statement send-static {
    term 1 {
        from protocol static;
        then accept;
    }
}
content_copy zoom_out_map
user@R3# show protocols
bgp {
    group ext {
        type external;
        export [ send-direct send-static ];
        peer-as 250;
        neighbor 10.1.0.1;
    }
}
content_copy zoom_out_map
user@R3# show routing-options
static {
    route 10.0.0.0/30 next-hop 10.1.0.1;
}
autonomous-system 300;

完成设备配置后,从配置模式输入 commit

验证

确认配置工作正常。

检查本地和全局 AS 设置

目的

确保设备 R2 已配置本地和全局 AS 设置。

操作

在操作模式下,输入 show bgp neighbors 命令。

content_copy zoom_out_map
user@R2> show bgp neighbors
Peer: 10.0.0.1+179 AS 100      Local: 10.0.0.2+61036 AS 250  
  Type: External    State: Established    Flags: <Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ send-direct send-static ] 
  Options: <Preference PeerAS LocalAS Refresh>
  Holdtime: 90 Preference: 170 Local AS: 250 Local System AS: 200
  Number of flaps: 0
  Peer ID: 192.168.0.1     Local ID: 192.168.0.2       Active Holdtime: 90
  Keepalive Interval: 30         Peer index: 0   
  BFD: disabled, down
  Local Interface: fe-1/2/0.2                       
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Stale routes from peer are kept for: 300
  Peer does not support Restarter functionality
  NLRI that restart is negotiated for: inet-unicast
  NLRI of received end-of-rib markers: inet-unicast
  NLRI of all end-of-rib markers sent: inet-unicast
  Peer supports 4 byte AS extension (peer-as 100)
  Peer does not support Addpath
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              1
    Received prefixes:            3
    Accepted prefixes:            2
    Suppressed due to damping:    0
    Advertised prefixes:          4
  Last traffic (seconds): Received 6    Sent 14   Checked 47  
  Input messages:  Total 258    Updates 3       Refreshes 0     Octets 4969
  Output messages: Total 258    Updates 2       Refreshes 0     Octets 5037
  Output Queue[0]: 0

Peer: 10.1.0.2+179 AS 300      Local: 10.1.0.1+52296 AS 250  
  Type: External    State: Established    Flags: <Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ send-direct send-static ] 
  Options: <Preference PeerAS LocalAS Refresh>
  Holdtime: 90 Preference: 170 Local AS: 250 Local System AS: 200
  Number of flaps: 0
  Peer ID: 192.168.0.3     Local ID: 192.168.0.2       Active Holdtime: 90
  Keepalive Interval: 30         Peer index: 1   
  BFD: disabled, down
  Local Interface: fe-1/2/1.3                       
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Stale routes from peer are kept for: 300
  Peer does not support Restarter functionality
  NLRI that restart is negotiated for: inet-unicast
  NLRI of received end-of-rib markers: inet-unicast
  NLRI of all end-of-rib markers sent: inet-unicast
  Peer supports 4 byte AS extension (peer-as 300)
  Peer does not support Addpath
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              1
    Received prefixes:            3
    Accepted prefixes:            2
    Suppressed due to damping:    0
    Advertised prefixes:          4
  Last traffic (seconds): Received 19   Sent 26   Checked 9   
  Input messages:  Total 256    Updates 3       Refreshes 0     Octets 4931
  Output messages: Total 256    Updates 2       Refreshes 0     Octets 4999
  Output Queue[0]: 0
意义

本地 AS:250 和本地系统 AS:200 输出显示设备 R2 具有预期的设置。此外,输出显示选项列表包括 LocalAS。

检查 BGP 对等会话

目的

确保已建立会话并显示本地 AS 编号 250。

操作

在操作模式下,输入 show bgp summary 命令。

content_copy zoom_out_map
user@R1> show bgp summary
Groups: 1 Peers: 1 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                 4          2          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...
10.0.0.2                250        232        233       0       4     1:42:37 2/4/4/0              0/0/0/0
content_copy zoom_out_map
user@R3> show bgp summary
Groups: 1 Peers: 1 Down peers: 0
Table          Tot Paths  Act Paths Suppressed    History Damp State    Pending
inet.0                 4          2          0          0          0          0
Peer                     AS      InPkt     OutPkt    OutQ   Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...
10.1.0.1                250        235        236       0       4     1:44:25 2/4/4/0              0/0/0/0
意义

设备 R1 和设备 R3 似乎与 AS 250 中的设备对等,即使设备 R2 实际上在 AS 200 中。

验证 BGP AS 路径

目的

请确保路由在路由表中,且 AS 路径显示本地 AS 编号 250。

操作

从配置模式,输入 set route protocol bgp 命令。

content_copy zoom_out_map
user@R1> show route protocol bgp
inet.0: 6 destinations, 8 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.0.0/30         [BGP/170] 01:46:44, localpref 100
                      AS path: 250 I
                    > to 10.0.0.2 via fe-1/2/0.1
10.1.0.0/30         [BGP/170] 01:46:44, localpref 100
                      AS path: 250 I
                    > to 10.0.0.2 via fe-1/2/0.1
192.168.0.2/32     *[BGP/170] 01:46:44, localpref 100
                      AS path: 250 I
                    > to 10.0.0.2 via fe-1/2/0.1
192.168.0.3/32     *[BGP/170] 01:46:40, localpref 100
                      AS path: 250 300 I
                    > to 10.0.0.2 via fe-1/2/0.1
content_copy zoom_out_map
user@R3> show route protocol bgp

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

10.0.0.0/30         [BGP/170] 01:47:10, localpref 100
                      AS path: 250 I
                    > to 10.1.0.1 via fe-1/2/0.4
10.1.0.0/30         [BGP/170] 01:47:10, localpref 100
                      AS path: 250 I
                    > to 10.1.0.1 via fe-1/2/0.4
192.168.0.1/32     *[BGP/170] 01:47:10, localpref 100
                      AS path: 250 100 I
                    > to 10.1.0.1 via fe-1/2/0.4
192.168.0.2/32     *[BGP/170] 01:47:10, localpref 100
                      AS path: 250 I
                    > to 10.1.0.1 via fe-1/2/0.4
意义

输出显示设备 R1 和设备 R3 的路由似乎包括了含有 AS 250 的 AS 路径,尽管设备 R2 实际处于 AS 200 中。

示例:为 EBGP 会话配置本地专用 AS

此示例说明了如何配置专用本地自治系统 (AS) 编号。本地 AS 被视为专用的,因为它会播发给使用本地 AS 编号进行对等的对等方,但在向可以使用全局 AS 编号进行对等的对等方的公告中隐藏。

要求

在配置此示例之前,不需要除设备初始化之外的特殊配置。

概述

当 ISP 合并并希望保留客户的配置时,特别是客户配置为与之建立对等关系的 AS,请使用该 local-as 语句。该 local-as 语句模拟客户路由器中已有的 AS 编号,即使 ISP 的路由器已移动到其他 AS 也是如此。

使用该 private 选项时,将在与外部 BGP (EBGP) 邻接方建立 BGP 会话期间使用本地 AS,但会在发送至其他 EBGP 对等方的 AS 路径中隐藏本地 AS。发送至外部对等方的 AS 路径中仅包含全局 AS。

private 选项可用于与仍配置了其先前 AS 的路由设备建立本地对等关系,或者与尚未修改其对等方安排的特定客户建立对等关系。本地 AS 用于建立与 EBGP 邻接方的 BGP 会话,但会在发送至其他 AS 中外部对等方的 AS 路径中隐藏。

包括该 private 选项,以便在发送给外部对等方的 AS 路径中,本地 AS 不会在全局 AS 之前附加。指定该 private 选项时,本地 AS 只会前置在发送到 EBGP 邻接方的 AS 路径中。

图 3 显示了示例拓扑。

图 3: 用于配置专用本地 AS 的拓扑用于配置专用本地 AS 的拓扑

设备 R1 在 AS 64496 中。设备 R2 在 AS 64510 中。设备 R3 在 AS 64511 中。设备 R4 在 AS 64512 中。设备 R1 之前属于 AS 64497,后者已与其他网络合并,现在属于 AS 64496。由于设备 R3 仍然与设备 R1(使用其之前的 AS 64497)对等,因此设备 R1 需要配置编号为 64497 的本地 AS,以便与设备 R3 保持对等。配置本地 AS 64497 将允许设备 R1 在向设备 R3 播发路由时添加 AS 64497。设备 R3 看到:前缀 10.1.1.2/32 的 AS 路径为 64497 64496,即设备 R2 的环路接口。设备 R4(位于设备 R3 后面)看到到 设备 R2 环路接口的 AS 路径为 64511 64497 64496 64510。为防止设备 R1 在向其他对等方的公告中添加本地 AS 编号,此示例包含该 local-as 64497 private 语句。该 private 选项将设备 R1 配置为在向设备 R2 通告路由时不包含本地 AS 64497。设备 R2 看到:到设备 R3 的 AS 路径为 64496 64511 ,到设备 R4 的 AS 路径为 64496 64511 64512。private设备 R1 配置中的选项会导致设备 R1 重新播发到设备 R2 的 AS 路径中缺少 AS 编号 64497。

设备 R1 对所有路由器隐藏专用本地 AS,设备 R3 除外。该 private 选项适用于设备 R1 从设备 R3 接收(学习)的路由,而设备 R1 又会重新播发到其他路由器。当设备 R1 向设备 R2 重新播发从设备 R3 获知的这些路由时,向设备 R2 播发的 AS 路径中没有专用本地 AS。

配置

CLI 快速配置

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

设备 R1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 3 family inet address 192.168.1.1/24
set interfaces fe-1/2/1 unit 5 family inet address 192.168.10.1/24
set interfaces lo0 unit 2 family inet address 10.1.1.1/32
set protocols bgp group external-AS64511 type external
set protocols bgp group external-AS64511 peer-as 64511
set protocols bgp group external-AS64511 local-as 64497
set protocols bgp group external-AS64511 local-as private
set protocols bgp group external-AS64511 neighbor 192.168.1.2
set protocols bgp group external-AS64510 type external
set protocols bgp group external-AS64510 peer-as 64510
set protocols bgp group external-AS64510 neighbor 192.168.10.2
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64496

设备 R2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 6 family inet address 192.168.10.2/24
set interfaces lo0 unit 3 family inet address 10.1.1.2/32
set protocols bgp group external type external
set protocols bgp group external export send-direct
set protocols bgp group external peer-as 64496
set protocols bgp group external neighbor 192.168.10.1
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64510

设备 R3

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 4 family inet address 192.168.1.2/24
set interfaces fe-1/2/1 unit 7 family inet address 192.168.5.1/24
set interfaces lo0 unit 4 family inet address 10.1.1.3/32
set protocols bgp group external type external
set protocols bgp group external export send-direct
set protocols bgp group external neighbor 192.168.1.1 peer-as 64497
set protocols bgp group external neighbor 192.168.5.2 peer-as 64512
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64511

设备 R4

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 8 family inet address 192.168.5.2/24
set interfaces lo0 unit 5 family inet address 10.1.1.4/32
set protocols bgp group external type external
set protocols bgp group external export send-direct
set protocols bgp group external peer-as 64511
set protocols bgp group external neighbor 192.168.5.1
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64512

配置设备 R1

分步过程

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

要配置设备 R1:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces fe-1/2/0 unit 3]
    user@R1# set family inet address 192.168.1.1/24
    [edit interfaces fe-1/2/1 unit 5]
    user@R1# set family inet address 192.168.10.1/24
    [edit interfaces lo0 unit 2]
    user@R1# set family inet address 10.1.1.1/32
    
  2. 配置与设备 R2 的 EBGP 对等会话。

    content_copy zoom_out_map
    [edit protocols bgp group external-AS64510]
    user@R1# set type external
    user@R1# set peer-as 64510
    user@R1# set neighbor 192.168.10.2
    
  3. 配置与设备 R3 的 EBGP 对等会话。

    content_copy zoom_out_map
    [edit protocols bgp group external-AS64511]
    user@R1# set type external
    user@R1# set peer-as 64511
    user@R1# set local-as 64497
    user@R1# set local-as private
    user@R1# set neighbor 192.168.1.2
    
  4. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement send-direct term 1]
    user@R1# set from protocol direct
    user@R1# set then accept
    
  5. 配置全局自治系统 (AS) 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@R1# set autonomous-system 64496
    
结果

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

content_copy zoom_out_map
user@R1# show interfaces
fe-1/2/0 {
    unit 3 {
        family inet {
            address 192.168.1.1/24;
        }
    }
}
fe-1/2/1 {
    unit 5 {
        family inet {
            address 192.168.10.1/24;
        }
    }
}
lo0 {
    unit 2 {
        family inet {
            address 10.1.1.1/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
content_copy zoom_out_map
user@R1# show protocols
bgp {
    group external-AS64511 {
        type external;
        peer-as 64511;
        local-as 64497 private;
        neighbor 192.168.1.2;
    }
    group external-AS64510 {
        type external;
        peer-as 64510;
        neighbor 192.168.10.2;
    }
}
content_copy zoom_out_map
user@R1# show routing-options
autonomous-system 64496;

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

根据需要对拓扑中的其他设备重复配置。

验证

确认配置工作正常。

检查设备 R2 的 AS 路径

目的

确保设备 R2 在到设备 R3 和设备 R4 的 AS 路径中没有 AS 64497。

操作

在操作模式下,输入 show route protocol bgp 命令。

content_copy zoom_out_map
user@R2> show route protocol bgp
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.1.1.3/32        *[BGP/170] 01:33:11, localpref 100
                      AS path: 64496 64511 I
                    > to 192.168.10.1 via fe-1/2/0.6
10.1.1.4/32        *[BGP/170] 01:33:11, localpref 100
                      AS path: 64496 64511 64512 I
                    > to 192.168.10.1 via fe-1/2/0.6
192.168.5.0/24     *[BGP/170] 01:49:15, localpref 100
                      AS path: 64496 64511 I
                    > to 192.168.10.1 via fe-1/2/0.6
意义

设备 R2 的 AS 路径不包括 AS 64497。

检查设备 R3 的 AS 路径

目的

确保本地 AS 64497 仅在发送到 EBGP 邻接方 R3 的 AS 路径中附加。设备 R3 看到:前缀 10.1.1.2/32 的 AS 路径为 64497 64496,即设备 R2 的环路接口。

操作

在操作模式下,输入 show route protocol bgp 命令。

content_copy zoom_out_map
user@R3> show route protocol bgp
inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.1.1.2/32        *[BGP/170] 01:35:11, localpref 100
                      AS path: 64497 64496 64510 I
                    > to 192.168.1.1 via fe-1/2/0.4
10.1.1.4/32        *[BGP/170] 01:35:11, localpref 100
                      AS path: 64512 I
                    > to 192.168.5.2 via fe-1/2/1.7
192.168.5.0/24      [BGP/170] 01:51:15, localpref 100
                      AS path: 64512 I
                    > to 192.168.5.2 via fe-1/2/1.7
意义

设备 R3 到设备 R2(前缀 10.1.1.2)的路由包括设备 R1 上配置的本地和全局 AS(分别为 64497 和 64496)。

了解 BGP 的累积 IGP 属性

内部网关协议 (IGP) 旨在处理单个域或一个自治系统 (AS) 内的路由。每个链路都被分配一个称为指标的特定值。两个节点之间的距离计算为路径上链接的所有指标值的总和。IGP 根据距离选择两个节点之间的最短路径。

BGP 旨在为大量独立的 AS 提供路由,这些 AS 各自的管理之间的协调有限或是没有协调。BGP 不会在路径选择决策中使用指标。

BGP 的累积 IGP (AIGP) 指标属性支持部署,其中单个管理部门可以运行多个连续的 BGP AS。此类部署允许 BGP 根据 IGP 指标做出路由决策。在此类网络中,BGP 可以根据指标选择路径,就像 IGP 所做的那样。在这种情况下,BGP 选择两个节点之间的最短路径,即使这些节点可能位于两个不同的 AS 中。

AIGP 属性在使用隧道将数据包传送到其 BGP 下一跃点的网络中特别有用。瞻博网络® Junos® 操作系统 (Junos OS) 目前支持两个 BGP 地址族和 family inet6 labeled-unicast的 AIGP 属性。 family inet labeled-unicast

AIGP 会影响 BGP 最佳路由决策流程。AIGP 属性首选项规则在本地首选项规则之后应用。将 AIGP 距离比作打破平局。如果解析下一跃点具有 AIGP 属性,BGP 最佳路由决策过程也会影响内部成本规则的应用方式。如果未启用 AIGP,路由的内部成本将基于路由下一跃点的指标计算。启用 AIGP 后,解析 AIGP 距离将添加到内部成本中。

从版本 20.2R1 开始,Junos OS 支持将 AIGP 指标转换为 MED。如果您希望 MED 承载端到端 AIGP 指标值(用于选择最佳路径),则可以启用此功能。 这在 AS 间 MPLS VPN 解决方案中特别有用,因为客户站点通过两个不同的服务提供商连接,而客户边缘路由器希望采取基于 IGP 指标的决策。您可以配置 , minimum-aigp 以防止在有效 aigp 更改超过先前已知的最低值时不必要地更新路由。有效 AIGP 是随路由播发的 AIGP 值加上到达下一跃点的 IGP 成本。您可以在和[edit policy-options policy-statement <name> then metric][edit protocols bgp group <group-name> metric-out]层次结构级别进行配置effective-aigpminimum-effective-aigp语句。

AIGP 属性是可选的非传递 BGP 路径属性,在互联网草案 draft-ietf-idr-aigp-06( BGP 的累积 IGP 指标属性)中指定。

示例:为 BGP 配置累积的 IGP 属性

此示例说明如何为 BGP 配置累积 IGP (AIGP) 指标属性。

要求

此示例使用以下硬件和软件组件:

  • 七个 BGP 接口设备。

  • Junos OS 12.1 或更高版本。

概述

AIGP 属性支持单个管理部门可以运行多个连续的 BGP 自治系统 (AS) 的部署。此类部署允许 BGP 根据 IGP 指标做出路由决策。启用 AIGP 后,BGP 可以根据 IGP 指标选择路径。这使 BGP 能够选择两个节点之间的最短路径,即使这些节点可能位于不同的 AS 中。AIGP 属性在使用隧道将数据包传送到其 BGP 下一跃点的网络中特别有用。此示例显示了配置了 MPLS 标签交换路径的 AIGP。

要启用 AIGP,您需要在 aigp 协议家族的 BGP 配置中包含该语句。在特定家族上配置 AIGP 可以在该家族上发送和接收 AIGP 属性。默认情况下,AIGP 处于禁用状态。禁用 AIGP 的邻居不会发送 AIGP 属性,而是以静默方式丢弃收到的 AIGP 属性。

Junos OS 支持 AIGP 和 family inet labeled-unicastfamily inet6 labeled-unicast。可以在全局 BGP、组或邻居级别为给定系列配置语句 aigp

默认情况下,本地前缀的 AIGP 属性值为零。启用了 AIGP 的邻居可以使用策略 aigp-originate 操作,通过导出策略为给定前缀发起 AIGP 属性。AIGP 属性的值反映到前缀的 IGP 距离。或者,您可以使用策略操作指定 aigp-originate distance distance 一个值。可配置范围为 0 到 4,294,967,295。只需一个节点即可发起 AIGP 属性。如果使用 BGP 配置中的语句启用了 aigp 邻接方 AIGP,则会保留并重新通告 AIGP 属性。

发起 AIGP 属性的策略操作具有以下要求:

  • 邻居必须启用 AIGP。

  • 策略必须作为导出策略应用。

  • 前缀必须没有当前 AIGP 属性。

  • 前缀必须使用下一跃点自导出。

  • 前缀必须位于 AIGP 域中。通常,环路 IP 地址是要发起的前缀。

如果不满足这些要求,则忽略该策略。

拓扑图

图 4 显示了此示例中使用的拓扑。OSPF 用作内部网关协议 (IGP)。在设备 PE1 和设备 PE4 之间配置内部 BGP。外部 BGP (EBGP) 在设备 PE7 和设备 PE1 之间、设备 PE4 和设备 PE3 之间以及设备 PE4 和设备 PE2 之间配置。设备 PE4、PE2 和 PE3 配置为多跳。设备 PE4 根据 AIGP 值选择路径,然后根据 AIGP 和策略配置重新播发 AIGP 值。设备 PE1 将 AIGP 值重新播发到另一个管理域中的设备 PE7。每个设备都有两个环路接口地址:10.9.9.x 用于 BGP 对等互连和路由器 ID,10.100.1.x 用于 BGP 下一跃点。

设备 PE1 和 PE3 之间的网络具有 IBGP 对等和多个 OSPF 区域。指向设备 PE7 的外部链接配置为显示 AIGP 属性已重新播发到管理域之外的邻接方(如果该邻接方已启用 AIGP)。

图 4: BGP 中多路径通告BGP 中多路径通告

对于 AIGP 属性的发起,BGP 下一跃点必须是自身。如果 BGP 下一跃点保持不变,则收到的 AIGP 属性将按原样重新播发到另一个 AIGP 邻接方。如果下一跃点发生变化,则收到的 AIGP 属性将以增加的值重新播发到另一个 AIGP 邻接方。值的增加反映了到上一个 BGP 下一跃点的 IGP 距离。为了进行演示,此示例将环路接口地址用于设备 PE4 与设备 PE2 和设备 PE3 的 EBGP 对等会话。在这些会话上启用多跳,以便执行递归查找以确定点对点接口。由于下一跃点会更改,因此 IGP 距离将添加到 AIGP 距离中。

配置

CLI 快速配置

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

设备 P1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 1 description P1-to-PE1
set interfaces fe-1/2/0 unit 1 family inet address 10.0.0.2/30
set interfaces fe-1/2/0 unit 1 family mpls
set interfaces fe-1/2/1 unit 4 description P1-to-P2
set interfaces fe-1/2/1 unit 4 family inet address 10.0.0.29/30
set interfaces fe-1/2/1 unit 4 family mpls
set interfaces fe-1/2/2 unit 8 description P1-to-PE4
set interfaces fe-1/2/2 unit 8 family inet address 10.0.0.17/30
set interfaces fe-1/2/2 unit 8 family mpls
set interfaces lo0 unit 3 family inet address 10.9.9.2/32
set interfaces lo0 unit 3 family inet address 10.100.1.2/32
set protocols rsvp interface fe-1/2/0.1
set protocols rsvp interface fe-1/2/2.8
set protocols rsvp interface fe-1/2/1.4
set protocols mpls label-switched-path P1-to-P2 to 10.9.9.3
set protocols mpls label-switched-path P1-to-PE1 to 10.9.9.1
set protocols mpls label-switched-path P1-to-PE4 to 10.9.9.4
set protocols mpls interface fe-1/2/0.1
set protocols mpls interface fe-1/2/2.8
set protocols mpls interface fe-1/2/1.4
set protocols bgp group internal type internal
set protocols bgp group internal local-address 10.9.9.2
set protocols bgp group internal family inet labeled-unicast aigp
set protocols bgp group internal neighbor 10.9.9.1
set protocols bgp group internal neighbor 10.9.9.3
set protocols bgp group internal neighbor 10.9.9.4
set protocols ospf area 0.0.0.1 interface fe-1/2/0.1 metric 1
set protocols ospf area 0.0.0.1 interface fe-1/2/1.4 metric 1
set protocols ospf area 0.0.0.0 interface fe-1/2/2.8 metric 1
set protocols ospf area 0.0.0.0 interface 10.9.9.2 passive
set protocols ospf area 0.0.0.0 interface 10.9.9.2 metric 1
set protocols ospf area 0.0.0.0 interface 10.100.1.2 passive
set protocols ospf area 0.0.0.0 interface 10.100.1.2 metric 1
set routing-options router-id 10.9.9.2
set routing-options autonomous-system 13979

设备 P2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 3 description P2-to-PE1
set interfaces fe-1/2/0 unit 3 family inet address 10.0.0.6/30
set interfaces fe-1/2/0 unit 3 family mpls
set interfaces fe-1/2/1 unit 5 description P2-to-P1
set interfaces fe-1/2/1 unit 5 family inet address 10.0.0.30/30
set interfaces fe-1/2/1 unit 5 family mpls
set interfaces fe-1/2/2 unit 6 description P2-to-PE4
set interfaces fe-1/2/2 unit 6 family inet address 10.0.0.13/30
set interfaces fe-1/2/2 unit 6 family mpls
set interfaces lo0 unit 5 family inet address 10.9.9.3/32
set interfaces lo0 unit 5 family inet address 10.100.1.3/32
set protocols rsvp interface fe-1/2/1.5
set protocols rsvp interface fe-1/2/2.6
set protocols rsvp interface fe-1/2/0.3
set protocols mpls label-switched-path P2-to-PE1 to 10.9.9.1
set protocols mpls label-switched-path P2-to-P1 to 10.9.9.2
set protocols mpls label-switched-path P2-to-PE4 to 10.9.9.4
set protocols mpls interface fe-1/2/1.5
set protocols mpls interface fe-1/2/2.6
set protocols mpls interface fe-1/2/0.3
set protocols bgp group internal type internal
set protocols bgp group internal local-address 10.9.9.3
set protocols bgp group internal family inet labeled-unicast aigp
set protocols bgp group internal neighbor 10.9.9.1
set protocols bgp group internal neighbor 10.9.9.2
set protocols bgp group internal neighbor 10.9.9.4
set protocols ospf area 0.0.0.0 interface fe-1/2/2.6 metric 1
set protocols ospf area 0.0.0.0 interface 10.9.9.3 passive
set protocols ospf area 0.0.0.0 interface 10.9.9.3 metric 1
set protocols ospf area 0.0.0.0 interface 10.100.1.3 passive
set protocols ospf area 0.0.0.0 interface 10.100.1.3 metric 1
set routing-options router-id 10.9.9.3
set routing-options autonomous-system 13979

设备 PE4

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 7 description PE4-to-P2
set interfaces fe-1/2/0 unit 7 family inet address 10.0.0.14/30
set interfaces fe-1/2/0 unit 7 family mpls
set interfaces fe-1/2/1 unit 9 description PE4-to-P1
set interfaces fe-1/2/1 unit 9 family inet address 10.0.0.18/30
set interfaces fe-1/2/1 unit 9 family mpls
set interfaces fe-1/2/2 unit 10 description PE4-to-PE2
set interfaces fe-1/2/2 unit 10 family inet address 10.0.0.21/30
set interfaces fe-1/2/2 unit 10 family mpls
set interfaces fe-1/0/2 unit 12 description PE4-to-PE3
set interfaces fe-1/0/2 unit 12 family inet address 10.0.0.25/30
set interfaces fe-1/0/2 unit 12 family mpls
set interfaces lo0 unit 7 family inet address 10.9.9.4/32
set interfaces lo0 unit 7 family inet address 10.100.1.4/32
set protocols rsvp interface fe-1/2/0.7
set protocols rsvp interface fe-1/2/1.9
set protocols rsvp interface fe-1/2/2.10
set protocols rsvp interface fe-1/0/2.12
set protocols mpls label-switched-path PE4-to-PE2 to 10.9.9.5
set protocols mpls label-switched-path PE4-to-PE3 to 10.9.9.6
set protocols mpls label-switched-path PE4-to-P1 to 10.9.9.2
set protocols mpls label-switched-path PE4-to-P2 to 10.9.9.3
set protocols mpls interface fe-1/2/0.7
set protocols mpls interface fe-1/2/1.9
set protocols mpls interface fe-1/2/2.10
set protocols mpls interface fe-1/0/2.12
set protocols bgp export next-hop
set protocols bgp export aigp
set protocols bgp group internal type internal
set protocols bgp group internal local-address 10.9.9.4
set protocols bgp group internal family inet labeled-unicast aigp
set protocols bgp group internal neighbor 10.9.9.1
set protocols bgp group internal neighbor 10.9.9.3
set protocols bgp group internal neighbor 10.9.9.2
set protocols bgp group external type external
set protocols bgp group external multihop ttl 2
set protocols bgp group external local-address 10.9.9.4
set protocols bgp group external family inet labeled-unicast aigp
set protocols bgp group external peer-as 7018
set protocols bgp group external neighbor 10.9.9.5
set protocols bgp group external neighbor 10.9.9.6
set protocols ospf area 0.0.0.0 interface fe-1/2/1.9 metric 1
set protocols ospf area 0.0.0.0 interface fe-1/2/0.7 metric 1
set protocols ospf area 0.0.0.0 interface 10.9.9.4 passive
set protocols ospf area 0.0.0.0 interface 10.9.9.4 metric 1
set protocols ospf area 0.0.0.0 interface 10.100.1.4 passive
set protocols ospf area 0.0.0.0 interface 10.100.1.4 metric 1
set protocols ospf area 0.0.0.2 interface fe-1/2/2.10 metric 1
set protocols ospf area 0.0.0.3 interface fe-1/0/2.12 metric 1
set policy-options policy-statement aigp term 10 from protocol static
set policy-options policy-statement aigp term 10 from route-filter 44.0.0.0/24 exact
set policy-options policy-statement aigp term 10 then aigp-originate distance 200
set policy-options policy-statement aigp term 10 then next-hop 10.100.1.4
set policy-options policy-statement aigp term 10 then accept
set policy-options policy-statement next-hop term 10 from protocol bgp
set policy-options policy-statement next-hop term 10 then next-hop 10.100.1.4
set policy-options policy-statement next-hop term 10 then accept
set policy-options policy-statement next-hop term 20 from protocol direct
set policy-options policy-statement next-hop term 20 from route-filter 10.9.9.4/32 exact
set policy-options policy-statement next-hop term 20 from route-filter 10.100.1.4/32 exact
set policy-options policy-statement next-hop term 20 then next-hop 10.100.1.4
set policy-options policy-statement next-hop term 20 then accept
set routing-options static route 44.0.0.0/24 discard
set routing-options router-id 10.9.9.4
set routing-options autonomous-system 13979

设备 PE1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 description PE1-to-P1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30
set interfaces fe-1/2/0 unit 0 family mpls
set interfaces fe-1/2/1 unit 2 description PE1-to-P2
set interfaces fe-1/2/1 unit 2 family inet address 10.0.0.5/30
set interfaces fe-1/2/1 unit 2 family mpls
set interfaces fe-1/2/2 unit 14 description PE1-to-PE7
set interfaces fe-1/2/2 unit 14 family inet address 10.0.0.9/30
set interfaces lo0 unit 1 family inet address 10.9.9.1/32
set interfaces lo0 unit 1 family inet address 10.100.1.1/32
set protocols rsvp interface fe-1/2/0.0
set protocols rsvp interface fe-1/2/1.2
set protocols rsvp interface fe-1/2/2.14
set protocols mpls label-switched-path PE1-to-P1 to 10.9.9.2
set protocols mpls label-switched-path PE1-to-P2 to 10.9.9.3
set protocols mpls interface fe-1/2/0.0
set protocols mpls interface fe-1/2/1.2
set protocols mpls interface fe-1/2/2.14
set protocols bgp group internal type internal
set protocols bgp group internal local-address 10.9.9.1
set protocols bgp group internal family inet labeled-unicast aigp
set protocols bgp group internal export SET_EXPORT_ROUTES
set protocols bgp group internal vpn-apply-export
set protocols bgp group internal neighbor 10.9.9.4
set protocols bgp group internal neighbor 10.9.9.2
set protocols bgp group internal neighbor 10.9.9.3
set protocols bgp group external type external
set protocols bgp group external family inet labeled-unicast aigp
set protocols bgp group external export SET_EXPORT_ROUTES
set protocols bgp group external peer-as 7019
set protocols bgp group external neighbor 10.0.0.10
set protocols ospf area 0.0.0.1 interface fe-1/2/0.0 metric 1
set protocols ospf area 0.0.0.1 interface fe-1/2/1.2 metric 1
set protocols ospf area 0.0.0.1 interface 10.9.9.1 passive
set protocols ospf area 0.0.0.1 interface 10.9.9.1 metric 1
set protocols ospf area 0.0.0.1 interface 10.100.1.1 passive
set protocols ospf area 0.0.0.1 interface 10.100.1.1 metric 1
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol direct
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol bgp
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then next-hop 10.100.1.1
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then accept
set routing-options router-id 10.9.9.1
set routing-options autonomous-system 13979

设备 PE2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 11 description PE2-to-PE4
set interfaces fe-1/2/0 unit 11 family inet address 10.0.0.22/30
set interfaces fe-1/2/0 unit 11 family mpls
set interfaces lo0 unit 9 family inet address 10.9.9.5/32 primary
set interfaces lo0 unit 9 family inet address 10.100.1.5/32
set protocols rsvp interface fe-1/2/0.11
set protocols mpls label-switched-path PE2-to-PE4 to 10.9.9.4
set protocols mpls interface fe-1/2/0.11
set protocols bgp group external type external
set protocols bgp group external multihop ttl 2
set protocols bgp group external local-address 10.9.9.5
set protocols bgp group external family inet labeled-unicast aigp
set protocols bgp group external export next-hop
set protocols bgp group external export aigp
set protocols bgp group external export SET_EXPORT_ROUTES
set protocols bgp group external vpn-apply-export
set protocols bgp group external peer-as 13979
set protocols bgp group external neighbor 10.9.9.4
set protocols ospf area 0.0.0.2 interface 10.9.9.5 passive
set protocols ospf area 0.0.0.2 interface 10.9.9.5 metric 1
set protocols ospf area 0.0.0.2 interface 10.100.1.5 passive
set protocols ospf area 0.0.0.2 interface 10.100.1.5 metric 1
set protocols ospf area 0.0.0.2 interface fe-1/2/0.11 metric 1
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol direct
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol static
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol bgp
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then next-hop 10.100.1.5
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then accept
set policy-options policy-statement aigp term 10 from route-filter 55.0.0.0/24 exact
set policy-options policy-statement aigp term 10 then aigp-originate distance 20
set policy-options policy-statement aigp term 10 then next-hop 10.100.1.5
set policy-options policy-statement aigp term 10 then accept
set policy-options policy-statement aigp term 20 from route-filter 99.0.0.0/24 exact
set policy-options policy-statement aigp term 20 then aigp-originate distance 30
set policy-options policy-statement aigp term 20 then next-hop 10.100.1.5
set policy-options policy-statement aigp term 20 then accept
set policy-options policy-statement next-hop term 10 from protocol bgp
set policy-options policy-statement next-hop term 10 then next-hop 10.100.1.5
set policy-options policy-statement next-hop term 10 then accept
set policy-options policy-statement next-hop term 20 from protocol direct
set policy-options policy-statement next-hop term 20 from route-filter 10.9.9.5/32 exact
set policy-options policy-statement next-hop term 20 from route-filter 10.100.1.5/32 exact
set policy-options policy-statement next-hop term 20 then next-hop 10.100.1.5
set policy-options policy-statement next-hop term 20 then accept
set routing-options static route 99.0.0.0/24 discard
set routing-options static route 55.0.0.0/24 discard
set routing-options router-id 10.9.9.5
set routing-options autonomous-system 7018

设备 PE3

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 13 description PE3-to-PE4
set interfaces fe-1/2/0 unit 13 family inet address 10.0.0.26/30
set interfaces fe-1/2/0 unit 13 family mpls
set interfaces lo0 unit 11 family inet address 10.9.9.6/32
set interfaces lo0 unit 11 family inet address 10.100.1.6/32
set protocols rsvp interface fe-1/2/0.13
set protocols mpls label-switched-path PE3-to-PE4 to 10.9.9.4
set protocols mpls interface fe-1/2/0.13
set protocols bgp group external type external
set protocols bgp group external multihop ttl 2
set protocols bgp group external local-address 10.9.9.6
set protocols bgp group external family inet labeled-unicast aigp
set protocols bgp group external export next-hop
set protocols bgp group external export SET_EXPORT_ROUTES
set protocols bgp group external vpn-apply-export
set protocols bgp group external peer-as 13979
set protocols bgp group external neighbor 10.9.9.4
set protocols ospf area 0.0.0.3 interface 10.9.9.6 passive
set protocols ospf area 0.0.0.3 interface 10.9.9.6 metric 1
set protocols ospf area 0.0.0.3 interface 10.100.1.6 passive
set protocols ospf area 0.0.0.3 interface 10.100.1.6 metric 1
set protocols ospf area 0.0.0.3 interface fe-1/2/0.13 metric 1
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol direct
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol static
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol bgp
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then next-hop 10.100.1.6
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then accept
set policy-options policy-statement next-hop term 10 from protocol bgp
set policy-options policy-statement next-hop term 10 then next-hop 10.100.1.6
set policy-options policy-statement next-hop term 10 then accept
set policy-options policy-statement next-hop term 20 from protocol direct
set policy-options policy-statement next-hop term 20 from route-filter 10.9.9.6/32 exact
set policy-options policy-statement next-hop term 20 from route-filter 10.100.1.6/32 exact
set policy-options policy-statement next-hop term 20 then next-hop 10.100.1.6
set policy-options policy-statement next-hop term 20 then accept
set routing-options router-id 10.9.9.6
set routing-options autonomous-system 7018

设备 PE7

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 15 description PE7-to-PE1
set interfaces fe-1/2/0 unit 15 family inet address 10.0.0.10/30
set interfaces lo0 unit 13 family inet address 10.9.9.7/32
set interfaces lo0 unit 13 family inet address 10.100.1.7/32
set protocols bgp group external type external
set protocols bgp group external family inet labeled-unicast aigp
set protocols bgp group external export SET_EXPORT_ROUTES
set protocols bgp group external peer-as 13979
set protocols bgp group external neighbor 10.0.0.9
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol direct
set policy-options policy-statement SET_EXPORT_ROUTES term 10 from protocol bgp
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then next-hop 10.100.1.7
set policy-options policy-statement SET_EXPORT_ROUTES term 10 then accept
set routing-options router-id 10.9.9.7
set routing-options autonomous-system 7019

配置设备 P1

分步过程

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

要配置设备 P1:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@P1# set fe-1/2/0 unit 1 description P1-to-PE1
    user@P1# set fe-1/2/0 unit 1 family inet address 10.0.0.2/30
    user@P1# set fe-1/2/0 unit 1 family mpls
    user@P1# set fe-1/2/1 unit 4 description P1-to-P2
    user@P1# set fe-1/2/1 unit 4 family inet address 10.0.0.29/30
    user@P1# set fe-1/2/1 unit 4 family mpls
    user@P1# set fe-1/2/2 unit 8 description P1-to-PE4
    user@P1# set fe-1/2/2 unit 8 family inet address 10.0.0.17/30
    user@P1# set fe-1/2/2 unit 8 family mpls
    user@P1# set lo0 unit 3 family inet address 10.9.9.2/32
    user@P1# set lo0 unit 3 family inet address 10.100.1.2/32
    
  2. 配置 MPLS 和信令协议,例如 RSVP 或 LDP。

    content_copy zoom_out_map
    [edit protocols]
    user@P1# set rsvp interface fe-1/2/0.1
    user@P1# set rsvp interface fe-1/2/2.8
    user@P1# set rsvp interface fe-1/2/1.4
    user@P1# set mpls label-switched-path P1-to-P2 to 10.9.9.3
    user@P1# set mpls label-switched-path P1-to-PE1 to 10.9.9.1
    user@P1# set mpls label-switched-path P1-to-PE4 to 10.9.9.4
    user@P1# set mpls interface fe-1/2/0.1
    user@P1# set mpls interface fe-1/2/2.8
    user@P1# set mpls interface fe-1/2/1.4
    
  3. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp group internal]
    user@P1# set type internal
    user@P1# set local-address 10.9.9.2
    user@P1# set neighbor 10.9.9.1
    user@P1# set neighbor 10.9.9.3
    user@P1# set neighbor 10.9.9.4
    
  4. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp group internal]
    user@P1# set family inet labeled-unicast aigp
    
  5. 配置 IGP,例如 OSPF、RIP 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf]
    user@P1# set area 0.0.0.1 interface fe-1/2/0.1 metric 1
    user@P1# set area 0.0.0.1 interface fe-1/2/1.4 metric 1
    user@P1# set area 0.0.0.0 interface fe-1/2/2.8 metric 1
    user@P1# set area 0.0.0.0 interface 10.9.9.2 passive
    user@P1# set area 0.0.0.0 interface 10.9.9.2 metric 1
    user@P1# set area 0.0.0.0 interface 10.100.1.2 passive
    user@P1# set area 0.0.0.0 interface 10.100.1.2 metric 1
    
  6. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@P1# set router-id 10.9.9.2
    user@P1# set autonomous-system 13979
    
  7. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@P1# commit
    
结果

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

content_copy zoom_out_map
user@P1# show interfaces
fe-1/2/0 {
    unit 1 {
        description P1-to-PE1;
        family inet {
            address 10.0.0.2/30;
        }
        family mpls;
    }
}
fe-1/2/1 {
    unit 4 {
        description P1-to-P2;
        family inet {
            address 10.0.0.29/30;
        }
        family mpls;
    }
}
fe-1/2/2 {
    unit 8 {
        description P1-to-PE4;
        family inet {
            address 10.0.0.17/30;
        }
        family mpls;
    }
}
lo0 {
    unit 3 {
        family inet {
            address 10.9.9.2/32;
            address 10.100.1.2/32;
        }
    }
}
content_copy zoom_out_map
user@P1# show protocols
rsvp {
    interface fe-1/2/0.1;
    interface fe-1/2/2.8;
    interface fe-1/2/1.4;
}
mpls {
    label-switched-path P1-to-P2 {
        to 10.9.9.3;
    }
    label-switched-path P1-to-PE1 {
        to 10.9.9.1;
    }
    label-switched-path P1-to-PE4 {
        to 10.9.9.4;
    }
    interface fe-1/2/0.1;
    interface fe-1/2/2.8;
    interface fe-1/2/1.4;
}
bgp {
    group internal {
        type internal;
        local-address 10.9.9.2;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        neighbor 10.9.9.1;
        neighbor 10.9.9.3;
        neighbor 10.9.9.4;
    }
}
ospf {
    area 0.0.0.1 {
        interface fe-1/2/0.1 {
            metric 1;
        }
        interface fe-1/2/1.4 {
            metric 1;
        }
    }
    area 0.0.0.0 {
        interface fe-1/2/2.8 {
            metric 1;
        }
        interface 10.9.9.2 {
            passive;
            metric 1;
        }
        interface 10.100.1.2 {
            passive;
            metric 1;
        }
    }
}
content_copy zoom_out_map
user@P1# show routing-options
router-id 10.9.9.2;
autonomous-system 13979;

配置设备 P2

分步过程

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

要配置设备 P2:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@P2# set fe-1/2/0 unit 3 description P2-to-PE1
    user@P2# set fe-1/2/0 unit 3 family inet address 10.0.0.6/30
    user@P2# set fe-1/2/0 unit 3 family mpls
    user@P2# set fe-1/2/1 unit 5 description P2-to-P1
    user@P2# set fe-1/2/1 unit 5 family inet address 10.0.0.30/30
    user@P2# set fe-1/2/1 unit 5 family mpls
    user@P2# set fe-1/2/2 unit 6 description P2-to-PE4
    user@P2# set fe-1/2/2 unit 6 family inet address 10.0.0.13/30
    user@P2# set fe-1/2/2 unit 6 family mpls
    user@P2# set lo0 unit 5 family inet address 10.9.9.3/32
    user@P2# set lo0 unit 5 family inet address 10.100.1.3/32
    
  2. 配置 MPLS 和信令协议,例如 RSVP 或 LDP。

    content_copy zoom_out_map
    [edit protocols]
    user@P2# set rsvp interface fe-1/2/1.5
    user@P2# set rsvp interface fe-1/2/2.6
    user@P2# set rsvp interface fe-1/2/0.3
    user@P2# set mpls label-switched-path P2-to-PE1 to 10.9.9.1
    user@P2# set mpls label-switched-path P2-to-P1 to 10.9.9.2
    user@P2# set mpls label-switched-path P2-to-PE4 to 10.9.9.4
    user@P2# set mpls interface fe-1/2/1.5
    user@P2# set mpls interface fe-1/2/2.6
    user@P2# set mpls interface fe-1/2/0.3
    
  3. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp group internal]
    user@P2# set type internal
    user@P2# set local-address 10.9.9.3
    user@P2# set neighbor 10.9.9.1
    user@P2# set neighbor 10.9.9.2
    user@P2# set neighbor 10.9.9.4
    
  4. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp group internal]
    user@P2# set family inet labeled-unicast aigp
    
  5. 配置 IGP,例如 OSPF、RIP 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf]
    user@P2# set area 0.0.0.0 interface fe-1/2/2.6 metric 1
    user@P2# set area 0.0.0.0 interface 10.9.9.3 passive
    user@P2# set area 0.0.0.0 interface 10.9.9.3 metric 1
    user@P2# set area 0.0.0.0 interface 10.100.1.3 passive
    user@P2# set area 0.0.0.0 interface 10.100.1.3 metric 1
    
  6. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@P2# set router-id 10.9.9.3
    user@P2# set autonomous-system 13979
    
  7. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@P2# commit
    
结果

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

content_copy zoom_out_map
user@P2# show interfaces
fe-1/2/0 {
    unit 3 {
        description P2-to-PE1;
        family inet {
            address 10.0.0.6/30;
        }
        family mpls;
    }
}
fe-1/2/1 {
    unit 5 {
        description P2-to-P1;
        family inet {
            address 10.0.0.30/30;
        }
        family mpls;
    }
}
fe-1/2/2 {
    unit 6 {
        description P2-to-PE4;
        family inet {
            address 10.0.0.13/30;
        }
        family mpls;
    }
}
lo0 {
    unit 5 {
        family inet {
            address 10.9.9.3/32;
            address 10.100.1.3/32;
        }
    }
}
content_copy zoom_out_map
user@P2# show protocols
rsvp {
    interface fe-1/2/1.5;
    interface fe-1/2/2.6;
    interface fe-1/2/0.3;
}
mpls {
    label-switched-path P2-to-PE1 {
        to 10.9.9.1;
    }
    label-switched-path P2-to-P1 {
        to 10.9.9.2;
    }
    label-switched-path P2-to-PE4 {
        to 10.9.9.4;
    }
    interface fe-1/2/1.5;
    interface fe-1/2/2.6;
    interface fe-1/2/0.3;
}
bgp {
    group internal {
        type internal;
        local-address 10.9.9.3;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        neighbor 10.9.9.1;
        neighbor 10.9.9.2;
        neighbor 10.9.9.4;
    }
}
ospf {
    area 0.0.0.0 {
        interface fe-1/2/2.6 {
            metric 1;
        }
        interface 10.9.9.3 {
            passive;
            metric 1;
        }
        interface 10.100.1.3 {
            passive;
            metric 1;
        }
    }
}
content_copy zoom_out_map
user@P2# show routing-options
router-id 10.9.9.3;
autonomous-system 13979;

配置设备 PE4

分步过程

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

要配置设备 PE4:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@PE4# set fe-1/2/0 unit 7 description PE4-to-P2
    user@PE4# set fe-1/2/0 unit 7 family inet address 10.0.0.14/30
    user@PE4# set fe-1/2/0 unit 7 family mpls
    user@PE4# set fe-1/2/1 unit 9 description PE4-to-P1
    user@PE4# set fe-1/2/1 unit 9 family inet address 10.0.0.18/30
    user@PE4# set fe-1/2/1 unit 9 family mpls
    user@PE4# set fe-1/2/2 unit 10 description PE4-to-PE2
    user@PE4# set fe-1/2/2 unit 10 family inet address 10.0.0.21/30
    user@PE4# set fe-1/2/2 unit 10 family mpls
    user@PE4# set fe-1/0/2 unit 12 description PE4-to-PE3
    user@PE4# set fe-1/0/2 unit 12 family inet address 10.0.0.25/30
    user@PE4# set fe-1/0/2 unit 12 family mpls
    user@PE4# set lo0 unit 7 family inet address 10.9.9.4/32
    user@PE4# set lo0 unit 7 family inet address 10.100.1.4/32
    
  2. 配置 MPLS 和信令协议,例如 RSVP 或 LDP。

    content_copy zoom_out_map
    [edit protocols]
    user@PE4# set rsvp interface fe-1/2/0.7
    user@PE4# set rsvp interface fe-1/2/1.9
    user@PE4# set rsvp interface fe-1/2/2.10
    user@PE4# set rsvp interface fe-1/0/2.12
    user@PE4# set mpls label-switched-path PE4-to-PE2 to 10.9.9.5
    user@PE4# set mpls label-switched-path PE4-to-PE3 to 10.9.9.6
    user@PE4# set mpls label-switched-path PE4-to-P1 to 10.9.9.2
    user@PE4# set mpls label-switched-path PE4-to-P2 to 10.9.9.3
    user@PE4# set mpls interface fe-1/2/0.7
    user@PE4# set mpls interface fe-1/2/1.9
    user@PE4# set mpls interface fe-1/2/2.10
    user@PE4# set mpls interface fe-1/0/2.12
    
  3. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@PE4# set export next-hop
    user@PE4# set export aigp
    user@PE4# set group internal type internal
    user@PE4# set group internal local-address 10.9.9.4
    user@PE4# set group internal neighbor 10.9.9.1
    user@PE4# set group internal neighbor 10.9.9.3
    user@PE4# set group internal neighbor 10.9.9.2
    user@PE4# set group external type external
    user@PE4# set group external multihop ttl 2
    user@PE4# set group external local-address 10.9.9.4
    user@PE4# set group external peer-as 7018
    user@PE4# set group external neighbor 10.9.9.5
    user@PE4# set group external neighbor 10.9.9.6
    
  4. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@PE4# set group external family inet labeled-unicast aigp
    user@PE4# set group internal family inet labeled-unicast aigp
    
  5. 发起前缀,并配置 AIGP 距离。

    默认情况下,前缀是使用当前 IGP 距离发起的。或者,您可以使用选项 distance 为 AIGP 属性配置距离,如下所示。

    content_copy zoom_out_map
    [edit policy-options policy-statement aigp term 10]
    user@PE4# set from protocol static
    user@PE4# set from route-filter 44.0.0.0/24 exact
    user@PE4# set then aigp-originate distance 200
    user@PE4# set then next-hop 10.100.1.4
    user@PE4# set then accept
    
  6. 启用策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement next-hop]
    user@PE4# set term 10 from protocol bgp
    user@PE4# set term 10 then next-hop 10.100.1.4
    user@PE4# set term 10 then accept
    user@PE4# set term 20 from protocol direct
    user@PE4# set term 20 from route-filter 10.9.9.4/32 exact
    user@PE4# set term 20 from route-filter 10.100.1.4/32 exact
    user@PE4# set term 20 then next-hop 10.100.1.4
    user@PE4# set term 20 then accept
    
  7. 配置静态路由。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE4# set static route 44.0.0.0/24 discard
    
  8. 配置 IGP,例如 OSPF、RIP 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf]
    user@PE4# set area 0.0.0.0 interface fe-1/2/1.9 metric 1
    user@PE4# set area 0.0.0.0 interface fe-1/2/0.7 metric 1
    user@PE4# set area 0.0.0.0 interface 10.9.9.4 passive
    user@PE4# set area 0.0.0.0 interface 10.9.9.4 metric 1
    user@PE4# set area 0.0.0.0 interface 10.100.1.4 passive
    user@PE4# set area 0.0.0.0 interface 10.100.1.4 metric 1
    user@PE4# set area 0.0.0.2 interface fe-1/2/2.10 metric 1
    user@PE4# set area 0.0.0.3 interface fe-1/0/2.12 metric 1
    
  9. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE4# set router-id 10.9.9.4
    user@PE4# set autonomous-system 13979
    
  10. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@PE4# commit
    
结果

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

content_copy zoom_out_map
user@PE4# show interfaces
fe-1/0/2 {
    unit 12 {
        description PE4-to-PE3;
        family inet {
            address 10.0.0.25/30;
        }
        family mpls;
    }
}
fe-1/2/0 {
    unit 7 {
        description PE4-to-P2;
        family inet {
            address 10.0.0.14/30;
        }
        family mpls;
    }
}
fe-1/2/1 {
    unit 9 {
        description PE4-to-P1;
        family inet {
            address 10.0.0.18/30;
        }
        family mpls;
    }
}
fe-1/2/2 {
    unit 10 {
        description PE4-to-PE2;
        family inet {
            address 10.0.0.21/30;
        }
        family mpls;
    }
}
lo0 {
    unit 7 {
        family inet {
            address 10.9.9.4/32;
            address 10.100.1.4/32;
        }
    }
}
content_copy zoom_out_map
user@PE4# show policy-options
policy-statement aigp {
    term 10 {
        from {
            protocol static;
            route-filter 44.0.0.0/24 exact;
        }
        then {
            aigp-originate distance 200;
            next-hop 10.100.1.4;
            accept;
        }
    }
}
policy-statement next-hop {
    term 10 {
        from protocol bgp;
        then {
            next-hop 10.100.1.4;
            accept;
        }
    }
    term 20 {
        from {
            protocol direct;
            route-filter 10.9.9.4/32 exact;
            route-filter 10.100.1.4/32 exact;
        }
        then {
            next-hop 10.100.1.4;
            accept;
        }
    }
}
content_copy zoom_out_map
user@PE4# show protocols
rsvp {
    interface fe-1/2/0.7;
    interface fe-1/2/1.9;
    interface fe-1/2/2.10;
    interface fe-1/0/2.12;
}
mpls {
    label-switched-path PE4-to-PE2 {
        to 10.9.9.5;
    }
    label-switched-path PE4-to-PE3 {
        to 10.9.9.6;
    }
    label-switched-path PE4-to-P1 {
        to 10.9.9.2;
    }
    label-switched-path PE4-to-P2 {
        to 10.9.9.3;
    }
    interface fe-1/2/0.7;
    interface fe-1/2/1.9;
    interface fe-1/2/2.10;
    interface fe-1/0/2.12;
}
bgp {
    export [ next-hop aigp ];
    group internal {
        type internal;
        local-address 10.9.9.4;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        neighbor 10.9.9.1;
        neighbor 10.9.9.3;
        neighbor 10.9.9.2;
    }
    group external {
        type external;
        multihop {
            ttl 2;
        }
        local-address 10.9.9.4;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        peer-as 7018;
        neighbor 10.9.9.5;
        neighbor 10.9.9.6;
    }
}
ospf {
    area 0.0.0.0 {
        interface fe-1/2/1.9 {
            metric 1;
        }
        interface fe-1/2/0.7 {
            metric 1;
        }
        interface 10.9.9.4 {
            passive;
            metric 1;
        }
        interface 10.100.1.4 {
            passive;
            metric 1;
        }
    }
    area 0.0.0.2 {
        interface fe-1/2/2.10 {
            metric 1;
        }
    }
    area 0.0.0.3 {
        interface fe-1/0/2.12 {
            metric 1;
        }
    }
}
content_copy zoom_out_map
user@PE4# show routing-options
static {
    route 44.0.0.0/24 discard;
}
router-id 10.9.9.4;
autonomous-system 13979;

配置设备 PE1

分步过程

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

要配置设备 PE1:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@PE1# set fe-1/2/0 unit 0 description PE1-to-P1
    user@PE1# set fe-1/2/0 unit 0 family inet address 10.0.0.1/30
    user@PE1# set fe-1/2/0 unit 0 family mpls
    user@PE1# set fe-1/2/1 unit 2 description PE1-to-P2
    user@PE1# set fe-1/2/1 unit 2 family inet address 10.0.0.5/30
    user@PE1# set fe-1/2/1 unit 2 family mpls
    user@PE1# set fe-1/2/2 unit 14 description PE1-to-PE7
    user@PE1# set fe-1/2/2 unit 14 family inet address 10.0.0.9/30
    user@PE1# set lo0 unit 1 family inet address 10.9.9.1/32
    user@PE1# set lo0 unit 1 family inet address 10.100.1.1/32
    
  2. 配置 MPLS 和信令协议,例如 RSVP 或 LDP。

    content_copy zoom_out_map
    [edit protocols]
    user@PE1# set rsvp interface fe-1/2/0.0
    user@PE1# set rsvp interface fe-1/2/1.2
    user@PE1# set rsvp interface fe-1/2/2.14
    user@PE1# set mpls label-switched-path PE1-to-P1 to 10.9.9.2
    user@PE1# set mpls label-switched-path PE1-to-P2 to 10.9.9.3
    user@PE1# set mpls interface fe-1/2/0.0
    user@PE1# set mpls interface fe-1/2/1.2
    user@PE1# set mpls interface fe-1/2/2.14
    
  3. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@PE1# set group internal type internal
    user@PE1# set group internal local-address 10.9.9.1
    user@PE1# set group internal export SET_EXPORT_ROUTES
    user@PE1# set group internal vpn-apply-export
    user@PE1# set group internal neighbor 10.9.9.4
    user@PE1# set group internal neighbor 10.9.9.2
    user@PE1# set group internal neighbor 10.9.9.3
    user@PE1# set group external type external
    user@PE1# set group external export SET_EXPORT_ROUTES
    user@PE1# set group external peer-as 7019
    user@PE1# set group external neighbor 10.0.0.10
    
  4. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@PE1# set group internal family inet labeled-unicast aigp
    user@PE1# set group external family inet labeled-unicast aigp
    
  5. 启用策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement SET_EXPORT_ROUTES term 10]
    user@PE1# set from protocol direct
    user@PE1# set from protocol bgp
    user@PE1# set then next-hop 10.100.1.1
    user@PE1# set then accept
    
  6. 配置 IGP,例如 OSPF、RIP 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf area 0.0.0.1]
    user@PE1# set interface fe-1/2/0.0 metric 1
    user@PE1# set interface fe-1/2/1.2 metric 1
    user@PE1# set interface 10.9.9.1 passive
    user@PE1# set interface 10.9.9.1 metric 1
    user@PE1# set interface 10.100.1.1 passive
    user@PE1# set interface 10.100.1.1 metric 1
    
  7. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE1# set router-id 10.9.9.1
    user@PE1# set autonomous-system 13979
    
  8. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@PE1# commit
    
结果

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

content_copy zoom_out_map
user@PE1# show interfaces
fe-1/2/0 {
    unit 0 {
        description PE1-to-P1;
        family inet {
            address 10.0.0.1/30;
        }
        family mpls;
    }
}
fe-1/2/1 {
    unit 2 {
        description PE1-to-P2;
        family inet {
            address 10.0.0.5/30;
        }
        family mpls;
    }
}
fe-1/2/2 {
    unit 14 {
        description PE1-to-PE7;
        family inet {
            address 10.0.0.9/30;
        }
    }
}
lo0 {
    unit 1 {
        family inet {
            address 10.9.9.1/32;
            address 10.100.1.1/32;
        }
    }
}
content_copy zoom_out_map
user@PE1# show policy-options
policy-statement SET_EXPORT_ROUTES {
    term 10 {
        from protocol [ direct bgp ];
        then {
            next-hop 10.100.1.1;
            accept;
        }
    }
}
content_copy zoom_out_map
user@PE1# show protocols
rsvp {
    interface fe-1/2/0.0;
    interface fe-1/2/1.2;
    interface fe-1/2/2.14;
}
mpls {
    label-switched-path PE1-to-P1 {
        to 10.9.9.2;
    }
    label-switched-path PE1-to-P2 {
        to 10.9.9.3;
    }
    interface fe-1/2/0.0;
    interface fe-1/2/1.2;
    interface fe-1/2/2.14;
}
bgp {
    group internal {
        type internal;
        local-address 10.9.9.1;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        export SET_EXPORT_ROUTES;
        vpn-apply-export;
        neighbor 10.9.9.4;
        neighbor 10.9.9.2;
        neighbor 10.9.9.3;
    }
    group external {
        type external;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        export SET_EXPORT_ROUTES;
        peer-as 7019;
        neighbor 10.0.0.10;
    }
}
ospf {
    area 0.0.0.1 {
        interface fe-1/2/0.0 {
            metric 1;
        }
        interface fe-1/2/1.2 {
            metric 1;
        }
        interface 10.9.9.1 {
            passive;
            metric 1;
        }
        interface 10.100.1.1 {
            passive;
            metric 1;
        }
    }
}
content_copy zoom_out_map
user@PE1# show routing-options
router-id 10.9.9.1;
autonomous-system 13979;

配置设备 PE2

分步过程

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

要配置设备 PE2:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@PE2# set fe-1/2/0 unit 11 description PE2-to-PE4
    user@PE2# set fe-1/2/0 unit 11 family inet address 10.0.0.22/30
    user@PE2# set fe-1/2/0 unit 11 family mpls
    user@PE2# set lo0 unit 9 family inet address 10.9.9.5/32 primary
    user@PE2# set lo0 unit 9 family inet address 10.100.1.5/32
    
  2. 配置 MPLS 和信令协议,例如 RSVP 或 LDP。

    content_copy zoom_out_map
    [edit protocols]
    user@PE2# set rsvp interface fe-1/2/0.11
    user@PE2# set mpls label-switched-path PE2-to-PE4 to 10.9.9.4
    user@PE2# set mpls interface fe-1/2/0.11
    
  3. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@PE2# set group external type external
    user@PE2# set group external multihop ttl 2
    user@PE2# set group external local-address 10.9.9.5
    user@PE2# set group external export next-hop
    user@PE2# set group external export aigp
    user@PE2# set group external export SET_EXPORT_ROUTES
    user@PE2# set group external vpn-apply-export
    user@PE2# set group external peer-as 13979
    user@PE2# set group external neighbor 10.9.9.4
    
  4. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@PE2# set group external family inet labeled-unicast aigp
    
  5. 发起前缀,并配置 AIGP 距离。

    默认情况下,前缀是使用当前 IGP 距离发起的。或者,您可以使用选项 distance 为 AIGP 属性配置距离,如下所示。

    content_copy zoom_out_map
    [edit policy-options policy-statement aigp]
    user@PE2# set term 10 from route-filter 55.0.0.0/24 exact
    user@PE2# set term 10 then aigp-originate distance 20
    user@PE2# set term 10 then next-hop 10.100.1.5
    user@PE2# set term 10 then accept
    user@PE2# set term 20 from route-filter 99.0.0.0/24 exact
    user@PE2# set term 20 then aigp-originate distance 30
    user@PE2# set term 20 then next-hop 10.100.1.5
    user@PE2# set term 20 then accept
    
  6. 启用策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@PE2# set policy-statement SET_EXPORT_ROUTES term 10 from protocol direct
    user@PE2# set policy-statement SET_EXPORT_ROUTES term 10 from protocol static
    user@PE2# set policy-statement SET_EXPORT_ROUTES term 10 from protocol bgp
    user@PE2# set policy-statement SET_EXPORT_ROUTES term 10 then next-hop 10.100.1.5
    user@PE2# set policy-statement SET_EXPORT_ROUTES term 10 then accept
    user@PE2# set policy-statement next-hop term 10 from protocol bgp
    user@PE2# set policy-statement next-hop term 10 then next-hop 10.100.1.5
    user@PE2# set policy-statement next-hop term 10 then accept
    user@PE2# set policy-statement next-hop term 20 from protocol direct
    user@PE2# set policy-statement next-hop term 20 from route-filter 10.9.9.5/32 exact
    user@PE2# set policy-statement next-hop term 20 from route-filter 10.100.1.5/32 exact
    user@PE2# set policy-statement next-hop term 20 then next-hop 10.100.1.5
    user@PE2# set policy-statement next-hop term 20 then accept
    
  7. 启用一些静态路由。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE2# set static route 99.0.0.0/24 discard
    user@PE2# set static route 55.0.0.0/24 discard
    
  8. 配置 IGP,例如 OSPF、RIP 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf area 0.0.0.2]
    user@PE2# set interface 10.9.9.5 passive
    user@PE2# set interface 10.9.9.5 metric 1
    user@PE2# set interface 10.100.1.5 passive
    user@PE2# set interface 10.100.1.5 metric 1
    user@PE2# set interface fe-1/2/0.11 metric 1
    
  9. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE2# set router-id 10.9.9.5
    user@PE2# set autonomous-system 7018
    
  10. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@PE2# commit
    
结果

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

content_copy zoom_out_map
user@PE2# show interfaces
fe-1/2/0 {
    unit 11 {
        description PE2-to-PE4;
        family inet {
            address 10.0.0.22/30;
        }
        family mpls;
    }
}
lo0 {
    unit 9 {
        family inet {
            address 10.9.9.5/32 {
                primary;
            }
            address 10.100.1.5/32;
        }
    }
}
content_copy zoom_out_map
user@PE2# show policy-options
policy-statement SET_EXPORT_ROUTES {
    term 10 {
        from protocol [ direct static bgp ];
        then {
            next-hop 10.100.1.5;
            accept;
        }
    }
}
policy-statement aigp {
    term 10 {
        from {
            route-filter 55.0.0.0/24 exact;
        }
        then {
            aigp-originate distance 20;
            next-hop 10.100.1.5;
            accept;
        }
    }
    term 20 {
        from {
            route-filter 99.0.0.0/24 exact;
        }
        then {
            aigp-originate distance 30;
            next-hop 10.100.1.5;
            accept;
        }
    }
}
policy-statement next-hop {
    term 10 {
        from protocol bgp;
        then {
            next-hop 10.100.1.5;
            accept;
        }
    }
    term 20 {
        from {
            protocol direct;
            route-filter 10.9.9.5/32 exact;
            route-filter 10.100.1.5/32 exact;
        }
        then {
            next-hop 10.100.1.5;
            accept;
        }
    }
}
content_copy zoom_out_map
user@PE2# show protocols
rsvp {
    interface fe-1/2/0.11;
}
mpls {
    label-switched-path PE2-to-PE4 {
        to 10.9.9.4;
    }
    interface fe-1/2/0.11;
}
bgp {
    group external {
        type external;
        multihop {
            ttl 2;
        }
        local-address 10.9.9.5;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        export [ next-hop aigp SET_EXPORT_ROUTES ];
        vpn-apply-export;
        peer-as 13979;
        neighbor 10.9.9.4;
    }
}
ospf {
    area 0.0.0.2 {
        interface 10.9.9.5 {
            passive;
            metric 1;
        }
        interface 10.100.1.5 {
            passive;
            metric 1;
        }
        interface fe-1/2/0.11 {
            metric 1;
        }
    }
}
content_copy zoom_out_map
user@PE2# show routing-options
static {
    route 99.0.0.0/24 discard;
    route 55.0.0.0/24 discard;
}
router-id 10.9.9.5;
autonomous-system 7018;

配置设备 PE3

分步过程

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

要配置设备 PE3:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@PE3# set fe-1/2/0 unit 13 description PE3-to-PE4
    user@PE3# set fe-1/2/0 unit 13 family inet address 10.0.0.26/30
    user@PE3# set fe-1/2/0 unit 13 family mpls
    user@PE3# set lo0 unit 11 family inet address 10.9.9.6/32
    user@PE3# set lo0 unit 11 family inet address 10.100.1.6/32
    
  2. 配置 MPLS 和信令协议,例如 RSVP 或 LDP。

    content_copy zoom_out_map
    [edit protocols]
    user@PE3# set rsvp interface fe-1/2/0.13
    user@PE3# set mpls label-switched-path PE3-to-PE4 to 10.9.9.4
    user@PE3# set mpls interface fe-1/2/0.13
    
  3. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp group external]
    user@PE3# set type external
    user@PE3# set multihop ttl 2
    user@PE3# set local-address 10.9.9.6
    user@PE3# set export next-hop
    user@PE3# set export SET_EXPORT_ROUTES
    user@PE3# set vpn-apply-export
    user@PE3# set peer-as 13979
    user@PE3# set neighbor 10.9.9.4
    
  4. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp group external]
    user@PE3# set family inet labeled-unicast aigp
    
  5. 启用策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@PE3# set policy-statement SET_EXPORT_ROUTES term 10 from protocol direct
    user@PE3# set policy-statement SET_EXPORT_ROUTES term 10 from protocol static
    user@PE3# set policy-statement SET_EXPORT_ROUTES term 10 from protocol bgp
    user@PE3# set policy-statement SET_EXPORT_ROUTES term 10 then next-hop 10.100.1.6
    user@PE3# set policy-statement SET_EXPORT_ROUTES term 10 then accept
    user@PE3# set policy-statement next-hop term 10 from protocol bgp
    user@PE3# set policy-statement next-hop term 10 then next-hop 10.100.1.6
    user@PE3# set policy-statement next-hop term 10 then accept
    user@PE3# set policy-statement next-hop term 20 from protocol direct
    user@PE3# set policy-statement next-hop term 20 from route-filter 10.9.9.6/32 exact
    user@PE3# set policy-statement next-hop term 20 from route-filter 10.100.1.6/32 exact
    user@PE3# set policy-statement next-hop term 20 then next-hop 10.100.1.6
    user@PE3# set policy-statement next-hop term 20 then accept
    
  6. 配置 IGP,例如 OSPF、RIP 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf area 0.0.0.3]
    user@PE3# set interface 10.9.9.6 passive
    user@PE3# set interface 10.9.9.6 metric 1
    user@PE3# set interface 10.100.1.6 passive
    user@PE3# set interface 10.100.1.6 metric 1
    user@PE3# set interface fe-1/2/0.13 metric 1
    
  7. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE3# set router-id 10.9.9.6
    user@PE3# set autonomous-system 7018
    
  8. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@PE3# commit
    
结果

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

content_copy zoom_out_map
user@PE3# show interfaces
fe-1/2/0 {
    unit 13 {
        description PE3-to-PE4;
        family inet {
            address 10.0.0.26/30;
        }
        family mpls;
    }
}
lo0 {
    unit 11 {
        family inet {
            address 10.9.9.6/32;
            address 10.100.1.6/32;
        }
    }
}
content_copy zoom_out_map
user@PE3# show policy-options
policy-statement SET_EXPORT_ROUTES {
    term 10 {
        from protocol [ direct static bgp ];
        then {
            next-hop 10.100.1.6;
            accept;
        }
    }
}
policy-statement next-hop {
    term 10 {
        from protocol bgp;
        then {
            next-hop 10.100.1.6;
            accept;
        }
    }
    term 20 {
        from {
            protocol direct;
            route-filter 10.9.9.6/32 exact;
            route-filter 10.100.1.6/32 exact;
        }
        then {
            next-hop 10.100.1.6;
            accept;
        }
    }
}
content_copy zoom_out_map
user@PE3# show protocols
rsvp {
    interface fe-1/2/0.13;
}
mpls {
    label-switched-path PE3-to-PE4 {
        to 10.9.9.4;
    }
    interface fe-1/2/0.13;
}
bgp {
    group external {
        type external;
        multihop {
            ttl 2;
        }
        local-address 10.9.9.6;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        export [ next-hop SET_EXPORT_ROUTES ];
        vpn-apply-export;
        peer-as 13979;
        neighbor 10.9.9.4;
    }
}
ospf {
    area 0.0.0.3 {
        interface 10.9.9.6 {
            passive;
            metric 1;
        }
        interface 10.100.1.6 {
            passive;
            metric 1;
        }
        interface fe-1/2/0.13 {
            metric 1;
        }
    }
}
content_copy zoom_out_map
user@PE3# show routing-options
router-id 10.9.9.6;
autonomous-system 7018;

配置设备 PE7

分步过程

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

要配置设备 PE7:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@PE7# set fe-1/2/0 unit 15 description PE7-to-PE1
    user@PE7# set fe-1/2/0 unit 15 family inet address 10.0.0.10/30
    user@PE7# set lo0 unit 13 family inet address 10.9.9.7/32
    user@PE7# set lo0 unit 13 family inet address 10.100.1.7/32
    
  2. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp group external]
    user@PE7# set type external
    user@PE7# set export SET_EXPORT_ROUTES
    user@PE7# set peer-as 13979
    user@PE7# set neighbor 10.0.0.9
    
  3. 启用 AIGP。

    content_copy zoom_out_map
    [edit protocols bgp group external]
    user@PE7# set family inet labeled-unicast aigp
    
  4. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement SET_EXPORT_ROUTES term 10]
    user@PE7# set from protocol direct
    user@PE7# set from protocol bgp
    user@PE7# set then next-hop 10.100.1.7
    user@PE7# set then accept
    
  5. 配置路由器 ID 和自治系统编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE7# set router-id 10.9.9.7
    user@PE7# set autonomous-system 7019
    
  6. 如果完成设备配置,请提交配置。

    content_copy zoom_out_map
    user@PE7# commit
    
结果

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

content_copy zoom_out_map
user@PE7# show interfaces
interfaces {
    fe-1/2/0 {
        unit 15 {
            description PE7-to-PE1;
            family inet {
                address 10.0.0.10/30;
            }
        }
    }
    lo0 {
        unit 13 {
            family inet {
                address 10.9.9.7/32;
                address 10.100.1.7/32;
            }
        }
    }
}
content_copy zoom_out_map
user@PE7# show policy-options
policy-statement SET_EXPORT_ROUTES {
    term 10 {
        from protocol [ direct bgp ];
        then {
            next-hop 10.100.1.7;
            accept;
        }
    }
}
content_copy zoom_out_map
user@PE7# show protocols
bgp {
    group external {
        type external;
        family inet {
            labeled-unicast {
                aigp;
            }
        }
        export SET_EXPORT_ROUTES;
        peer-as 13979;
        neighbor 10.0.0.9;
    }
}
content_copy zoom_out_map
user@PE7# show routing-options
router-id 10.9.9.7;
autonomous-system 7019;

验证

确认配置工作正常。

验证设备 PE4 是否正在从其 EBGP 邻接方 PE2 接收 AIGP 属性

目的

确保设备 PE2 上的 AIGP 策略正常工作。

操作
content_copy zoom_out_map
user@PE4> show route receive-protocol bgp 10.9.9.5 extensive
* 55.0.0.0/24 (1 entry, 1 announced)
     Accepted
     Route Label: 299888
     Nexthop: 10.100.1.5
     AS path: 7018 I
     AIGP: 20

* 99.0.0.0/24 (1 entry, 1 announced)
     Accepted
     Route Label: 299888
     Nexthop: 10.100.1.5
     AS path: 7018 I
     AIGP: 30
意义

在设备 PE2 上, aigp-originate 语句配置的距离为 20 (aigp-originate distance 20)。此语句适用于路由 55.0.0.0/24。同样,该 aigp-originate distance 30 语句将应用于路由 99.0.0.0/24。因此,当设备 PE4 收到这些路由时,AIGP 属性将附加配置的衡量指标。

检查 IGP 指标

目的

从设备 PE4,检查 BGP 下一跃点 10.100.1.5 的 IGP 指标。

操作
content_copy zoom_out_map
user@PE4> show route 10.100.1.5
inet.0: 30 destinations, 40 routes (30 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.100.1.5/32      *[OSPF/10] 05:35:50, metric 2
                    > to 10.0.0.22 via fe-1/2/2.10
                    [BGP/170] 03:45:07, localpref 100, from 10.9.9.5
                      AS path: 7018 I
                    > to 10.0.0.22 via fe-1/2/2.10
意义

此路由的 IGP 指标为 2。

验证设备 PE4 是否已将 IGP 衡量指标添加到 AIGP 属性

目的

确保设备 PE4 在向其 IBGP 邻接方设备 PE1 重新播发路由时,将 IGP 指标添加到 AIGP 属性。

操作
content_copy zoom_out_map
user@PE4> show route advertising-protocol bgp 10.9.9.1 extensive

* 55.0.0.0/24 (1 entry, 1 announced)
 BGP group internal type Internal
     Route Label: 300544
     Nexthop: 10.100.1.4
     Flags: Nexthop Change
     Localpref: 100
     AS path: [13979] 7018 I
     AIGP: 22

* 99.0.0.0/24 (1 entry, 1 announced)
 BGP group internal type Internal
     Route Label: 300544
     Nexthop: 10.100.1.4
     Flags: Nexthop Change
     Localpref: 100
     AS path: [13979] 7018 I
     AIGP: 32
意义

IGP 指标将添加到 AIGP 指标(20 + 2 = 22 和 30 + 2 = 32),因为这些路由的下一跃点已更改。

验证设备 PE7 是否正在从其 EBGP 邻接方 PE1 接收 AIGP 属性

目的

确保设备 PE1 上的 AIGP 策略正常工作。

操作
content_copy zoom_out_map
user@PE7> show route receive-protocol bgp 10.0.0.9 extensive
* 44.0.0.0/24 (1 entry, 1 announced)
     Accepted
     Route Label: 300096
     Nexthop: 10.0.0.9
     AS path: 13979 I
     AIGP: 203

* 55.0.0.0/24 (1 entry, 1 announced)
     Accepted
     Route Label: 300112
     Nexthop: 10.0.0.9
     AS path: 13979 7018 I
     AIGP: 25

* 99.0.0.0/24 (1 entry, 1 announced)
     Accepted
     Route Label: 300112                
     Nexthop: 10.0.0.9
     AS path: 13979 7018 I
     AIGP: 35
意义

44.0.0.0/24 路由源自设备 PE4。55.0.0.0/24 和 99.0.0.0/24 路由源自设备 PE2。IGP 距离将添加到配置的 AIGP 距离中。

验证解析 AIGP 指标

目的

确认如果前缀是通过递归解析的,并且递归下一跃点具有 AIGP 指标,则该前缀具有递归 BGP 下一跃点上的 AIGP 值的总和。

操作
  1. 将静态路由添加到 66.0.0.0/24。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE2# set static route 66.0.0.0/24 discard
    
  2. 删除设备 PE2 上的策略语句中的 aigp 现有条款。

    content_copy zoom_out_map
    [edit policy-options policy-statement aigp]
    user@PE2# delete term 10
    user@PE2# delete term 20
    
  3. 为路由到 66.0.0.0 配置递归路由查找。

    该策略显示前缀 66.0.0.0/24(无)的 AIGP 指标及其递归下一跃点。前缀 66.0.0.0/24 由 55.0.0.1 解析。前缀 66.0.0.0/24 没有发起自己的 AIGP 指标,但其递归下一跃点 55.0.0.1 具有 AIGP 值。

    content_copy zoom_out_map
    [edit policy-options policy-statement aigp]
    user@PE2# set term 10 from route-filter 55.0.0.1/24 exact 
    user@PE2# set term 10 then aigp-originate distance 20 
    user@PE2# set term 10 then next-hop 10.100.1.5 
    user@PE2# set term 10 then accept 
    user@PE2# set term 20 from route-filter 66.0.0.0/24 exact 
    user@PE2# set term 20 then next-hop 55.0.0.1 
    user@PE2# set term 20 then accept 
    
  4. 在设备 PE4 上,运行 show route 55.0.0.0 extensive 命令。

    指标 2 的值是 BGP 下一跃点的 IGP 指标。当设备 PE4 将这些路由重新播发到其 IBGP 对等方设备 PE1 时,AIGP 衡量指标是 AIGP + 其解析 AIGP 衡量指标 + 衡量指标 2 之和。

    前缀 55.0.0.0 显示自己的 IGP 度量 20,由设备 PE2 定义和通告。它不显示解析 AIGP 值,因为它没有递归 BGP 下一跃点。指标 2 的值为 2。

    content_copy zoom_out_map
    user@PE4> show route 55.0.0.0 extensive
    inet.0: 31 destinations, 41 routes (31 active, 0 holddown, 0 hidden)
    55.0.0.0/24 (1 entry, 1 announced)
    TSI:
    KRT in-kernel 55.0.0.0/24 -> {indirect(262151)}
    Page 0 idx 0 Type 1 val 928d1b8
        Flags: Nexthop Change
        Nexthop: 10.100.1.4
        Localpref: 100
        AS path: [13979] 7018 I
        Communities:
        AIGP: 22
    Path 55.0.0.0 from 10.9.9.5 Vector len 4.  Val: 0
            *BGP    Preference: 170/-101
                    Next hop type: Indirect
                    Address: 0x925da38
                    Next-hop reference count: 4
                    Source: 10.9.9.5
                    Next hop type: Router, Next hop index: 1004
                    Next hop: 10.0.0.22 via fe-1/2/2.10, selected
                    Label operation: Push 299888
                    Label TTL action: prop-ttl
                    Protocol next hop: 10.100.1.5
                    Push 299888
                    Indirect next hop: 93514d8 262151
                    State: <Active Ext>
                    Local AS: 13979 Peer AS:  7018
                    Age: 22:03:26   Metric2: 2 
                    AIGP: 20 
                    Task: BGP_7018.10.9.9.5+58560
                    Announcement bits (3): 3-KRT 4-BGP_RT_Background 5-Resolve tree 1 
                    AS path: 7018 I
                    Accepted
                    Route Label: 299888
                    Localpref: 100
                    Router ID: 10.9.9.5
                    Indirect next hops: 1
                            Protocol next hop: 10.100.1.5 Metric: 2
                            Push 299888
                            Indirect next hop: 93514d8 262151
                            Indirect path forwarding next hops: 1
                                    Next hop type: Router
                                    Next hop: 10.0.0.22 via fe-1/2/2.10
                            10.100.1.5/32 Originating RIB: inet.0
                              Metric: 2                       Node path count: 1
                              Forwarding nexthops: 1
                                    Nexthop: 10.0.0.22 via fe-1/2/2.10
  5. 在设备 PE4 上,运行 show route 66.0.0.0 extensive 命令。

    前缀 66.0.0.0/24 显示解析 AIGP,这是其自己的 AIGP 指标与其递归 BGP 下一跃点的总和:

    66.0.0.1 = 0, 55.0.0.1 = 20, 0+20 = 20

    content_copy zoom_out_map
    user@PE4> show route 66.0.0.0 extensive 
    inet.0: 31 destinations, 41 routes (31 active, 0 holddown, 0 hidden)
    66.0.0.0/24 (1 entry, 1 announced)
    TSI:
    KRT in-kernel 66.0.0.0/24 -> {indirect(262162)}
    Page 0 idx 0 Type 1 val 928cefc
        Flags: Nexthop Change
        Nexthop: 10.100.1.4
        Localpref: 100
        AS path: [13979] 7018 I
        Communities:
    Path 66.0.0.0 from 10.9.9.5 Vector len 4.  Val: 0
            *BGP    Preference: 170/-101
                    Next hop type: Indirect
                    Address: 0x925d4e0
                    Next-hop reference count: 4
                    Source: 10.9.9.5
                    Next hop type: Router, Next hop index: 1006
                    Next hop: 10.0.0.22 via fe-1/2/2.10, selected
                    Label operation: Push 299888, Push 299888(top)
                    Label TTL action: prop-ttl, prop-ttl(top)
                    Protocol next hop: 55.0.0.1
                    Push 299888
                    Indirect next hop: 9353e88 262162
                    State: <Active Ext>
                    Local AS: 13979 Peer AS:  7018
                    Age: 31:42      Metric2: 2 
                    Resolving-AIGP: 20 
                    Task: BGP_7018.10.9.9.5+58560
                    Announcement bits (3): 3-KRT 4-BGP_RT_Background 5-Resolve tree 1 
                    AS path: 7018 I
                    Accepted
                    Route Label: 299888
                    Localpref: 100
                    Router ID: 10.9.9.5
                    Indirect next hops: 1
                            Protocol next hop: 55.0.0.1 Metric: 2 AIGP: 20
                            Push 299888
                            Indirect next hop: 9353e88 262162
                            Indirect path forwarding next hops: 1
                                    Next hop type: Router
                                    Next hop: 10.0.0.22 via fe-1/2/2.10
                            55.0.0.0/24 Originating RIB: inet.0
                              Metric: 2                       Node path count: 1
                              Indirect nexthops: 1
                                    Protocol Nexthop: 10.100.1.5 Metric: 2 Push 299888
                                    Indirect nexthop: 93514d8 262151
                                    Indirect path forwarding nexthops: 1
                                            Nexthop: 10.0.0.22 via fe-1/2/2.10
                                    10.100.1.5/32 Originating RIB: inet.0
                                      Metric: 2                               Node path count: 1
                                      Forwarding nexthops: 1
                                            Nexthop: 10.0.0.22 via fe-1/2/2.10

验证 BGP 更新中是否存在 AIGP 属性

目的

如果未在 BGP(或groupneighbor或层次结构)下启用 AIGP 属性,则 AIGP 属性将被静默丢弃。在配置的选项中detail启用traceoptions并包含packets标志,以确认传输或接收的 BGP 更新中是否存在 AIGP 属性。这在调试 AIGP 问题时很有用。

操作
  1. 为 配置 traceoptions设备 PE2 和设备 PE4。

    content_copy zoom_out_map
    user@host> show protocols bgp
        traceoptions {
            file bgp size 1m files 5;
            flag packets detail;
        }
    
  2. traceoptions检查设备 PE2 上的文件。

    以下示例显示了设备 PE2 播发前缀 99.0.0.0/24 到设备 PE4 (10.9.9.4) 且 AIGP 指标为 20:

    content_copy zoom_out_map
    user@PE2> show log bgp
    Mar 22 09:27:18.982150 BGP SEND 10.9.9.5+49652 -> 10.9.9.4+179
    Mar 22 09:27:18.982178 BGP SEND message type 2 (Update) length 70
    Mar 22 09:27:18.982198 BGP SEND Update PDU length 70
    Mar 22 09:27:18.982248 BGP SEND flags 0x40 code Origin(1): IGP
    Mar 22 09:27:18.982273 BGP SEND flags 0x40 code ASPath(2) length 6: 7018
    Mar 22 09:27:18.982295 BGP SEND flags 0x80 code AIGP(26): AIGP: 20 
    Mar 22 09:27:18.982316 BGP SEND flags 0x90 code MP_reach(14): AFI/SAFI 1/4
    Mar 22 09:27:18.982341 BGP SEND         nhop 10.100.1.5 len 4
    Mar 22 09:27:18.982372 BGP SEND         99.0.0.0/24 (label 301664)
    Mar 22 09:27:33.665412 bgp_send: sending 19 bytes to abcd::10:255:170:84 (External AS 13979)
    
  3. 使用命令验证 show route receive-protocol 设备 PE4 上是否已收到路由。

    设备 PE4 上未启用 AIGP,因此对于前缀 99.0.0.0/24,AIGP 属性将被静默丢弃,并且不会出现在以下输出中:

    content_copy zoom_out_map
    user@PE4> show route receive-protocol bgp 10.9.9.5 extensive | find 55.0.0.0
    * 99.0.0.0/24 (2 entries, 1 announced)
         Accepted
         Route Label: 301728
         Nexthop: 10.100.1.5
         AS path: 7018 I
    
  4. traceoptions检查设备 PE4 上的文件。

    日志中的 traceoptions 以下输出显示收到的 99.0.0.0/24 前缀附加了 AIGP 属性:

    content_copy zoom_out_map
    user@PE4> show log bgp
    Mar 22 09:41:39.650295 BGP RECV 10.9.9.5+64690 -> 10.9.9.4+179
    Mar 22 09:41:39.650331 BGP RECV message type 2 (Update) length 70
    Mar 22 09:41:39.650350 BGP RECV Update PDU length 70
    Mar 22 09:41:39.650370 BGP RECV flags 0x40 code Origin(1): IGP
    Mar 22 09:41:39.650394 BGP RECV flags 0x40 code ASPath(2) length 6: 7018
    Mar 22 09:41:39.650415 BGP RECV flags 0x80 code AIGP(26): AIGP: 20
    Mar 22 09:41:39.650436 BGP RECV flags 0x90 code MP_reach(14): AFI/SAFI 1/4
    Mar 22 09:41:39.650459 BGP RECV         nhop 10.100.1.5 len 4
    Mar 22 09:41:39.650495 BGP RECV         99.0.0.0/24 (label 301728)
    Mar 22 09:41:39.650574 bgp_rcv_nlri: 99.0.0.0/24
    Mar 22 09:41:39.650607 bgp_rcv_nlri: 99.0.0.0/24 belongs to meshgroup
    Mar 22 09:41:39.650629 bgp_rcv_nlri: 99.0.0.0/24 qualified bnp->ribact 0x0 l2afcb 0x0
    
意义

执行此验证有助于对 AIGP 进行故障排除和调试问题。它使您能够验证网络中的哪些设备发送和接收 AIGP 属性。

了解 AS 覆盖

AS 覆盖功能允许提供商边缘 (PE) 路由器更改在 VPN 路由和转发 (VRF) 接入链路上运行的外部 BGP (EBGP) 会话上客户边缘 (CE) 设备使用的专用自治系统 (AS) 编号。专用 AS 编号将更改为 PE AS 编号。连接到另一台 PE 设备的另一台 CE 设备看到 EBGP 路由来自第一个站点,AS 路径为提供商 ASN 提供商 ASN,而不是提供商 ASN 站点 1-ASN。这允许企业网络在所有站点上使用相同的专用 ASN。

AS 覆盖功能为服务提供商提供了明显的管理优势,因为默认情况下 BGP 不接受具有包含本地 AS 编号的 AS 路径属性的 BGP 路由。

在有多个站点的企业网络中,您可能会希望跨站点使用单个 AS 编号。例如,假设两台 CE 设备位于 AS 64512 中,而提供商网络处于 AS 65534 中。

当服务提供商使用此设置配置第 3 层 VPN 时,即使 MPLS 网络具有指向设备 CE1 和设备 CE2 的路由,设备 CE1 和设备 CE2 之间也没有路由,因为 AS 路径属性将显示为 64512 65534 64512。BGP 使用 AS 路径属性作为其环路避免机制。如果站点在 AS 路径中多次看到自己的 AS 编号,则路由被视为无效。

克服此困难的一种方法是使用语句, as-override 该语句适用于 PE 设备。该 as-override 语句将 CE 设备的 AS 编号替换为 PE 设备的 AS 编号,从而防止客户 AS 编号在 AS 路径属性中多次出现。

如果客户使用 AS 路径前缀来降低某些路径的可取性,并且服务提供商使用 AS 覆盖,则 AS 路径中出现的每个 CE AS 编号都将更改为服务提供商 AS 编号。例如,假设所有客户站点使用相同的 AS 编号,如 64512。如果 ISP 使用 AS 编号 65534,则一个客户站点会看到至其他站点的路径为 65534 65534。如果客户在特定路径上附加 64512 以降低其理想性,则另一个客户站点会将该路径视为 65534 65534 65534。

示例:使用路由反射和 AS 覆盖配置第 3 层 VPN

假设您是提供基于 MPLS 的托管第 3 层 VPN 服务的服务提供商。您的客户有多个站点,并且需要将 BGP 路由到每个站点上的客户边缘 (CE) 设备。

要求

配置此示例之前,不需要除设备初始化之外的特殊配置。

概述

此示例包含两个 CE 设备、两个提供商边缘 (PE) 设备和多个提供商核心设备。提供商网络还使用 IS-IS 来支持 LDP 和 BGP 环路可达性 设备 P2 充当路由反射器 (RR)。两台 CE 设备均位于自治系统 (AS) 64512 中。提供商网络位于 AS 65534 中。

as-override 语句将应用于 PE 设备,从而将 CE 设备的 AS 编号替换为 PE 设备的 AS 编号。这可以防止客户 AS 编号在 AS 路径属性中多次出现。

图 5 显示了此示例中使用的拓扑。

图 5: AS 覆盖拓扑AS 覆盖拓扑

CLI 快速配置 显示了 中 图 5所有设备的配置。分步过程本节介绍设备 PE1 上的步骤。

拓扑学

配置

程序

CLI 快速配置

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

设备 CE1

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.1/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces lo0 unit 0 family inet address 10.255.1.1/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0101.00
set protocols bgp group PE type external
set protocols bgp group PE family inet unicast
set protocols bgp group PE export ToBGP
set protocols bgp group PE peer-as 65534
set protocols bgp group PE neighbor 10.0.0.2
set policy-options policy-statement ToBGP term Direct from protocol direct
set policy-options policy-statement ToBGP term Direct then accept
set routing-options router-id 10.255.1.1
set routing-options autonomous-system 64512

设备 P1

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.6/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces ge-1/2/0 unit 0 family mpls
set interfaces ge-1/2/1 unit 0 family inet address 10.0.0.9/30
set interfaces ge-1/2/1 unit 0 family iso
set interfaces ge-1/2/1 unit 0 family mpls
set interfaces ge-1/2/2 unit 0 family inet address 10.0.0.25/30
set interfaces ge-1/2/2 unit 0 family iso
set interfaces ge-1/2/2 unit 0 family mpls
set interfaces lo0 unit 0 family inet address 10.255.3.3/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0303.00
set protocols mpls interface all
set protocols mpls interface fxp0.0 disable
set protocols bgp group l3vpn type internal
set protocols bgp group l3vpn local-address 10.255.3.3
set protocols bgp group l3vpn family inet-vpn unicast
set protocols bgp group l3vpn peer-as 65534
set protocols bgp group l3vpn local-as 65534
set protocols bgp group l3vpn neighbor 10.255.4.4
set protocols isis interface all level 2 metric 10
set protocols isis interface all level 1 disable
set protocols isis interface fxp0.0 disable
set protocols isis interface lo0.0 level 2 metric 0
set protocols ldp deaggregate
set protocols ldp interface all
set protocols ldp interface fxp0.0 disable
set routing-options router-id 10.255.3.3

设备 P2

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.10/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces ge-1/2/0 unit 0 family mpls
set interfaces ge-1/2/1 unit 0 family inet address 10.0.0.13/30
set interfaces ge-1/2/1 unit 0 family iso
set interfaces ge-1/2/1 unit 0 family mpls
set interfaces lo0 unit 0 family inet address 10.255.4.4/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0404.00
set protocols mpls interface all
set protocols mpls interface fxp0.0 disable
set protocols bgp group Core-RRClients type internal
set protocols bgp group Core-RRClients local-address 10.255.4.4
set protocols bgp group Core-RRClients family inet-vpn unicast
set protocols bgp group Core-RRClients cluster 10.255.4.4
set protocols bgp group Core-RRClients peer-as 65534
set protocols bgp group Core-RRClients neighbor 10.255.3.3
set protocols bgp group Core-RRClients neighbor 10.255.7.7
set protocols bgp group Core-RRClients neighbor 10.255.2.2
set protocols bgp group Core-RRClients neighbor 10.255.5.5
set protocols isis interface all level 2 metric 10
set protocols isis interface all level 1 disable
set protocols isis interface fxp0.0 disable
set protocols isis interface lo0.0 level 2 metric 0
set protocols ldp deaggregate
set protocols ldp interface all
set protocols ldp interface fxp0.0 disable
set routing-options router-id 10.255.4.4
set routing-options autonomous-system 65534

设备 P3

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.22/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces ge-1/2/0 unit 0 family mpls
set interfaces ge-1/2/1 unit 0 family inet address 10.0.0.26/30
set interfaces ge-1/2/1 unit 0 family iso
set interfaces ge-1/2/1 unit 0 family mpls
set interfaces ge-1/2/2 unit 0 family inet address 10.0.0.30/30
set interfaces ge-1/2/2 unit 0 family iso
set interfaces ge-1/2/2 unit 0 family mpls
set interfaces lo0 unit 0 family inet address 10.255.7.7/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0707.00
set protocols mpls interface all
set protocols mpls interface fxp0.0 disable
set protocols bgp group l3vpn type internal
set protocols bgp group l3vpn local-address 10.255.7.7
set protocols bgp group l3vpn family inet-vpn unicast
set protocols bgp group l3vpn peer-as 65534
set protocols bgp group l3vpn local-as 65534
set protocols bgp group l3vpn neighbor 10.255.4.4
set protocols isis interface all level 2 metric 10
set protocols isis interface all level 1 disable
set protocols isis interface fxp0.0 disable
set protocols isis interface lo0.0 level 2 metric 0
set protocols ldp deaggregate
set protocols ldp interface all
set protocols ldp interface fxp0.0 disable
set routing-options router-id 10.255.7.7

设备 PE1

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.2/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces ge-1/2/0 unit 0 family mpls
set interfaces ge-1/2/1 unit 0 family inet address 10.0.0.5/30
set interfaces ge-1/2/1 unit 0 family iso
set interfaces ge-1/2/1 unit 0 family mpls
set interfaces ge-1/2/2 unit 0 family inet address 10.0.0.21/30
set interfaces ge-1/2/2 unit 0 family iso
set interfaces ge-1/2/2 unit 0 family mpls
set interfaces lo0 unit 0 family inet address 10.255.2.2/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0202.00
set protocols mpls interface ge-1/2/2.0
set protocols mpls interface ge-1/2/1.0
set protocols mpls interface lo0.0
set protocols mpls interface fxp0.0 disable
set protocols bgp group l3vpn type internal
set protocols bgp group l3vpn local-address 10.255.2.2
set protocols bgp group l3vpn family inet-vpn unicast
set protocols bgp group l3vpn peer-as 65534
set protocols bgp group l3vpn local-as 65534
set protocols bgp group l3vpn neighbor 10.255.4.4
set protocols isis interface ge-1/2/1.0 level 2 metric 10
set protocols isis interface ge-1/2/1.0 level 1 disable
set protocols isis interface ge-1/2/2.0 level 2 metric 10
set protocols isis interface ge-1/2/2.0 level 1 disable
set protocols isis interface fxp0.0 disable
set protocols isis interface lo0.0 level 2 metric 0
set protocols ldp deaggregate
set protocols ldp interface ge-1/2/1.0
set protocols ldp interface ge-1/2/2.0
set protocols ldp interface fxp0.0 disable
set protocols ldp interface lo0.0
set routing-instances VPN-A instance-type vrf
set routing-instances VPN-A interface ge-1/2/0.0
set routing-instances VPN-A route-distinguisher 65534:1234
set routing-instances VPN-A vrf-target target:65534:1234
set routing-instances VPN-A protocols bgp group CE type external
set routing-instances VPN-A protocols bgp group CE family inet unicast
set routing-instances VPN-A protocols bgp group CE neighbor 10.0.0.1 peer-as 64512
set routing-instances VPN-A protocols bgp group CE neighbor 10.0.0.1 as-override
set routing-options router-id 10.255.2.2
set routing-options autonomous-system 65534

设备 PE2

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.14/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces ge-1/2/0 unit 0 family mpls
set interfaces ge-1/2/1 unit 0 family inet address 10.0.0.17/30
set interfaces ge-1/2/1 unit 0 family iso
set interfaces ge-1/2/2 unit 0 family inet address 10.0.0.29/30
set interfaces ge-1/2/2 unit 0 family iso
set interfaces ge-1/2/2 unit 0 family mpls
set interfaces lo0 unit 0 family inet address 10.255.5.5/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0505.00
set protocols mpls interface ge-1/2/0.0
set protocols mpls interface ge-1/2/2.0
set protocols mpls interface lo0.0
set protocols mpls interface fxp0.0 disable
set protocols bgp group l3vpn type internal
set protocols bgp group l3vpn local-address 10.255.5.5
set protocols bgp group l3vpn family inet-vpn unicast
set protocols bgp group l3vpn peer-as 65534
set protocols bgp group l3vpn local-as 65534
set protocols bgp group l3vpn neighbor 10.255.4.4
set protocols isis interface ge-1/2/0.0 level 2 metric 10
set protocols isis interface ge-1/2/0.0 level 1 disable
set protocols isis interface ge-1/2/2.0 level 2 metric 10
set protocols isis interface ge-1/2/2.0 level 1 disable
set protocols isis interface fxp0.0 disable
set protocols isis interface lo0.0 level 2 metric 0
set protocols ldp deaggregate
set protocols ldp interface ge-1/2/0.0
set protocols ldp interface ge-1/2/2.0
set protocols ldp interface fxp0.0 disable
set protocols ldp interface lo0.0
set routing-instances VPN-A instance-type vrf
set routing-instances VPN-A interface ge-1/2/1.0
set routing-instances VPN-A route-distinguisher 65534:1234
set routing-instances VPN-A vrf-target target:65534:1234
set routing-instances VPN-A protocols bgp group CE type external
set routing-instances VPN-A protocols bgp group CE family inet unicast
set routing-instances VPN-A protocols bgp group CE neighbor 10.0.0.18 peer-as 64512
set routing-instances VPN-A protocols bgp group CE neighbor 10.0.0.18 as-override
set routing-options router-id 10.255.5.5
set routing-options autonomous-system 65534

设备 CE2

content_copy zoom_out_map
set interfaces ge-1/2/0 unit 0 family inet address 10.0.0.18/30
set interfaces ge-1/2/0 unit 0 family iso
set interfaces lo0 unit 0 family inet address 10.255.6.6/32
set interfaces lo0 unit 0 family iso address 49.0001.0010.0000.0606.00
set protocols bgp group PE type external
set protocols bgp group PE family inet unicast
set protocols bgp group PE export ToBGP
set protocols bgp group PE peer-as 65534
set protocols bgp group PE neighbor 10.0.0.17
set policy-options policy-statement ToBGP term Direct from protocol direct
set policy-options policy-statement ToBGP term Direct then accept
set routing-options router-id 10.255.6.6
set routing-options autonomous-system 64512
分步过程

下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器

要配置 AS 覆盖:

  1. 配置接口。

    要启用 MPLS,请在接口上包含协议家族,以便接口不会丢弃传入的 MPLS 流量。

    content_copy zoom_out_map
    [edit interfaces]
    user@PE1# set ge-1/2/0 unit 0 family inet address 10.0.0.2/30
    user@PE1# set ge-1/2/0 unit 0 family iso
    user@PE1# set ge-1/2/0 unit 0 family mpls
    user@PE1# set ge-1/2/1 unit 0 family inet address 10.0.0.5/30
    user@PE1# set ge-1/2/1 unit 0 family iso
    user@PE1# set ge-1/2/1 unit 0 family mpls
    user@PE1# set ge-1/2/2 unit 0 family inet address 10.0.0.21/30
    user@PE1# set ge-1/2/2 unit 0 family iso
    user@PE1# set ge-1/2/2 unit 0 family mpls
    user@PE1# set lo0 unit 0 family inet address 10.255.2.2/32
    user@PE1# set lo0 unit 0 family iso address 49.0001.0010.0000.0202.00
    
  2. 将接口添加到 MPLS 协议以建立控制平面级别的连接。

    设置 IGP,以便提供商设备可以相互通信。

    要建立分发 MPLS 标签的机制,请启用 LDP。(可选)对于 LDP,启用转发等效类 (FEC) 分解,这样可以加快全局收敛速度。

    content_copy zoom_out_map
    [edit protocols]
    user@PE1# set mpls interface ge-1/2/2.0
    user@PE1# set mpls interface ge-1/2/1.0
    user@PE1# set mpls interface lo0.0
    user@PE1# set mpls interface fxp0.0 disable
    user@PE1# set isis interface ge-1/2/1.0 level 2 metric 10
    user@PE1# set isis interface ge-1/2/1.0 level 1 disable
    user@PE1# set isis interface ge-1/2/2.0 level 2 metric 10
    user@PE1# set isis interface ge-1/2/2.0 level 1 disable
    user@PE1# set isis interface fxp0.0 disable
    user@PE1# set isis interface lo0.0 level 2 metric 0
    user@PE1# set ldp deaggregate
    user@PE1# set ldp interface ge-1/2/1.0
    user@PE1# set ldp interface ge-1/2/2.0
    user@PE1# set ldp interface fxp0.0 disable
    user@PE1# set ldp interface lo0.0
    
  3. 使用 IPv4 VPN 单播地址族,启用内部 BGP (IBGP) 连接,以便仅与 RR 对等。

    content_copy zoom_out_map
    [edit protocols bgp group l3vpn]
    user@PE1# set type internal
    user@PE1# set local-address 10.255.2.2
    user@PE1# set family inet-vpn unicast
    user@PE1# set peer-as 65534
    user@PE1# set local-as 65534
    user@PE1# set neighbor 10.255.4.4
    
  4. 配置路由实例,包括 as-override 语句。

    在 PE 设备上创建路由实例 (VRF),并将 BGP 配置设置为与设备 CE1 对等。

    content_copy zoom_out_map
    [edit routing-instances VPN-A]
    user@PE1# set instance-type vrf
    user@PE1# set interface ge-1/2/0.0
    user@PE1# set route-distinguisher 65534:1234
    user@PE1# set vrf-target target:65534:1234
    user@PE1# set protocols bgp group CE type external
    user@PE1# set protocols bgp group CE family inet unicast
    user@PE1# set protocols bgp group CE neighbor 10.0.0.1 peer-as 64512
    user@PE1# set protocols bgp group CE neighbor 10.0.0.1 as-override
    
  5. 配置路由器 ID 和 AS 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@PE1# set router-id 10.255.2.2
    user@PE1# set autonomous-system 65534
    
结果

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

content_copy zoom_out_map
user@PE1# show interfaces
ge-1/2/0 {
    unit 2 {
        family inet {
            address 10.0.0.2/30;
        }
        family iso;
        family mpls;
    }
}
ge-1/2/1 {
    unit 5 {
        family inet {
            address 10.0.0.5/30;
        }
        family iso;
        family mpls;
    }
}
ge-1/2/2 {
    unit 21 {
        family inet {
            address 10.0.0.21/30;
        }
        family iso;
        family mpls;
    }
}
lo0 {
    unit 0 {
        family inet {
            address 10.255.2.2/32;
        }
        family iso {
            address 49.0001.0010.0000.0202.00;
        }
    }
}
content_copy zoom_out_map
user@PE1# show protocols
mpls {
    interface ge-1/2/2.0;
    interface ge-1/2/1.0;
    interface lo0.0;
    interface fxp0.0 {
        disable;
    }
}
bgp {
    group l3vpn {
        type internal;
        local-address 10.255.2.2;
        family inet-vpn {
            unicast;
        }
        peer-as 65534;
        local-as 65534;
        neighbor 10.255.4.4;
    }
}
isis {
    interface ge-1/2/1.0 {
        level 2 metric 10;
        level 1 disable;
    }
    interface ge-1/2/2.0 {
        level 2 metric 10;
        level 1 disable;
    }
    interface fxp0.0 {
        disable;
    }
    interface lo0.0 {
        level 2 metric 0;
    }
}
ldp {
    deaggregate;
    interface ge-1/2/1.0;
    interface ge-1/2/2.0;
    interface fxp0.0 {
        disable;
    }
    interface lo0.0;
}
content_copy zoom_out_map
user@PE1# show routing-instances
VPN-A {
    instance-type vrf;
    interface ge-1/2/0.0;
    route-distinguisher 65534:1234;
    vrf-target target:65534:1234;
    protocols {
        bgp {
            group CE {
                type external;
                family inet {
                    unicast;
                }
                neighbor 10.0.0.1 {
                    peer-as 64512;
                    as-override;
                }
            }
        }
    }
}
content_copy zoom_out_map
user@PE1# show routing-options
router-id 10.255.2.2;
autonomous-system 65534;

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

验证

确认配置工作正常。

检查到 CE 设备的 AS 路径

目的

在设备 PE1 上显示有关设备 CE2 环路接口路由的 AS 路径属性的信息。

操作

在设备 PE1 上,从操作模式输入 show route table VPN-A.inet.0 10.255.6.6 命令。

content_copy zoom_out_map
user@PE1> show route table VPN-A.inet.0 10.255.6.6
 

VPN-A.inet.0: 5 destinations, 6 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.255.6.6/32      *[BGP/170] 02:19:35, localpref 100, from 10.255.4.4
                      AS path: 64512 I, validation-state: unverified
                    > to 10.0.0.22 via ge-1/2/2.0, Push 300032, Push 299776(top)
意义

输出显示设备 PE1 具有来自 AS 64512 的 10.255.6.6/32 的 AS 路径。

检查如何通告到设备 CE2 的路由

目的

确保到设备 CE2 的路由已播发到设备 CE1,就像它来自 MPLS 核心一样。

操作

在设备 PE1 上,从操作模式输入 show route advertising-protocol bgp 10.0.0.1 命令。

content_copy zoom_out_map
user@PE1> show route advertising-protocol bgp 10.0.0.1
 
VPN-A.inet.0: 5 destinations, 6 routes (5 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 10.0.0.16/30            Self                                    I
* 10.255.1.1/32           10.0.0.1                                65534 I
* 10.255.6.6/32           Self                                    65534 I
意义

输出指示设备 PE1 在 AS 路径中仅播发自己的 AS 编号。

检查设备 CE1 上的路由

目的

确保设备 CE1 在通往设备 CE2 的路由的 AS 路径中仅包含提供程序 AS 编号。

操作

在操作模式下,输入 show route table inet.0 terse 10.255.6.6 命令。

content_copy zoom_out_map
user@CE1> show route table inet.0 terse 10.255.6.6

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

A V Destination        P Prf   Metric 1   Metric 2  Next hop        AS path
* ? 10.255.6.6/32      B 170        100                             65534 65534 I
  unverified                                       >10.0.0.2
意义

输出指示设备 CE1 具有到设备 CE2 的路由。循环问题可通过使用该 as-override 语句得到解决。

一个路由在 CE 设备上隐藏。这是因为 Junos OS 不执行 BGP 水平分割。通常,BGP 中的水平分割是不必要的,因为由于 AS 路径长度(对于 EBGP)、AS 路径环路检测 (IBGP) 或其他 BGP 指标,发起方可能接收回的任何路由都不太优先。将路由播发回从中获知的邻居对路由器性能的影响可以忽略不计,这是正确的做法。

示例:启用 BGP 路由通告

Junos OS 不会将从某个 EBGP 对等方获知的路由播发回同一个外部 BGP (EBGP) 对等方。此外,无论路由实例如何,软件都不会将这些路由播发至与始发对等方相同的自治系统 (AS) 中的任何 EBGP 对等方。您可以通过在配置中包含 advertise-peer-as 语句来修改此行为。

如果在配置中包含语句 advertise-peer-as ,则无论此检查如何,BGP 都会播发路由。

要恢复默认行为, no-advertise-peer-as 请在配置中包含该语句:

content_copy zoom_out_map

如果配置中包含路由 as-override 抑制缺省行为,则会禁用该语句。如果在配置中同时包含 and as-overrideno-advertise-peer-as 语句,则会忽略该 no-advertise-peer-as 语句。

要求

在配置此示例之前,不需要除设备初始化之外的特殊配置。

注:

此示例已在 Junos 21.2R1 版上更新并重新验证。

概述

此示例显示了具有外部 BGP (EBGP) 连接的三个路由设备。设备 R2 有一个到设备 R1 的 EBGP 连接,另一个连接到设备 R3 的 EBGP 连接。尽管被位于 AS 64511 中的设备 R2 分隔,但设备 R1 和设备 R3 在同一 AS (AS 64512) 中。设备 R1 和设备 R3 向 BGP 直接路由播发至各自的环路接口地址。

设备 R2 接收这些环路接口路由,并且该 advertise peer-as 语句允许设备 R2 通告这些路由。具体而言,设备 R1 将 192.168.0.1 路由发送到设备 R2,由于设备 R2 已配置, advertise peer-as 因此设备 R2 可以将 192.168.0.1 路由发送到设备 R3。同样,设备 R3 将 192.168.0.3 路由发送到设备 R2,并使 advertise peer-as 设备 R2 能够将路由转发到设备 R1。

要使设备 R1 和设备 R3 接受在 AS 路径中包含其自己的 AS 编号的路由,需要对 loops 2 设备 R1 和设备 R3 使用该语句。

拓扑学

图 6: 用于播发对等身份的 BGP 拓扑用于播发对等身份的 BGP 拓扑

配置

CLI 快速配置

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

设备 R1

content_copy zoom_out_map
set interfaces xe-0/2/0 description R1-to-R2
set interfaces xe-0/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 family inet unicast loops 2
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext peer-as 64511
set protocols bgp group ext neighbor 10.0.0.2
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64512

设备 R2

content_copy zoom_out_map
set interfaces xe-0/2/0 description R2-to-R1
set interfaces xe-0/2/0 unit 0 family inet address 10.0.0.2/30
set interfaces xe-0/2/1 description R2-to-R3
set interfaces xe-0/2/1 unit 0 family inet address 10.1.0.1/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 advertise-peer-as
set protocols bgp group ext export send-direct
set protocols bgp group ext neighbor 10.0.0.1 peer-as 64512
set protocols bgp group ext neighbor 10.1.0.2 peer-as 64512
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64511

设备 R3

content_copy zoom_out_map
set interfaces xe-0/2/0 description R3-to-R2
set interfaces xe-0/2/0 unit 0 family inet address 10.1.0.2/30
set interfaces lo0 unit 0 family inet address 192.168.0.3/32
set protocols bgp family inet unicast loops 2
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext peer-as 64511
set protocols bgp group ext neighbor 10.1.0.1
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set routing-options autonomous-system 64512

程序

分步过程

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

要配置设备 R1:

  1. 配置设备接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set xe-0/2/0 description R1-to-R2
    user@R1# set xe-0/2/0 unit 0 family inet address 10.0.0.1/30
    user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
    
  2. 配置 BGP。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R1# set type external
    user@R1# set peer-as 64511
    user@R1# set neighbor 10.0.0.2
    
  3. 通过包含 loops 2 语句,防止来自设备 R3 的路由在设备 R1 上被隐藏。

    loops 2 语句意味着本地设备自己的 AS 编号最多可以在 AS 路径中出现一次,而不会导致路由被隐藏。如果在路径中检测到本地设备的 AS 编号两次或更多次,则路由将被隐藏。

    content_copy zoom_out_map
    [edit protocols bgp family inet unicast]
    user@R1# set loops 2
    
  4. 配置发送直接路由的路由策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement send-direct term 1]
    user@R1# set from protocol direct
    user@R1# set then accept
    
  5. 将导出策略应用于与设备 R2 的 BGP 对等会话。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R1# set export send-direct
    
  6. 配置自治系统 (AS) 编号。

    content_copy zoom_out_map
    [edit routing-options ]
    user@R1# set autonomous-system 64512
    
分步过程

要配置设备 R2:

  1. 配置设备接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R2# set xe-0/2/0 description R2-to-R1
    user@R2# set xe-0/2/0 unit 0 family inet address 10.0.0.2/30
    user@R2# set xe-0/2/1 description R2-to-R3
    user@R2# set xe-0/2/1 unit 0 family inet address 10.1.0.1/30
    user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
    
  2. 配置 BGP。

    content_copy zoom_out_map
    [edit  protocols bgp group ext]
    user@R2# set type external
    user@R2# set neighbor 10.0.0.1 peer-as 64512
    user@R2# set neighbor 10.1.0.2 peer-as 64512
    
  3. 配置设备 R2,以从一个 EBGP 对等方获知的路由播发至同一 AS 中的另一个 EBGP 对等方。

    换句话说,播发至从设备 R3 获知的设备 R1 路由(反之亦然),即使设备 R1 和设备 R3 在同一 AS 中。

    content_copy zoom_out_map
    [edit  protocols bgp group ext]
    user@R2# set advertise-peer-as
    
  4. 配置发送直接路由的路由策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement send-direct term 1]
    user@R2# set from protocol direct
    user@R2# set then accept
    
  5. 应用导出策略。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R2# set export send-direct
    
  6. 配置 AS 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@R2# set autonomous-system 64511
    
结果

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

设备 R1

content_copy zoom_out_map
user@R1# show interfaces
xe-0/2/0 {
    description R1-to-R2;
    unit 0 {
        family inet {
            address 10.0.0.1/30;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.1/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show protocols
bgp {
    family inet {
        unicast {
            loops 2;
        }
    }
    group ext {
        type external;
        export send-direct;
        peer-as 64511;
        neighbor 10.0.0.2;
    }
}
content_copy zoom_out_map
user@R1# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
content_copy zoom_out_map
user@R1# show routing-options
autonomous-system 64512;

设备 R2

content_copy zoom_out_map
user@R2# show interfaces
xe-0/2/0 {
    description R2-to-R1;
    unit 0 {
        family inet {
            address 10.0.0.2/30;
        }
    }
}
xe-0/2/1 {
    description R2-to-R3;
    unit 0 {
        family inet {
            address 10.1.0.1/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;
        advertise-peer-as;
        export send-direct;
        neighbor 10.0.0.1 {
            peer-as 64512;
        }
        neighbor 10.1.0.2 {
            peer-as 64512;
        }
    }
}
content_copy zoom_out_map
user@R2# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
content_copy zoom_out_map
user@R2# show routing-options
autonomous-system 64511;

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

验证

确认配置工作正常。

验证 BGP 路由

目的

确保设备 R1 和设备 R3 上的路由表包含预期的路由。

操作
  1. 在设备 R2 上,停用 advertise-peer-as BGP 配置中的语句。

    content_copy zoom_out_map
    [edit  protocols bgp group ext]
    user@R2# deactivate advertise-peer-as
    user@R2# commit
    
  2. 在设备 R3 上,停用 loops BGP 配置中的语句。

    content_copy zoom_out_map
    [edit  protocols bgp family inet unicast ]
    user@R3# deactivate unicast loops 
    user@R3# commit
    
  3. 在设备 R1 上,检查向设备 R2 播发的路由。

    content_copy zoom_out_map
    user@R1> show route advertising-protocol bgp 10.0.0.2
    inet.0: 5 destinations, 6 routes (5 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 10.0.0.0/30             Self                                    I
    * 192.168.0.1/32          Self                                    I
    
  4. 在设备 R2 上,检查从设备 R1 接收的路由。

    content_copy zoom_out_map
    user@R2> show route receive-protocol bgp 10.0.0.1
    inet.0: 7 destinations, 9 routes (7 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
      10.0.0.0/30             10.0.0.1                                64512 I
    * 192.168.0.1/32          10.0.0.1                                64512 I
  5. 在设备 R2 上,检查向设备 R3 播发的路由。

    content_copy zoom_out_map
    user@R2> show route advertising-protocol bgp 10.1.0.2
    inet.0: 7 destinations, 9 routes (7 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 10.0.0.0/30             Self                                    I
    * 10.1.0.0/30             Self                                    I
    * 192.168.0.2/32          Self                                    I
    
  6. 在设备 R2 上,激活 advertise-peer-as BGP 配置中的语句。

    content_copy zoom_out_map
    [edit  protocols bgp group ext]
    user@R2# activate advertise-peer-as
    user@R2# commit
    
  7. 在设备 R2 上,重新检查播发到设备 R3 的路由。

    content_copy zoom_out_map
    user@R2> show route advertising-protocol bgp 10.1.0.2
    inet.0: 7 destinations, 9 routes (7 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 10.0.0.0/30             Self                                    I
    * 10.1.0.0/30             Self                                    I
    * 192.168.0.1/32          Self             64512 I
    * 192.168.0.2/32          Self                                    I
    * 192.168.0.3/32          10.1.0.2         64512 I
  8. 在设备 R3 上,检查从设备 R2 接收的路由。

    content_copy zoom_out_map
    user@R3> show route receive-protocol bgp 10.1.0.1
    inet.0: 5 destinations, 6 routes (5 active, 0 holddown, 0 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 10.0.0.0/30             10.1.0.1                                64511 I
      10.1.0.0/30             10.1.0.1                                64511 I
    * 192.168.0.2/32          10.1.0.1                                64511 I
  9. 在设备 R3 上,激活 loops BGP 配置中的语句。

    content_copy zoom_out_map
    [edit  protocols bgp family inet unicast ]
    user@R3# activate unicast loops 
    user@R3# commit
    
  10. 在设备 R3 上,重新检查从设备 R2 接收的路由。

    content_copy zoom_out_map
    user@R3> show route receive-protocol bgp 10.1.0.1
    inet.0: 6 destinations, 8 routes (6 active, 0 holddown, 1 hidden)
      Prefix                  Nexthop              MED     Lclpref    AS path
    * 10.0.0.0/30             10.1.0.1                                64511 I
      10.1.0.0/30             10.1.0.1                                64511 I
    * 192.168.0.1/32          10.1.0.1                                64511 64512 I
    * 192.168.0.2/32          10.1.0.1                                64511 I
    
意义

首先停用 advertise-peer-as 语句和 loops 语句,以便可以检查默认行为。设备 R1 向设备 R2 发送指向设备 R1 环路接口地址 192.168.0.1/32 的路由。设备 R2 不会将此路由播发到设备 R3。激活 advertise-peer-as 语句后,设备 R2 会将 192.168.0.1/32 路由播发至设备 R3。设备 R3 在激活语句之前 loops 不接受此路由。

禁用独立 AS 域的属性集消息,以便进行 BGP 环路检测

针对特定路由的 BGP 环路检测使用路由实例的本地自治系统 (AS) 域。默认情况下,所有路由实例都属于单个主路由实例域。因此,BGP 环路检测使用在所有路由实例上配置的本地 AS。根据您的网络配置,此默认行为可能会导致路由被循环和隐藏。

要限制主路由实例中的本地 AS,可以为路由实例配置独立 AS 域。独立域独立于主路由实例,可防止独立域的 AS 路径与其他域的 AS 路径和 AS 路径属性共享。

默认情况下,独立域使用传递路径属性 128(属性集)消息,通过内部 BGP (IBGP) 核心对独立域的 BGP 属性建立隧道。但是,在许多情况下,独立域的属性集消息行为是不需要的。如果只想配置独立域来保持路由实例中本地 AS 的独立性,并且仅对路由实例中指定的本地 AS 执行 BGP 环路检测,则可以禁用属性集消息。

要在独立域上禁用属性集消息,请包含以下 independent-domain no-attrset 语句:

  1. 选择包含要修改的独立域的路由实例。您可以从以下层次结构级别中选择路由实例:
    • [edit routing-instances routing-instance-name]

    • [edit logical-systems logical-system-name routing-instances routing-instance-name]

  2. 禁用独立域上的属性集消息。
    content_copy zoom_out_map
    [edit routing-instances instance-name]
    user@host# set routing-options autonomous-system as-number independent-domain no-attrset
    
    提示:

    禁用属性集消息时,建议您指定主路由实例的 AS 编号。这可确保主路由实例 AS 在路由实例中被视为本地 AS,并用于 BGP 环路检测。

为独立域指定路由实例后,本地 AS 仅与该路由实例关联。这意味着 BGP 环路检测仅使用路由实例中定义的本地 AS。

示例:选择最佳路径时忽略 AS 路径属性

如果存在到同一目标的多个 BGP 路由,BGP 将根据路径的路由属性选择最佳路径。影响最佳路径决策的路由属性之一是每个路由的 AS 路径长度。AS 路径更短的路由优先于 AS 路径更长的路由。尽管通常不实用,某些情景可能要求在路由选择过程中忽略 AS 路径长度。此示例说明了如何配置路由设备以忽略 AS 路径属性。

要求

在配置此示例之前,不需要除设备初始化之外的特殊配置。

概述

在外部连接的路由设备上,跳过 AS 路径比较的目的可能是强制外部 BGP (EBGP) 与内部 BGP (IBGP) 决策尽快从网络中删除流量。在内部连接的路由设备上,您可能希望仅 IBGP 路由器默认为本地外部连接的网关。本地仅支持 IBGP(内部)路由器会跳过 AS 路径比较,并在决策树中向下移动,以使用最近的内部网关协议 (IGP) 网关(最低 IGP 指标)。这样做可能是强制这些路由器使用 LAN 连接而不是其 WAN 连接的有效方法。

警告:

在网络中的路由设备上包含语句 as-path-ignore 时,可能需要将其包含在网络中所有其他启用了 BGP 的设备上,以防止出现路由环路和收敛问题。对于 IBGP 路径比较尤其如此。

在此示例中,设备 R2 从设备 R1 和设备 R3 了解设备 R4 (10.4.4.4/32) 上的环路接口地址。设备 R1 播发 10.4.4.4/32,AS 路径为 65001 65005 65004,设备 R3 播发 10.4.4.4/32,AS 路径为 65003 65004。设备 R2 从设备 R3 中选择 10.4.4.4/32 的路径作为最佳路径,因为 AS 路径比设备 R1 中的 AS 路径短。

此示例修改设备 R2 上的 BGP 配置,以便最佳路径选择中不使用 AS 路径长度。

设备 R1 的路由器 ID (10.1.1.1) 低于设备 R3 (10.3.3.3)。如果所有其他路径选择标准相等(或在本例中被忽略),则使用从设备 R1 获知的路由。由于 AS 路径属性会被忽略,因此最佳路径是指向设备 R1,因为它的路由器 ID 值较低。

图 7 显示了示例拓扑。

图 7: 用于忽略 AS 路径长度的拓扑用于忽略 AS 路径长度的拓扑

配置

CLI 快速配置

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

设备 R1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 1 family inet address 192.168.10.1/24
set interfaces fe-1/2/1 unit 10 family inet address 192.168.50.2/24
set interfaces lo0 unit 1 family inet address 10.1.1.1/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext export send-local
set protocols bgp group ext neighbor 192.168.10.2 peer-as 65002
set protocols bgp group ext neighbor 192.168.50.1 peer-as 65005
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-local term 1 from protocol local
set policy-options policy-statement send-local term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.20.0/24 next-hop 192.168.10.2
set routing-options static route 192.168.30.0/24 next-hop 192.168.10.2
set routing-options static route 192.168.40.0/24 next-hop 192.168.50.1
set routing-options router-id 10.1.1.1
set routing-options autonomous-system 65001

设备 R2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 2 family inet address 192.168.10.2/24
set interfaces fe-1/2/1 unit 3 family inet address 192.168.20.2/24
set interfaces lo0 unit 2 family inet address 10.2.2.2/32
set protocols bgp path-selection as-path-ignore
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext export send-local
set protocols bgp group ext neighbor 192.168.10.1 peer-as 65001
set protocols bgp group ext neighbor 192.168.20.1 peer-as 65003
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-local term 1 from protocol local
set policy-options policy-statement send-local term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.50.0/24 next-hop 192.168.10.1
set routing-options static route 192.168.40.0/24 next-hop 192.168.10.1
set routing-options static route 192.168.30.0/24 next-hop 192.168.20.1
set routing-options router-id 10.2.2.2
set routing-options autonomous-system 65002

设备 R3

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 4 family inet address 192.168.20.1/24
set interfaces fe-1/2/1 unit 5 family inet address 192.168.30.1/24
set interfaces lo0 unit 3 family inet address 10.3.3.3/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext export send-local
set protocols bgp group ext neighbor 192.168.20.2 peer-as 65002
set protocols bgp group ext neighbor 192.168.30.2 peer-as 65004
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-local term 1 from protocol local
set policy-options policy-statement send-local term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.10.0/24 next-hop 192.168.20.2
set routing-options static route 192.168.50.0/24 next-hop 192.168.20.2
set routing-options static route 192.168.40.0/24 next-hop 192.168.30.2
set routing-options router-id 10.3.3.3
set routing-options autonomous-system 65003

设备 R4

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 6 family inet address 192.168.30.2/24
set interfaces fe-1/2/1 unit 7 family inet address 192.168.40.1/24
set interfaces lo0 unit 4 family inet address 10.4.4.4/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext export send-local
set protocols bgp group ext neighbor 192.168.30.1 peer-as 65003
set protocols bgp group ext neighbor 192.168.40.2 peer-as 65005
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-local term 1 from protocol local
set policy-options policy-statement send-local term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.10.0/24 next-hop 192.168.40.2
set routing-options static route 192.168.50.0/24 next-hop 192.168.40.2
set routing-options static route 192.168.40.0/24 next-hop 192.168.30.1
set routing-options router-id 10.4.4.4
set routing-options autonomous-system 65004

设备 R5

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 8 family inet address 192.168.40.2/24
set interfaces fe-1/2/1 unit 9 family inet address 192.168.50.1/24
set interfaces lo0 unit 5 family inet address 10.5.5.5/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext export send-local
set protocols bgp group ext neighbor 192.168.40.1 peer-as 65004
set protocols bgp group ext neighbor 192.168.50.2 peer-as 65001
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-local term 1 from protocol local
set policy-options policy-statement send-local term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.10.0/24 next-hop 192.168.50.2
set routing-options static route 192.168.20.0/24 next-hop 192.168.50.2
set routing-options static route 192.168.30.0/24 next-hop 192.168.40.1
set routing-options router-id 10.5.5.5
set routing-options autonomous-system 65005

配置设备 R2

分步过程

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

要配置设备 R2:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R2# set fe-1/2/0 unit 2 family inet address 192.168.10.2/24
    user@R2# set fe-1/2/1 unit 3 family inet address 192.168.20.2/24
    user@R2# set lo0 unit 2 family inet address 10.2.2.2/32
    
  2. 配置 EBGP。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R2# set type external
    user@R2# set export send-direct
    user@R2# set export send-static
    user@R2# set export send-local
    user@R2# set neighbor 192.168.10.1 peer-as 65001
    user@R2# set neighbor 192.168.20.1 peer-as 65003
    
  3. 配置在 Junos OS 路径选择算法中要忽略的自治系统 (AS) 路径属性。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@R2# set path-selection as-path-ignore
    
  4. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@R2# set policy-statement send-direct term 1 from protocol direct
    user@R2# set policy-statement send-direct term 1 then accept
    user@R2# set policy-statement send-local term 1 from protocol local
    user@R2# set policy-statement send-local term 1 then accept
    user@R2# set policy-statement send-static term 1 from protocol static
    user@R2# set policy-statement send-static term 1 then accept
    
  5. 配置一些静态路由。

    content_copy zoom_out_map
    [edit routing-options static]
    user@R2# set route 192.168.50.0/24 next-hop 192.168.10.1
    user@R2# set route 192.168.40.0/24 next-hop 192.168.10.1
    user@R2# set route 192.168.30.0/24 next-hop 192.168.20.1
    
  6. 配置自治系统 (AS) 编号和路由器 ID。

    content_copy zoom_out_map
    [edit routing-options]
    user@R2# set router-id 10.2.2.2
    user@R2# set autonomous-system 65002
    
结果

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

content_copy zoom_out_map
user@R2# show interfaces
fe-1/2/0 {
    unit 2 {
        family inet {
            address 192.168.10.2/24;
        }
    }
}
fe-1/2/1 {
    unit 3 {
        family inet {
            address 192.168.20.2/24;
        }
    }
}
lo0 {
    unit 2 {
        family inet {
            address 10.2.2.2/32;
        }
    }
}
content_copy zoom_out_map
user@R2# show policy-options
policy-statement send-direct {
    term 1 {
        from protocol direct;
        then accept;
    }
}
policy-statement send-local {
    term 1 {
        from protocol local;
        then accept;
    }
}
policy-statement send-static {
    term 1 {
        from protocol static;
        then accept;
    }
}
content_copy zoom_out_map
user@R2# show protocols
bgp {
    path-selection as-path-ignore;
    group ext {
        type external;
        export [ send-direct send-static send-local ];
        neighbor 192.168.10.1 {
            peer-as 65001;
        }
        neighbor 192.168.20.1 {
            peer-as 65003;
        }
    }
}
content_copy zoom_out_map
user@R2# show routing-options
static {
    route 192.168.50.0/24 next-hop 192.168.10.1;
    route 192.168.40.0/24 next-hop 192.168.10.1;
    route 192.168.30.0/24 next-hop 192.168.20.1;
}
router-id 10.2.2.2;
autonomous-system 65002;

如果完成设备配置,请从配置模式输入 commit。在网络中的其他设备上重复配置,根据需要更改接口名称和 IP 地址。

验证

确认配置工作正常。

检查邻居状态

目的

确保从设备 R2 到 AS 4 的活动路径通过 AS 65001 和 AS 65005,而不是通过 AS 65003。

注:

要验证语句的功能 as-path-ignore ,您可能需要运行 restart routing 命令以强制重新评估活动路径。这是因为对于 BGP,如果两个路径都是外部路径,则 Junos OS 的行为是首选当前活动的路径。此行为有助于最大程度地减少路由摆动。在生产网络中重新启动路由协议进程时要小心。

操作

在操作模式下,输入 restart routing 命令。

content_copy zoom_out_map
user@R2> restart routing
Routing protocols process started, pid 49396

在操作模式下,输入 show route 10.4.4.4 protocol bgp 命令。

content_copy zoom_out_map
user@R2> show route 10.4.4.4 protocol bgp
inet.0: 12 destinations, 25 routes (12 active, 0 holddown, 4 hidden)
+ = Active Route, - = Last Active, * = Both

10.4.4.4/32         *[BGP/170] 00:00:12, localpref 100
                      AS path: 65001 65005 65004 I
                    > to 192.168.10.1 via fe-1/2/0.2
                    [BGP/170] 00:00:08, localpref 100
                      AS path: 65003 65004 I
                    > to 192.168.20.1 via fe-1/2/1.3
意义

星号 (*) 位于从 R1 获知的路径旁边,表示这是活动路径。活动路径的 AS 路径为 65001 65005 65004,比从路由器 R3 获知的非活动路径的 AS 路径 (65003 65004) 长。

了解如何从 AS 路径中移除专用 AS 编号

默认情况下,当 BGP 将 AS 路径播发至远程系统时,将包含所有 AS 编号,其中包括专用 AS 编号。您可以配置软件,以便从 AS 路径中删除专用 AS 编号。当满足以下任一情况时,执行此操作很有用:

  • 您为其提供连接的远程 AS 是多宿主的,但仅限于本地 AS。

  • 远程 AS 没有正式分配的 AS 编号。

  • 不宜将远程 AS 作为本地 AS 的联合体成员 AS。

大多数公司都有自己的 AS 编号。一些公司还使用专用 AS 编号来连接到其公共 AS 网络。对于开展业务的每个地区,这些公司可能会使用不同的专用 AS 编号。在任何实施中,都须避免在互联网公布专用 AS 编号。服务提供商可以使用该 remove-private 语句来防止在互联网上播发专用 AS 编号。

在企业场景中,假设您的公司有多个 AS 编号,其中有些是专用 AS 编号,有一个则使用公共 AS 编号。具有公共 AS 编号的那个与服务提供商有直接连接。在直接连接到服务提供商的 AS 中,可以使用该 remove-private 语句过滤掉发送到服务提供商的播发中的任何专用 AS 编号。

AS 编号将从 AS 路径的左端(最近添加 AS 路径的一端)开始去除。当路由设备找到第一个非专用 AS 或对等方的专用 AS 时,它会停止搜索专用 AS。如果 AS 路径包含外部 BGP (EBGP) 邻接方的 AS 编号,则 BGP 不会移除专用 AS 编号。

注:

从 Junos OS 10.0R2 及更高版本开始,如果需要将前缀发送到 AS 编号与 AS 路径中的 AS 编号匹配的 EBGP 对等方,请考虑使用 as-override 语句而不是 remove-private 语句。

如果适用,当已从 AS 路径中移除任何联合体成员 AS 后,将发生该操作。

软件预先配置了被视为专用的 AS 编号集,即在互联网编号分配机构 (IANA) 编号分配文档中定义的范围。保留为专用的 16 位 AS 编号集的范围为 64,512 到 65,534(含)。保留为专用的 32 位 AS 编号的范围是 4,200,000,000 到 4,294,967,294(含)。

示例:从 AS 路径中移除专用 AS 编号

此示例演示了如何从播发的 AS 路径中移除专用 AS 编号,以避免在互联网上公布该专用 AS 编号。

要求

在配置此示例之前,不需要除设备初始化之外的特殊配置。

概述

服务提供商和企业网络使用该语句来 remove-private 防止在互联网上播发专用 AS 编号。该 remove-private 语句在出站方向上工作。您可以在具有公有 AS 编号且连接到一个或多个具有专用 AS 编号的设备上的设备上配置 remove-private 语句。通常,您不能在具有专用 AS 编号的设备上配置此语句。

图 8 显示了示例拓扑。

图 8: 用于从播发 AS 路径中移除专用 AS 的拓扑用于从播发 AS 路径中移除专用 AS 的拓扑

在此示例中,设备 R1 使用专用 AS 编号 65530 连接到其服务提供商。示例显示了在设备 ISP 上配置的语句,以防止 remove-private 将设备 R1 的专用 AS 编号通告给设备 R2。设备 R2 仅看到服务提供商的 AS 编号。

注:

添加或删除 BGP 选项 remove-private 将导致受影响的 BGP 对等会话抖动。

配置

CLI 快速配置

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

设备 R1

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 1 family inet address 192.168.10.1/24
set interfaces lo0 unit 1 family inet address 10.10.10.1/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext peer-as 100
set protocols bgp group ext neighbor 192.168.10.10
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.20.0/24 next-hop 192.168.10.10
set routing-options autonomous-system 65530

设备 ISP

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 2 family inet address 192.168.10.10/24
set interfaces fe-1/2/1 unit 3 family inet address 192.168.20.20/24
set interfaces lo0 unit 2 family inet address 10.10.0.1/32
set protocols bgp group ext type external
set protocols bgp group ext neighbor 192.168.10.1 peer-as 65530
set protocols bgp group ext neighbor 192.168.20.1 remove-private
set protocols bgp group ext neighbor 192.168.20.1 peer-as 200
set routing-options autonomous-system 100

设备 R2

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 4 family inet address 192.168.20.1/24
set interfaces lo0 unit 3 family inet address 10.10.20.1/32
set protocols bgp group ext type external
set protocols bgp group ext export send-direct
set protocols bgp group ext export send-static
set protocols bgp group ext peer-as 100
set protocols bgp group ext neighbor 192.168.20.20
set policy-options policy-statement send-direct term 1 from protocol direct
set policy-options policy-statement send-direct term 1 then accept
set policy-options policy-statement send-static term 1 from protocol static
set policy-options policy-statement send-static term 1 then accept
set routing-options static route 192.168.10.0/24 next-hop 192.168.20.20
set routing-options autonomous-system 200

设备 ISP

分步过程

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

要配置设备 ISP:

  1. 配置接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@ISP# set fe-1/2/0 unit 2 family inet address 192.168.10.10/24
    user@ISP# set fe-1/2/1 unit 3 family inet address 192.168.20.20/24
    user@ISP# set lo0 unit 2 family inet address 10.10.0.1/32
    
  2. 配置 EBGP。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@ISP# set type external
    user@ISP# set neighbor 192.168.10.1 peer-as 65530
    user@ISP# set neighbor 192.168.20.1 peer-as 200
    
  3. 对于自治系统 (AS) 200 中的邻接方(设备 R2),请从播发的 AS 路径中移除专用 AS 编号。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@ISP# set neighbor 192.168.20.1 remove-private
    
  4. 配置 AS 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@ISP# set autonomous-system 100
    
结果

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

content_copy zoom_out_map
user@ISP# show interfaces
fe-1/2/0 {
    unit 2 {
        family inet {
            address 192.168.10.10/24;
        }
    }
}
fe-1/2/1 {
    unit 3 {
        family inet {
            address 192.168.20.20/24;
        }
    }
}
lo0 {
    unit 2 {
        family inet {
            address 10.10.0.1/32;
        }
    }
}
content_copy zoom_out_map
user@ISP# show protocols
bgp {
    group ext {
        type external;
        neighbor 192.168.10.1 {
            peer-as 65530;
        }
        neighbor 192.168.20.1 {
            remove-private;
            peer-as 200;
        }
    }
}
content_copy zoom_out_map
user@ISP# show routing-options
autonomous-system 100;

如果完成设备配置,请从配置模式输入 commit。对设备 R1 和设备 R2 重复配置,根据需要更改接口名称和 IP 地址,然后添加路由策略配置。

验证

确认配置工作正常。

检查邻居状态

目的

确保设备 ISP remove-private 在其与设备 R2 的邻居会话中启用了该设置。

操作

在操作模式下,输入 show bgp neighbor 192.168.20.1 命令。

content_copy zoom_out_map
user@ISP> show bgp neighbor 192.168.20.1
Peer: 192.168.20.1+179 AS 200  Local: 192.168.20.20+60216 AS 100  
  Type: External    State: Established    Flags: <ImportEval Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Options: <Preference RemovePrivateAS PeerAS Refresh>
  Holdtime: 90 Preference: 170
  Number of flaps: 0
  Peer ID: 10.10.20.1      Local ID: 10.10.0.1         Active Holdtime: 90
  Keepalive Interval: 30         Peer index: 0   
  BFD: disabled, down
  Local Interface: fe-1/2/1.3                       
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Stale routes from peer are kept for: 300
  Peer does not support Restarter functionality
  NLRI that restart is negotiated for: inet-unicast
  NLRI of received end-of-rib markers: inet-unicast
  NLRI of all end-of-rib markers sent: inet-unicast
  Peer supports 4 byte AS extension (peer-as 200)
  Peer does not support Addpath
  Table inet.0 Bit: 10001
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              1
    Received prefixes:            3
    Accepted prefixes:            2
    Suppressed due to damping:    0
    Advertised prefixes:          1
  Last traffic (seconds): Received 10   Sent 16   Checked 55  
  Input messages:  Total 54     Updates 3       Refreshes 0     Octets 1091
  Output messages: Total 54     Updates 1       Refreshes 0     Octets 1118
  Output Queue[0]: 0
意义

RemovePrivateAS 选项显示设备 ISP 具有预期的设置。

检查路由表

目的

请确保设备具有预期的路由和 AS 路径。

操作

在操作模式下,输入 show route protocol bgp 命令。

content_copy zoom_out_map
user@R1> show route protocol bgp
inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.10.20.1/32      *[BGP/170] 00:28:57, localpref 100
                      AS path: 100 200 I
                    > to 192.168.10.10 via fe-1/2/0.1
content_copy zoom_out_map
user@ISP> show route protocol bgp

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

10.10.10.1/32      *[BGP/170] 00:29:40, localpref 100
                      AS path: 65530 I
                    > to 192.168.10.1 via fe-1/2/0.2
10.10.20.1/32      *[BGP/170] 00:29:36, localpref 100
                      AS path: 200 I
                    > to 192.168.20.1 via fe-1/2/1.3
192.168.10.0/24     [BGP/170] 00:29:40, localpref 100
                      AS path: 65530 I
                    > to 192.168.10.1 via fe-1/2/0.2
192.168.20.0/24     [BGP/170] 00:29:36, localpref 100
                      AS path: 200 I
                    > to 192.168.20.1 via fe-1/2/1.3
content_copy zoom_out_map
user@R2> show route protocol bgp
inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.10.10.1/32      *[BGP/170] 00:29:53, localpref 100
                      AS path: 100 I
                    > to 192.168.20.20 via fe-1/2/0.4
意义

设备 ISP 在到设备 R1 的 AS 路径中具有专用 AS 编号 65530。但是,设备 ISP 不会将此专用 AS 编号播发至设备 R2。这显示在设备 R2 的路由表中。设备 R2 到设备 R1 的路径仅包含设备 ISP 的 AS 编号。

当 remove-private 语句停用时,检查 AS 路径

目的

验证不使用语句时 remove-private ,专用 AS 编号是否显示在设备 R2 的路由表中。

操作

在设备 ISP 上的配置模式下,输入 deactivate remove-private 命令,然后重新检查设备 R2 上的路由表。

content_copy zoom_out_map
[protocols bgp group ext neighbor 192.168.20.1]
user@ISP# deactivate remove-private
user@ISP# commit
content_copy zoom_out_map
user@R2> show route protocol bgp
inet.0: 5 destinations, 5 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.10.10.1/32      *[BGP/170] 00:00:54, localpref 100
                      AS path: 100 65530 I
                    > to 192.168.20.20 via fe-1/2/0.4
意义

专用 AS 编号 65530 显示在设备 R2 到设备 R1 的 AS 路径中。

变更历史表

是否支持某项功能取决于您使用的平台和版本。 使用 Feature Explorer 查看您使用的平台是否支持某项功能。

版本
说明
20.2R1
从版本 20.2R1 开始,Junos OS 支持将 AIGP 指标转换为 MED。如果您希望 MED 承载端到端 AIGP 指标值(用于选择最佳路径),则可以启用此功能。
footer-navigation