帮助我们改善您的体验。

让我们了解您的想法。

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

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 的路由器身份验证

使用路由器和路由身份验证以及路由完整性可以极大地降低被配置为与其他路由器共享错误路由信息的计算机或路由器攻击的风险。在这种攻击中,可以诱使受攻击的路由器创建路由环路,或者可以大大增加被攻击路由器的路由表从而影响性能,或者可以将路由信息重定向到网络中的某个位置供攻击者分析。可以在分段上发送虚假路由广告。这些更新可以接受到邻居路由器的路由表中,除非有身份验证机制来验证路由的来源。

路由器和路由身份验证使路由器只有在能够根据密码(密钥)验证它们是否正在与受信任源通信时才能共享信息。在此方法中,散列密钥与发送到另一个路由器的路由一起发送。接收路由器将发送的密钥与其自己配置的密钥进行比较。如果它们相同,则接受路由。通过使用散列算法,密钥不会以纯文本形式通过网络发送。相反,哈希是使用配置的密钥计算的。路由更新与密钥一起用作哈希函数的输入文本。此哈希与路由更新一起发送到接收路由器。接收路由器将收到的哈希与其上使用其上配置的预共享密钥在路由更新上生成的哈希进行比较。如果两个哈希相同,则假定路由来自受信任的源。只有发送路由器和接收路由器知道密钥。

为了进一步增强安全性,您可以配置一系列身份验证密钥( 钥匙串)。每个密钥在钥匙串中都有一个唯一的开始时间。钥匙串身份验证允许您定期更改密码信息,而不会关闭对等会话。此密钥链身份验证方法称为 无中断 ,因为密钥会从一个密钥滚动到下一个密钥,而不会重置任何对等会话或中断路由协议。

发送对等方使用以下规则来标识活动身份验证密钥:

  • 开始时间小于或等于当前时间(换句话说,不是将来的时间)。

  • 开始时间大于链中开始时间小于当前时间(换句话说,最接近当前时间)的所有其他键的开始时间。

接收对等方根据传入密钥标识符确定用于进行身份验证的密钥。

发送对等方根据配置的开始时间标识当前身份验证密钥,然后使用当前密钥生成哈希值。然后,发送对等方将 TCP 增强型身份验证选项对象插入到 BGP 更新消息中。对象包含对象 ID(由 IANA 分配)、对象长度、当前键和哈希值。

接收对等方检查传入的 TCP 增强型身份验证选项,查找收到的身份验证密钥,并根据开始时间、系统时间和容差参数确定密钥是否可接受。如果接受密钥,接收对等方将计算哈希并对更新消息进行身份验证。

最初将钥匙串应用于 TCP 会话会导致会话重置。但是,应用钥匙串后,在钥匙串中添加或删除密码不会导致 TCP 会话重置。此外,当钥匙串从一种身份验证算法更改为另一种身份验证算法时,TCP 会话不会重置。

TCP 身份验证

通常,在以下层次结构级别配置 TCP 身份验证:

  • [edit protocols bgp]

  • [edit protocols bgp group group-name]

  • [edit protocols bgp group group-name neighbor address]

TCP 身份验证和前缀子网

Junos 设备支持对通过 BGP 组中配置的允许前缀子网发现的 BGP 对等方进行 TCP 身份验证。

要为 TCP-AO 或 TCP MD5 为 BGP 会话配置基于前缀的身份验证,可以在以下层次结构中配置 allow (all | prefix-list) 语句:

  • [edit protocols bgp group group-name]

  • [edit protocols bgp group group-name dynamic-neighbor dyn-name]

有关 TCP 身份验证的详细信息,请参阅 TCP。

示例:为 BGP 配置路由器身份验证

可以对所有 BGP 协议交换进行身份验证,以确保只有可信的路由设备参与自治系统 (AS) 路由更新。默认情况下,身份验证处于禁用状态。

要求

准备工作:

  • 配置路由器接口。

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

概述

配置身份验证时,算法将创建包含在传输数据包中的编码校验和。接收路由设备使用身份验证密钥(密码)来验证数据包的校验和。

此示例包含以下用于配置和应用钥匙串的语句:

  • key—一个钥匙串可以有多个密钥。钥匙串中的每个键都必须由唯一的整数值标识。有效标识符值的范围为 0 到 63。

    密钥长度最多为 126 个字符。字符可以包含任意 ASCII 字符串。如果包含空格,请用引号 (“ ”) 将所有字符括起来。

  • tolerance—(可选)对于每个钥匙串,您可以配置以秒为单位的时钟偏斜容差值。时钟偏斜容限适用于接受 BGP 更新密钥的接收器。可配置范围为 0 到 999,999,999 秒。在容差期内,当前或以前的密码都是可以接受的。

  • key-chain- 对于每个钥匙串,必须指定一个名称。此示例定义一个钥匙串:bgp-auth。路由设备上可以有多个钥匙串。例如,您可以有一个用于 BGP 的钥匙串、一个用于 OSPF 的钥匙串和一个用于 LDP 的钥匙串。

  • secret—对于钥匙串中的每个密钥,您必须设置一个秘密密码。可以在语句中 secret 以加密或纯文本格式输入此密码。它始终以加密格式显示。

  • start-time—每个键必须以 UTC 格式指定开始时间。控制权从一个密钥传递到下一个密钥。当配置的开始时间到达(基于路由设备的时钟)时,具有该开始时间的密钥将变为活动状态。开始时间以路由设备的本地时区指定,并且在钥匙串中必须是唯一的。

  • authentication-key-chain- 使您能够在全局 BGP 级别为所有对等方、组或邻居应用钥匙串。此示例将密钥链应用于名为 的 ext外部 BGP (EBGP) 组中定义的对等方。

  • authentication-algorithm- 对于每个密钥链,您可以指定哈希算法。该算法可以是 AES-128、MD5 或 SHA-1。

    您可以将密钥链和身份验证算法与 BGP 相邻会话相关联。

此示例配置名为 bgp-auth的密钥链。密钥 0 将从 2011-6-23.20:19:33 -0700 开始发送和接受,并在钥匙串中的下一个密钥(密钥 1)变为活动状态时停止发送和接受。密钥 1 在一年后的 2012-6-23.20:19:33 -0700 变为活动状态,并且不会停止发送和接受,除非为另一个密钥配置了晚于密钥 1 的开始时间的开始时间。30 秒的时钟偏斜容差适用于接受密钥的接收器。在容差期内,当前密钥或上一个密钥都是可以接受的。密钥是共享密钥密码。这意味着接收经过身份验证的路由更新的邻接方必须具有相同的身份验证密钥链配置,包括相同的密钥(密码)。因此,如果路由器 R0 和路由器 R1 配置为对等方,则必须具有相同的身份验证密钥链配置。此示例仅显示其中一个路由设备上的配置。

拓扑图

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

图 1: BGP 身份验证BGP 身份验证

配置

CLI 快速配置

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

content_copy zoom_out_map
set protocols bgp group ext type external 
set protocols bgp group ext peer-as 65530 
set protocols bgp group ext neighbor 172.16.2.1  
set routing-options autonomous-system 65533
set protocols bgp group ext authentication-key-chain bgp-auth 
set protocols bgp group ext authentication-algorithm md5
set security authentication-key-chains key-chain bgp-auth tolerance 30
set security authentication-key-chains key-chain bgp-auth key 0 secret this-is-the-secret-password
set security authentication-key-chains key-chain bgp-auth key 0 start-time 2011-6-23.20:19:33-0700
set security authentication-key-chains key-chain bgp-auth key 1 secret this-is-another-secret-password
set security authentication-key-chains key-chain bgp-auth key 1 start-time 2012-6-23.20:19:33-0700

程序

分步过程

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

要将路由器 R1 配置为接受来自设备 CE1 的路由过滤器,并使用收到的过滤器执行出站路由过滤:

  1. 配置本地自治系统。

    content_copy zoom_out_map
    [edit routing-options]
    user@R1# set autonomous-system 65533
    
  2. 配置一个或多个 BGP 组。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R1# set type external
    user@R1# set peer-as 65530 
    user@R1# set neighbor 172.16.2.1  
    
  3. 使用多个密钥配置身份验证。

    content_copy zoom_out_map
    [edit security authentication-key-chains key-chain bgp-auth]
    user@R1# set key 0 secret this-is-the-secret-password
    user@R1# set key 0 start-time 2011-6-23.20:19:33-0700
    user@R1# set key 1 secret this-is-another-secret-password
    user@R1# set key 1 start-time 2012-6-23.20:19:33-0700
    

    每个密钥的开始时间在钥匙串中必须是唯一的。

  4. 将身份验证密钥链应用于 BGP,并设置哈希算法。

    content_copy zoom_out_map
    [edit protocols bgp group ext]
    user@R1# set authentication-key-chain bgp-auth 
    user@R1# set authentication-algorithm md5
    
  5. (可选)应用时钟偏斜容差值(以秒为单位)。

    content_copy zoom_out_map
    [edit security authentication-key-chains key-chain bgp-auth]
    user@R1# set tolerance 30
    
结果

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

content_copy zoom_out_map
user@R1# show protocols
bgp {
    group ext {
        type external;
        peer-as 65530;
        neighbor 172.16.2.1;
        authentication-key-chain bgp-auth;
        authentication-algorithm md5;
    }
}
content_copy zoom_out_map
user@R1# show routing-options
autonomous-system 65533;
content_copy zoom_out_map
user@R1# show security
authentication-key-chains {
    key-chain bgp-auth {
        tolerance 30;
            key 0 {
            secret $ABC123$ABC123
            start-time “2011-6-23.20:19:33 -0700”; 
        }
        key 1 {
            secret $ABC123$ABC123
            start-time “2012-6-23.20:19:33 -0700”;
        }
    }
}

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

对网络中每个启用 BGP 的设备重复此过程,并为每个启用 BGP 的设备使用适当的接口名称和地址。

验证

确认配置工作正常。

验证邻居的身份验证

目的

确保该 AutheKeyChain 选项显示在命令的 show bgp neighbor 输出中。

操作

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

content_copy zoom_out_map
user@R1> show bgp neighbor
Peer: 172.16.2.1+179 AS 65530  Local: 172.16.2.2+1222 AS 65533
  Type: External    State: Established    Flags: <Sync>
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Export: [ direct-lo0 ]
  Options: <Preference PeerAS Refresh>
  Options: <AutheKeyChain>
  Authentication key is configured
  Authentication key chain: jni
  Holdtime: 90 Preference: 170
  Number of flaps: 0
  Peer ID: 172.16.2.1       Local ID: 10.255.124.35    Active Holdtime: 90
  Keepalive Interval: 30         Peer index: 0
  Local Interface: fe-0/0/1.0
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              2
    Received prefixes:            2
    Suppressed due to damping:    0
    Advertised prefixes:          1
  Last traffic (seconds): Received 2    Sent 2    Checked 2
  Input messages:  Total 21     Updates 2       Refreshes 0     Octets 477
  Output messages: Total 22     Updates 1       Refreshes 0     Octets 471
  Output Queue[0]: 0

验证是否已发送授权消息

目的

确认 BGP 具有增强授权选项。

操作

在操作模式下,输入 monitor traffic interface fe-0/0/1 命令。

content_copy zoom_out_map
user@R1> monitor traffic interface fe-0/0/1
verbose output suppressed, use <detail> or <extensive> for full protocol decode
Listening on fe-0/0/1, capture size 96 bytes

13:08:00.618402  In arp who-has 172.16.2.66 tell 172.16.2.69
13:08:02.408249 Out IP 172.16.2.2.1122 > 172.16.2.1.646: P
1889289217:1889289235(18) ack 2215740969 win 58486 <nop,nop,timestamp 167557
1465469,nop,Enhanced Auth keyid 0 diglen 12 digest: fe3366001f45767165f17037>:
13:08:02.418396  In IP 172.16.2.1.646 > 172.16.2.2.1122: P 1:19(18) ack 18 win
57100 <nop,nop,timestamp 1466460 167557,nop,Enhanced Auth keyid 0 diglen 12
digest: a18c31eda1b14b2900921675>:
13:08:02.518146 Out IP 172.16.2.2.1122 > 172.16.2.1.646: . ack 19 win 58468
<nop,nop,timestamp 167568 1466460,nop,Enhanced Auth keyid 0 diglen 12 digest:
c3b6422eb6bd3fd9cf79742b>
13:08:28.199557 Out IP 172.16.2.2.nerv > 172.16.2.1.bgp: P
286842489:286842508(19) ack 931203976 win 57200 <nop,Enhanced Auth keyid 0
diglen 12 digest: fc0e42900a73736bcc07c1a4>: BGP, length: 19
13:08:28.209661  In IP 172.16.2.1.bgp > 172.16.2.2.nerv: P 1:20(19) ack 19 win
56835 <nop,Enhanced Auth keyid 0 diglen 12 digest: 0fc8578c489fabce63aeb2c3>:
BGP, length: 19
13:08:28.309525 Out IP 172.16.2.2.nerv > 172.16.2.1.bgp: . ack 20 win 57181
<nop,Enhanced Auth keyid 0 diglen 12 digest: ef03f282fb2ece0039491df8>
13:08:32.439708 Out IP 172.16.2.2.1122 > 172.16.2.1.646: P 54:72(18) ack 55 win
58432 <nop,nop,timestamp 170560 1468472,nop,Enhanced Auth keyid 0 diglen 12
digest: 76e0cf926f348b726c631944>:
13:08:32.449795  In IP 172.16.2.1.646 > 172.16.2.2.1122: P 55:73(18) ack 72 win
57046 <nop,nop,timestamp 1469463 170560,nop,Enhanced Auth keyid 0 diglen 12
digest: dae3eec390d18a114431f4d8>:
13:08:32.549726 Out IP 172.16.2.2.1122 > 172.16.2.1.646: . ack 73 win 58414
<nop,nop,timestamp 170571 1469463,nop,Enhanced Auth keyid 0 diglen 12 digest:
851df771aee2ea7a43a0c46c>
13:08:33.719880  In arp who-has 172.16.2.66 tell 172.16.2.69
^C
35 packets received by filter
0 packets dropped by kernel

检查身份验证错误

目的

检查由于身份验证错误而导致 TCP 丢弃的数据包数。

操作

在操作模式下,输入 show system statistics tcp | match auth 命令。

content_copy zoom_out_map
user@R1> show system statistics tcp | match auth
        0 send packets dropped by TCP due to auth errors
        58 rcv packets dropped by TCP due to auth errors

验证钥匙串的操作

目的

检查由于身份验证错误而导致 TCP 丢弃的数据包数。

操作

在操作模式下,输入 show security keychain detail 命令。

content_copy zoom_out_map
user@R1> show security keychain detail
keychain                 Active-ID       Next-ID       Transition  Tolerance
                       Send  Receive   Send  Receive 
 bgp-auth                3     3        1     1        1d 23:58    30    
  Id 3, Algorithm hmac-md5, State send-receive, Option basic
  Start-time Wed Aug 11 16:28:00 2010, Mode send-receive
  Id 1, Algorithm hmac-md5, State inactive, Option basic
  Start-time Fri Aug 20 11:30:57 2010, Mode send-receive  

变更历史表

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

版本
说明
22.4R1
从 Junos OS 演化版 22.4R1 开始,您可以使用 IP 子网配置 TCP-AO 或 TCP MD5 身份验证,以包括该子网下的整个地址范围。
22.4R1
从 Junos OS 演化版 22.4R1 开始,TCP 身份验证可以识别 VRF。
19.1R1
从 Junos OS 19.1R1 版开始,Junos OS 将对 TCP 身份验证的支持扩展到通过 BGP 组中配置的允许前缀子网发现的 BGP 对等方。
footer-navigation