帮助我们改善您的体验。

让我们了解您的想法。

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

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 更新消息的错误处理

当任何一个消息属性格式不正确时,BGP 消息被视为格式不正确。当参与 BGP 会话的路由器收到格式错误的更新消息时,默认情况下将重置整个会话。这是不可取的,因为具有有效路由的更新消息也会受到影响。若要避免此不良行为,需要修改 BGP 更新消息的错误处理。

要为 BGP 更新消息配置错误处理,请在 、 [edit protocols bgp group group-name][edit protocols bgp group group-name neighbor address]层次结构级别配置bgp-error-tolerance语句[edit protocols bgp]

content_copy zoom_out_map
bgp-error-tolerance {
    malformed-route-limit number;
    malformed-update-log-interval seconds;
    no-malformed-route-limit;
}

如果属性包含与“属性类型”字段的值冲突的属性标志,则会将属性标志重置为正确的值并处理更新消息。属性标志中的扩展长度位的值保持不变,因为此值定义属性长度是 1 个还是两个八位位组。因此,属性标志的值会影响 BGP 更新数据包的分析方式。

注:

对于路径属性的属性标志值,没有显式规范。

从 Junos OS 24.2R1 版开始,默认情况下会启用 BGP 错误处理。您仍然可以在此配置语句下配置子选项,如、 malformed-route-limitmalformed-update-log-intervalno-malformed-route-limit 。请注意,如果删除该 bgp-error-tolerance 语句,该功能仍将保持启用状态,并且子选项将重置为其默认值。

格式错误的更新消息将根据具体情况进行处理,具体取决于消息中包含的属性值。有三种方法可以处理格式错误的 BGP 更新消息,按严重性降序列出。

  1. Notification message approach— 格式错误的消息错误将记录在本地,错误代码更新消息将发送到对等方的管理部门,并重置整个 BGP 会话。

    在以下情况下选择此方法:

    • BGP 更新消息包含 MP 到达属性或 MP 不到达属性。

    • 由于属性长度与属性长度字段的值不匹配,因此无法正确解析 NLRI 字段或 BGP 更新消息。

  2. Treat-as-withdraw approach— 格式错误的更新消息中的所有路由都将被视为隐藏路由,除非配置了 keep none 语句,在这种情况下,路由将被丢弃。在没有该语句的情况下 keep none ,将配置一个限制,当超过限制时,将丢弃路由并防止隐藏任何进一步的格式错误路由。当达到格式错误的路由限制时,Junos OS 会删除新收到的格式错误的路由。

  3. Attribute discard approach- 更新消息中的格式错误属性将被丢弃;但是,将处理该消息。如果要丢弃的属性会影响路由选择或安装,则不建议使用此方法。

    注:

    如果某个属性在更新消息中多次出现,则该属性的所有匹配项(第一次除外)都将被丢弃,并处理该消息。

将扫描 BGP 更新消息以查找以下属性,并根据这些属性的值将其视为格式不正确:

  • The origin attribute——采用“即退即收”方法处理。

  • The AS path attribute——采用“即退即收”方法处理。

  • The AS 4 path attribute- 由属性丢弃方法处理。

  • The aggregator attribute- 由属性丢弃方法处理。

  • The aggregator 4 attribute- 由属性丢弃方法处理。

  • The next-hop attribute——采用“即退即收”方法处理。

  • The multiple exit discriminator attribute——采用“即退即收”方法处理。

  • The local preference attribute——采用“即退即收”方法处理。

  • The atomic aggregate attribute- 由属性丢弃方法处理。

  • The community attribute——采用“即退即收”方法处理。

  • The extended community attribute——采用“即退即收”方法处理。

  • The originator attribute——采用“即退即收”方法处理。

  • The cluster attribute——采用“即退即收”方法处理。

  • The PMSI attribute——采用“即退即收”方法处理。

  • The MP reach attribute- 由通知消息方法处理。

  • The MP unreach attribute- 由通知消息方法处理。

  • The attribute set attribute——采用“即退即收”方法处理。

  • The AIGP attribute——采用“即退即收”方法处理。

  • Unknown attribute—如果 BGP 标志未指示这是可选属性,则此格式不正确的属性将由通知消息方法处理。

注:

当 BGP 更新消息包含多个格式错误的属性时,将遵循由其中一个属性触发的最严重方法。

下面是 BGP 错误消息输出的示例:

content_copy zoom_out_map
user@R1> show log messages
Sep 18 17:54:13 R1 rpd[86600]: Received malformed update from 10.10.10.2 (External AS 64511) 
Sep 18 17:54:13 R1 rpd[86600]: Family inet-unicast, prefix 100.1.1.0/24 
Sep 18 17:54:13 R1 rpd[86600]: Malformed Attribute ORIGIN(1) flag 0x40 length 1 error 6 (Unrecognized ORIGIN attribute). 
Sep 18 17:54:13 R1 rpd[86600]: Malformed Attribute LOCAL_PREF(5) flag 0x40 length 6 error 5 (Attribute length error).

在此示例中,您会看到源 (ORIGIN) 和本地首选项 (LOCAL_PREF) 格式错误的属性。

示例:配置 BGP 更新消息的错误处理

此示例演示如何配置 BGP 错误处理。

要求

准备工作:

  • 配置路由器接口。

  • 配置内部网关协议 (IGP)。

  • 配置 BGP。

  • 配置路由策略。

概述

当路由设备收到具有格式错误属性的更新消息时,路由器需要重置会话。这在 RFC 4271 边界 网关协议 4 (BGP-4) 中指定。会话重置不仅会影响具有违规属性的路由,还会影响通过会话交换的其他有效路由。此外,在可选传递属性的情况下,此行为可能会出现潜在的安全漏洞。为了最大程度地减少格式错误的更新消息对路由的影响,互联网草案draft-ietf-idr-error-handling-01.txt BGP 更新消息的修订错误处理 指定了处理具有格式错误属性的 BGP 更新消息的修改。新的错误处理允许维护已建立的会话并保持交换的有效路由,同时删除格式错误的 UPDATE 消息中携带的路由。

拓扑学

在 中 图 1,设备 R1 与设备 R0 具有内部 BGP 对等会话,与设备 R2 具有外部 BGP 对等会话。

图 1: BGP 错误处理示例拓扑BGP 错误处理示例拓扑

为了防止格式错误的更新消息导致网络不稳定,设备 R1 配置了 BGP 错误处理,如下所示:

content_copy zoom_out_map
bgp-error-tolerance {
    malformed-update-log-interval 10;
    malformed-route-limit 5;
}

默认情况下,当任何一个消息属性格式不正确时,BGP 消息将被视为格式不正确。当参与 BGP 会话的路由器收到格式错误的更新消息时,将重置整个会话。该 bgp-error-tolerance 语句将覆盖此行为,以便以下 BGP 错误处理生效:

  • 对于致命错误,Junos OS 会发送标题为“错误代码更新消息”的通知消息,并重置 BGP 会话。MP_{UN}REACH 属性中的错误被视为致命错误。一个 BGP 更新中存在多个 MP_{UN}REACH 属性也被视为致命错误。如果 Junos OS 无法正确解析 NLRI 字段或 BGP 更新,则会重置 BGP 会话。当属性长度与属性值的长度不匹配时,可能会发生解析 BGP 更新数据包失败的情况。

  • 对于某些非致命错误,Junos OS 会将格式错误的 BGP 更新消息中包含的所有路由视为撤回的路由,并将其安装为隐藏,除非该 keep none 语句包含在 BGP 配置中。Junos OS 对涉及以下任何属性的情况使用此错误处理方法:ORIGIN、AS_PATH、NEXT_HOP、MULTI_EXIT_DISC、LOCAL_PREF、ORIGINATOR、 CLUSTER、ATTRSET、PMSI、社区和扩展社区。此外,如果缺少任何必需的已知路径属性,Junos OS 会将 BGP 更新视为格式不正确。为了限制这些格式错误的隐藏路由的内存使用,Junos OS 在达到此类格式错误的隐藏路由的最大数量后,将停止安装新的格式错误的隐藏路由。在此示例中,使用语句将 malformed-route-limit 最大数量设置为 5。默认值为 1000。或者,您可以允许由于格式错误的属性而隐藏无限数量的路由。通过包含 no-malformed-route-limit 语句来执行此操作。

  • 对于其他非致命错误,Junos OS 会丢弃格式错误的路径属性,并继续处理 BGP 更新消息。对可能影响路由选择或安装的路径属性使用此方法不安全。Junos OS 对涉及以下任何属性的情况使用此错误处理方法:ATOMIC_AGGREGATE、聚合器、AGGREGATOR4和AS4PATH。

为了便于对格式错误的数据包进行故障排除,Junos OS 会记录错误,其中列出了格式错误的路径属性代码、标志、长度、有关对等方和家族的信息,以及格式错误的 BGP 更新中的第一个前缀。如果在短时间内收到大量格式错误的数据包,则记录格式错误的数据包可能会降低 Junos OS 的性能。为了限制性能影响,Junos OS 实施了一种算法来记录格式错误的更新,在一段时间内抑制日志记录,并记录摘要。当日志记录抑制计时器过期时,软件将记录在时间间隔内收到的格式错误的属性的总数。在此示例中,计时器使用语句设置为 malformed-update-log-interval 10 秒。默认值为 300 秒(5 分钟)。

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

#d203e118__d203e309本节介绍设备 R1 上的步骤。

配置

CLI 快速配置

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

设备 R0

content_copy zoom_out_map
set  interfaces fe-1/2/0 unit 0 description to-R1
set  interfaces fe-1/2/0 unit 0 family inet address 172.16.10.5/30
set  interfaces lo0 unit 0 family inet address 192.168.0.3/32
set  protocols bgp group internal-peers type internal
set  protocols bgp group internal-peers local-address 192.168.0.3
set  protocols bgp group internal-peers export local-direct
set  protocols bgp group internal-peers neighbor 192.168.0.1
set  protocols ospf area 0.0.0.0 interface fe-1/2/0.0
set  protocols ospf area 0.0.0.0 interface lo0.0 passive
set  policy-options policy-statement local-direct from protocol [local direct]
set  policy-options policy-statement local-direct then accept
set  routing-options autonomous-system 64510
set  routing-options router-id 192.168.0.3

设备 R1

content_copy zoom_out_map
set  interfaces fe-1/2/1 unit 0 description to-R2
set  interfaces fe-1/2/1 unit 0 family inet address 10.10.10.1/30
set  interfaces fe-1/2/0 unit 0 description to-R0
set  interfaces fe-1/2/0 unit 0 family inet address 172.16.10.6/30
set  interfaces lo0 unit 0 family inet address 192.168.0.1/32
set  protocols bgp bgp-error-tolerance malformed-update-log-interval 10
set  protocols bgp bgp-error-tolerance malformed-route-limit 5
set  protocols bgp group internal-peers type internal
set  protocols bgp group internal-peers local-address 192.168.0.1
set  protocols bgp group internal-peers export local-direct
set  protocols bgp group internal-peers neighbor 192.168.0.3
set  protocols bgp group external-peers type external
set  protocols bgp group external-peers export local-direct
set  protocols bgp group external-peers peer-as 64511
set  protocols bgp group external-peers neighbor 10.10.10.2
set  protocols ospf area 0.0.0.0 interface fe-1/2/1.0
set  protocols ospf area 0.0.0.0 interface fe-1/2/0.0
set  protocols ospf area 0.0.0.0 interface lo0.0 passive
set  policy-options policy-statement local-direct from protocol [local direct]
set  policy-options policy-statement local-direct then accept
set  routing-options autonomous-system 64510
set  routing-options router-id 192.168.0.1

设备 R2

content_copy zoom_out_map
set  interfaces fe-1/2/1 unit 0 description to-R1
set  interfaces fe-1/2/1 unit 0 family inet address 10.10.10.2/30
set  interfaces lo0 unit 0 family inet address 192.168.0.2/32
set  protocols bgp group external-peers type external
set  protocols bgp group external-peers export local-direct
set  protocols bgp group external-peers peer-as 64510
set  protocols bgp group external-peers neighbor 10.10.10.1
set  protocols ospf area 0.0.0.0 interface fe-1/2/1.0
set  protocols ospf area 0.0.0.0 interface lo0.0 passive
set  policy-options policy-statement local-direct from protocol [local direct]
set  policy-options policy-statement local-direct then accept
set  routing-options autonomous-system 64511
set  routing-options router-id 192.168.10.2

程序

分步过程

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

要配置 BGP 错误处理,请执行以下操作:

  1. 配置路由器接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set fe-1/2/1 unit 0 description to-R2
    user@R1# set fe-1/2/1 unit 0 family inet address 10.10.10.1/30
    user@R1# set fe-1/2/0 unit 0 description to-R0
    user@R1# set fe-1/2/0 unit 0 family inet address 172.16.10.6/30
    user@R1# set lo0 unit 0 family inet address 192.168.0.1/32
    
  2. 配置内部网关协议 (IGP),例如 OSPF 或 IS-IS。

    content_copy zoom_out_map
    [edit protocols ospf area 0.0.0.0]
    user@R1# set interface fe-1/2/1.0
    user@R1# set interface fe-1/2/0.0
    user@R1# set interface lo0.0 passive
    
  3. 配置自治系统 (AS) 编号和路由器 ID。

    content_copy zoom_out_map
    [edit routing-options]
    user@R1# set autonomous-system 64510
    user@R1# set router-id 192.168.0.1
    
  4. 配置路由策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement local-direct]
    user@R1# set from protocol [local direct]
    user@R1# set then accept
    
  5. 配置 EBGP 会话。

    content_copy zoom_out_map
    [edit protocols bgp group external-peers]
    user@R1# set type external
    user@R1# set export local-direct
    user@R1# set peer-as 64511
    user@R1# set neighbor 10.10.10.2
    
  6. 配置 IBGP 会话。

    content_copy zoom_out_map
    [edit protocols bgp group internal-peers]
    user@R1# set type internal
    user@R1# set local-address 192.168.0.1
    user@R1# set export local-direct
    user@R1# set neighbor 192.168.0.3
    
  7. 启用 BGP 容错。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@R1# set bgp-error-tolerance 
    
  8. (可选)配置日志间隔。

    content_copy zoom_out_map
    [edit protocols bgp bgp-error-tolerance]
    user@R1# set malformed-update-log-interval 10
    
  9. (可选)配置要存储的隐藏路由数限制。

    content_copy zoom_out_map
    [edit protocols bgp bgp-error-tolerance]
    user@R1# set malformed-route-limit 5
    
结果

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

content_copy zoom_out_map
user@R1# show interfaces
fe-1/2/0 {
    unit 0 {
        description to-R0;
        family inet {
            address 172.16.10.6/30;
        }
    }
}
fe-1/2/1 {
    unit 0 {
        description to-R2;
        family inet {
            address 10.10.10.1/30;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.1/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show protocols
bgp {
    bgp-error-tolerance {
        malformed-update-log-interval 10;
        malformed-route-limit 5;
    }
    group internal-peers {
        type internal;
        local-address 192.168.0.1;
        export local-direct;
        neighbor 192.168.0.3;
    }
    group external-peers {
        type external;
        export local-direct;
        peer-as 64511;
        neighbor 10.10.10.2;
    }
}
ospf {
    area 0.0.0.0 {
        interface fe-1/2/1.0;
        interface fe-1/2/0.0;
        interface lo0.0 {
            passive;
        }
    }
}
content_copy zoom_out_map
user@R1# show policy-options
policy-statement local-direct {
    from protocol [local direct];
    then accept;
}
content_copy zoom_out_map
user@R1# show routing-options
router-id 192.168.0.1;
autonomous-system 64510;

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

验证

确认配置工作正常。

检查 BGP 邻居会话

目的

验证是否启用了 BGP 容错,并显示与格式错误的路径属性相关的计数器。

操作
content_copy zoom_out_map
user@R1# show bgp neighbor
Peer: 10.10.10.2+50058 AS 64511 Local: 10.10.10.1+179 AS 64510
  Type: External    State: Established    Flags: <Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ local-direct ] 
  Options: <Preference PeerAS Refresh>
  Holdtime: 90 Preference: 170
  Number of flaps: 0
  Malformed attributes    log interval: 10   route limit: 5
    Attribute:           ORIGIN(1) Last Received: 0 Total Received: 3
    Attribute:       LOCAL_PREF(5) Last Received: 0 Total Received: 2
  Peer ID: 192.168.10.2    Local ID: 192.168.10.1      Active Holdtime: 90
  Keepalive Interval: 30         Group index: 0    Peer index: 0   
  BFD: disabled, down
  Local Interface: fe-1/2/1.0                       
  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 64511)
  Peer does not support Addpath
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              0
    Received prefixes:            3
    Accepted prefixes:            0
    Suppressed due to damping:    0
    Advertised prefixes:          2
  Last traffic (seconds): Received 25   Sent 17   Checked 73  
  Input messages:  Total 2702   Updates 10      Refreshes 0     Octets 51652
  Output messages: Total 2701   Updates 6       Refreshes 0     Octets 51571
  Output Queue[0]: 0

Peer: 192.168.10.3+179 AS 64510 Local: 192.168.10.1+51127 AS 64510
  Type: Internal    State: Established    Flags: <Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ local-direct ] 
  Options: <Preference LocalAddress Refresh>
  Local Address: 192.168.10.1 Holdtime: 90 Preference: 170
  Number of flaps: 0
  Malformed attributes    log interval: 10   route limit: 5
  Peer ID: 192.168.10.3    Local ID: 192.168.10.1      Active Holdtime: 90
  Keepalive Interval: 30         Group index: 1    Peer index: 0   
  BFD: disabled, down
  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 64510)
  Peer does not support Addpath         
  Table inet.0 Bit: 10001
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              0
    Received prefixes:            3
    Accepted prefixes:            0
    Suppressed due to damping:    0
    Advertised prefixes:          2
  Last traffic (seconds): Received 5    Sent 24   Checked 51  
  Input messages:  Total 417    Updates 3       Refreshes 0     Octets 8006
  Output messages: Total 421    Updates 2       Refreshes 0     Octets 8136
  Output Queue[0]: 0
意义

格式不正确的属性字段显示已启用容错。日志间隔和路由限制字段显示配置的值。

属性计数器显示,在 EBGP 连接上,从设备 R2 接收了多个格式错误的属性。

检查隐藏的路由

目的

查看有关隐藏路线的信息并了解隐藏路由的原因。

操作
content_copy zoom_out_map
user@R1> show route hidden detail
inet.0: 42 destinations, 45 routes (36 active, 0 holddown, 6 hidden)
10.0.0.0/32 (1 entry, 0 announced)
         BGP   
                Next hop type: Router
                Address: 0x93d8b0c
                Next-hop reference count: 5
                Source: 10.10.10.2
                Next hop type: Router, Next hop index: 782
                Next hop: via fe-1/2/1.0, selected
                Session Id: 0x1
                State: <Hidden  Ext>
                Local AS:     1 Peer AS:     1
                Age: 5:32       Metric2: 1 
                Validation State: unverified 
                Task: BGP_1.10.10.5.62+56218
                AS path: I (MalformedAttr) 
                Router ID: 192.168.0.2

10.0.0.1/32 (1 entry, 0 announced)
         BGP   
                Next hop type: Router
                Address: 0x93d8b0c
                Next-hop reference count: 5
                Source: 10.10.10.2
                Next hop type: Router, Next hop index: 782
                Next hop: via fe-1/2/1.0, selected
                Session Id: 0x1
                Indirect next hop: 953c000 - INH Session ID: 0x3
                State: <Hidden Int Ext>
                Local AS:     1 Peer AS:     1
                Age: 5:32       Metric2: 1 
                Validation State: unverified 
                Task: BGP_1.10.10.5.62+56218
                AS path: I (MalformedAttr)
                Router ID: 192.168.0.2
意义

格式错误的隐藏路由在 AS 路径字段中用 MalformedAttr 标记。

您可以通过运行 clear bgp neighbor 10.10.10.2 malformed-route 命令来删除隐藏的路由。

验证隐藏路由的来源

目的

查看有关隐藏路线的信息并了解隐藏路由的原因。

操作
content_copy zoom_out_map
user@R1> show route receive-protocol bgp 10.10.10.2 detail hidden
inet.0: 42 destinations, 45 routes (36 active, 0 holddown, 6 hidden)
  10.0.0.0/32 (1 entry, 0 announced)
     Nexthop: 10.10.10.2
     Localpref: 100
     AS path: I (MalformedAttr)  

  10.0.0.1/32 (1 entry, 0 announced)
     Nexthop: 10.10.10.2
     Localpref: 100
     AS path: I (MalformedAttr)
意义

Junos OS 在命令输出 show route receive-protocol bgp 10.10.10.2 detail hidden 的 AS 路径字段中显示 MalformedAttr。

您可以通过运行 clear bgp neighbor 10.10.10.2 malformed-route 命令来删除隐藏的路由。

external-footer-nav