帮助我们改善您的体验。

让我们了解您的想法。

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

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

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

机器翻译对您有帮助吗?

starstarstarstarstar
Go to English page
免责声明:

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

示例:配置动态路由策略

date_range 18-Jan-25

此示例说明如何在不受标准配置数据库中所需验证的动态数据库中配置路由策略对象。

要求

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

概述

提交配置更改所需的验证过程可能需要大量的开销和时间。

将更改提交到动态数据库所需的时间比标准配置数据库短得多。您可以在标准数据库中配置的路由策略中引用这些策略和策略对象。BGP 是唯一可以应用引用动态数据库中配置的策略和策略对象的路由策略的协议。根据动态数据库中配置的对象配置并提交路由策略后,可以通过更改动态数据库配置来快速更新任何现有路由策略。

警告:

由于 Junos OS 不会验证对动态数据库的配置更改,因此在使用此功能时,应在提交所有配置更改之前测试并验证这些更改。

图 1 显示了示例网络。

图 1: 动态路由策略示例网络动态路由策略示例网络

该示例包括三个已建立外部 BGP (EBGP) 会话的路由器。只有设备 R1 使用动态数据库。

在设备 R0 的 fe-1/2/1 接口上,配置了多个 IPv4 接口,路由策略将这些前缀注入 BGP, from interface fe-1/2/1.0 使用策略条件作为指定设备 R0 的 fe-1/2/1 接口上配置的所有 IP 地址的简写方法。

同样,在设备 R2 的 fe-1/2/3 接口上,配置了多个 IPv4 地址,路由策略将这些前缀注入 BGP。设备 R2 的配置与设备 R0 的配置略有不同,因为设备 R2 的配置演示了前缀列表的使用。

在设备 R1 上的动态数据库中,定义了两个前缀列表,一个用于从设备 R0 获知的接口地址,另一个用于从设备 R2 获知的接口地址。设备 R1 的标准数据库包含路由策略,其前缀列表类似于动态数据库中定义的前缀列表。

在与设备 R0 的对等会话中,设备 R1 应用了静态数据库策略。相反,在与设备 R2 的对等会话中,设备 R1 的配置引用动态数据库。

本节 验证 分析了这些不同配置的结果。

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

#configuration776__policy-dynamic-st本节介绍设备 R1 动态数据库上的步骤。

#configuration776__policy-standard-st本节介绍设备 R1 标准数据库上的步骤。

配置

程序

CLI 快速配置

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

设备 R0

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30
set interfaces fe-1/2/1 unit 0 family inet address 172.16.4.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.3.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.2.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.1.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.5.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.6.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.7.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.8.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.9.1/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.10.1/24
set interfaces lo0 unit 0 family inet address 10.255.14.151/32
set protocols bgp group ext type external
set protocols bgp group ext neighbor 10.0.0.2 export t2
set protocols bgp group ext neighbor 10.0.0.2 peer-as 200
set policy-options policy-statement t2 from interface fe-1/2/0.0
set policy-options policy-statement t2 from interface fe-1/2/1.0
set policy-options policy-statement t2 then accept
set routing-options router-id 10.255.14.151
set routing-options autonomous-system 100

设备 R1 动态数据库

content_copy zoom_out_map
[edit dynamic]
set policy-options prefix-list dyn_prfx1 172.16.1.0/24
set policy-options prefix-list dyn_prfx1 172.16.2.0/24
set policy-options prefix-list dyn_prfx1 172.16.3.0/24
set policy-options prefix-list dyn_prfx1 172.16.4.0/24
set policy-options prefix-list dyn_prfx1 172.16.5.0/24
set policy-options prefix-list dyn_prfx1 172.16.6.0/24
set policy-options prefix-list dyn_prfx1 172.16.7.0/24
set policy-options prefix-list dyn_prfx1 172.16.8.0/24
set policy-options prefix-list dyn_prfx2 172.16.2.0/24
set policy-options prefix-list dyn_prfx2 172.16.3.0/24
set policy-options prefix-list dyn_prfx2 172.16.4.0/24
set policy-options prefix-list dyn_prfx2 172.16.5.0/24
set policy-options prefix-list dyn_prfx2 172.16.6.0/24
set policy-options policy-statement dyn_policy1 term t1 from prefix-list dyn_prfx1
set policy-options policy-statement dyn_policy1 term t1 then accept
set policy-options policy-statement dyn_policy1 term t2 then reject
set policy-options policy-statement dyn_policy2 term t1 from prefix-list dyn_prfx2
set policy-options policy-statement dyn_policy2 term t1 then accept
set policy-options policy-statement dyn_policy2 term t2 then reject

设备 R1 标准数据库

content_copy zoom_out_map
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30
set interfaces fe-1/2/2 unit 0 family inet address 10.1.0.1/30
set interfaces fe-1/2/1 unit 0 family inet address 172.16.4.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.3.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.2.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.1.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.5.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.6.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.7.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.8.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.9.2/24
set interfaces fe-1/2/1 unit 0 family inet address 172.16.10.2/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.22.2/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.23.2/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.24.2/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.25.2/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.26.2/24
set interfaces lo0 unit 0 family inet address 192.168.0.2/32
set protocols bgp group to_r0 idle-after-switch-over 300
set protocols bgp group to_r0 neighbor 10.0.0.1 import dyn_policy1
set protocols bgp group to_r0 neighbor 10.0.0.1 export dyn_policy2
set protocols bgp group to_r0 neighbor 10.0.0.1 peer-as 100
set protocols bgp group to_R2 import static_policy1
set protocols bgp group to_R2 export static_policy2
set protocols bgp group to_R2 idle-after-switch-over 300
set protocols bgp group to_R2 neighbor 10.1.0.2 peer-as 300
set policy-options prefix-list static_prfx1 172.16.22.0/24
set policy-options prefix-list static_prfx1 172.16.23.0/24
set policy-options prefix-list static_prfx1 172.16.24.0/24
set policy-options prefix-list static_prfx1 172.16.25.0/24
set policy-options prefix-list static_prfx2 172.16.1.0/24
set policy-options prefix-list static_prfx2 172.16.2.0/24
set policy-options prefix-list static_prfx2 172.16.3.0/24
set policy-options prefix-list static_prfx2 172.16.4.0/24
set policy-options policy-statement dyn_policy1 dynamic-db
set policy-options policy-statement dyn_policy2 dynamic-db
set policy-options policy-statement static_policy1 term t1 from prefix-list static_prfx1
set policy-options policy-statement static_policy1 term t1 then accept
set policy-options policy-statement static_policy1 term t2 then reject
set policy-options policy-statement static_policy2 term t1 from prefix-list static_prfx2
set policy-options policy-statement static_policy2 term t1 then accept
set policy-options policy-statement static_policy2 term t2 then reject
set routing-options autonomous-system 200

设备 R2

content_copy zoom_out_map
set interfaces fe-1/2/2 unit 0 family inet address 10.1.0.2/30
set interfaces fe-1/2/3 unit 0 family inet address 172.16.22.1/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.23.1/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.24.1/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.25.1/24
set interfaces fe-1/2/3 unit 0 family inet address 172.16.26.1/24
set interfaces lo0 unit 0 family inet address 192.168.0.3/32
set protocols bgp group to_vin neighbor 10.1.0.1 export p1
set protocols bgp group to_vin neighbor 10.1.0.1 peer-as 200
set policy-options prefix-list ppx1 172.16.22.0/24
set policy-options prefix-list ppx1 172.16.23.0/24
set policy-options prefix-list ppx1 172.16.24.0/24
set policy-options prefix-list ppx1 172.16.25.0/24
set policy-options prefix-list ppx1 172.16.26.0/24
set policy-options policy-statement p1 term t1 from family inet
set policy-options policy-statement p1 term t1 from prefix-list ppx1
set policy-options policy-statement p1 term t1 then accept
set routing-options autonomous-system 300

分步过程

下面的示例要求您在各个配置层级中进行导航。有关如何执行此操作的说明,请参阅 在配置模式下使用 CLI 编辑器Junos OS CLI 用户指南

要配置设备 R1 的动态数据库:

  1. 进入动态数据库的配置模式。

    content_copy zoom_out_map
    user@R1> configure dynamic   
    Entering configuration mode
    [edit dynamic]
    
  2. 为从设备 R0 获知的接口地址创建前缀列表。

    content_copy zoom_out_map
    [edit dynamic policy-options prefix-list dyn_prfx1]
    user@R1# set 172.16.1.0/24
    user@R1# set 172.16.2.0/24
    user@R1# set 172.16.3.0/24
    user@R1# set 172.16.4.0/24
    user@R1# set 172.16.5.0/24
    user@R1# set 172.16.6.0/24
    user@R1# set 172.16.7.0/24
    user@R1# set 172.16.8.0/24
    
  3. 为从设备 R2 获知的接口地址创建前缀列表。

    content_copy zoom_out_map
    [edit dynamic policy-options prefix-list dyn_prfx2]
    user@R1# set 172.16.2.0/24
    user@R1# set 172.16.3.0/24
    user@R1# set 172.16.4.0/24
    user@R1# set 172.16.5.0/24
    user@R1# set 172.16.6.0/24
    
  4. 配置路由策略。

    content_copy zoom_out_map
    [edit dynamic policy-options policy-statement dyn_policy1]
    user@R1# set term t1 from prefix-list dyn_prfx1
    user@R1# set term t1 then accept
    user@R1# set term t2 then reject
    user@R1# set term t1 from prefix-list dyn_prfx2
    user@R1# set term t1 then accept
    user@R1# set term t2 then reject
    

分步过程

下面的示例要求您在各个配置层级中进行导航。有关如何执行此操作的说明,请参阅 在配置模式下使用 CLI 编辑器Junos OS CLI 用户指南

要配置设备 R1 的标准数据库,请执行以下操作:

  1. 创建路由器接口。

    content_copy zoom_out_map
    [edit interfaces]
    user@R1# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30
    user@R1# set fe-1/2/2 unit 0 family inet address 10.1.0.1/30
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.4.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.3.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.2.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.1.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.5.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.6.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.7.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.8.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.9.2/24
    user@R1# set fe-1/2/1 unit 0 family inet address 172.16.10.2/24
    user@R1# set fe-1/2/3 unit 0 family inet address 172.16.2.2/24
    user@R1# set fe-1/2/3 unit 0 family inet address 172.16.3.2/24
    user@R1# set fe-1/2/3 unit 0 family inet address 172.16.4.2/24
    user@R1# set fe-1/2/3 unit 0 family inet address 172.16.5.2/24
    user@R1# set fe-1/2/3 unit 0 family inet address 172.16.6.2/24
    user@R1# set lo0 unit 0 family inet address 192.168.0.2/32
    
  2. 创建引用动态数据库中的策略的路由策略。

    content_copy zoom_out_map
    [edit policy-options]
    user@R1# set policy-statement dyn_policy1 dynamic-db
    user@R1# set policy-statement dyn_policy2 dynamic-db
    
  3. 配置与设备 R0 的 BGP 对等互连。

    content_copy zoom_out_map
    [edit protocols bgp group to_r0]
    user@R1# set neighbor 10.0.0.1 peer-as 100
    
  4. 将动态数据库策略应用于与设备 R0 的 BGP 对等互连。

    content_copy zoom_out_map
    [edit protocols bgp group to_r0]
    user@R1# set neighbor 10.0.0.1 import dyn_policy1
    user@R1# set neighbor 10.0.0.1 export dyn_policy2
    
  5. 为从设备 R0 获知的前缀配置前缀列表。

    content_copy zoom_out_map
    [edit policy-options prefix-list static_prfx2]
    user@R1# set 172.16.1.0/24
    user@R1# set 172.16.2.0/24
    user@R1# set 172.16.3.0/24
    user@R1# set 172.16.4.0/24
    
  6. 为从设备 R2 获知的前缀配置前缀列表。

    content_copy zoom_out_map
    [edit policy-options prefix-list static_prfx1]
    user@R1# set 172.16.2.0/24
    user@R1# set 172.16.3.0/24
    user@R1# set 172.16.4.0/24
    user@R1# set 172.16.5.0/24
    
  7. 配置静态数据库策略。

    content_copy zoom_out_map
    [edit policy-options policy-statement static_policy1]
    user@R1# set term t1 from prefix-list static_prfx1
    user@R1# set term t1 then accept
    user@R1# set term t2 then reject
    [edit policy-options policy-statement static_policy2]
    user@R1# set term t1 from prefix-list static_prfx2
    user@R1# set term t1 then accept
    user@R1# set term t2 then reject
    
  8. 配置与设备 R2 的 BGP 对等互连。

    content_copy zoom_out_map
    [edit protocols bgp group to_R2]
    user@R1# set neighbor 10.1.0.2 peer-as 300
    
  9. 将静态数据库策略应用于与设备 R2 的 BGP 对等互连。

    content_copy zoom_out_map
    [edit protocols bgp group to_R2]
    user@R1# set import static_policy1
    user@R1# set export static_policy2
    
  10. (可选)将路由器配置为在活动不间断路由切换后在指定时间段内或手动重新建立会话之前不重新建立 BGP 对等会话。

    此语句对于动态路由策略特别有用,因为启用不间断活动路由 (NSR) 时,动态数据库不会与备份路由引擎同步。因此,如果切换到备份路由引擎,则切换时在主路由引擎上运行的导入和导出策略可能不再可用。因此,您可能希望防止在切换发生后立即自动重新建立 BGP 对等会话。

    content_copy zoom_out_map
    [edit protocols bgp]
    user@R1# set group to_r0 idle-after-switch-over 300
    user@R1# set group to_R2 idle-after-switch-over 300
    
  11. 配置自治系统 (AS) 编号。

    content_copy zoom_out_map
    [edit routing-options]
    user@R1# set routing-options autonomous-system 200
    

结果

通过在动态数据库中输入配置模式命令,在show interfaces标准数据库中输入show配置模式中的 、 show protocolsshow policy-optionsshow routing-options命令来确认配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。

设备 R1 动态

content_copy zoom_out_map
[edit dynamic]
user@R1# show
policy-options {
    prefix-list dyn_prfx1 {
        172.16.1.0/24;
        172.16.2.0/24;
        172.16.3.0/24;
        172.16.4.0/24;
        172.16.5.0/24;
        172.16.6.0/24;
        172.16.7.0/24;
        172.16.8.0/24;
    }
    prefix-list dyn_prfx2 {
        172.16.2.0/24;
        172.16.3.0/24;
        172.16.4.0/24;
        172.16.5.0/24;
        172.16.6.0/24;
    }
    policy-statement dyn_policy1 {
        term t1 {
            from {
                prefix-list dyn_prfx1;
            }
            then accept;
        }
        term t2 {
            then reject;
        }
    }
    policy-statement dyn_policy2 {
        term t1 {
            from {
                prefix-list dyn_prfx2;
            }
            then accept;
        }
        term t2 {
            then reject;
        }
    }
}

设备 R1 标准

content_copy zoom_out_map
[edit]
user@R1# show interfaces
fe-1/2/0 {
    unit 0 {
        family inet {
            address 10.0.0.2/30;
        }
    }
}
fe-1/2/1 {
    unit 0 {
        family inet {
            address 172.16.4.2/24;
            address 172.16.3.2/24;
            address 172.16.2.2/24;
            address 172.16.1.2/24;
            address 172.16.5.2/24;
            address 172.16.6.2/24;
            address 172.16.7.2/24;
            address 172.16.8.2/24;
            address 172.16.9.2/24;
            address 172.16.10.2/24;
        }
    }
}
fe-1/2/2 {
    unit 0 {
        family inet {
            address 10.1.0.1/30;
        }
    }
}
fe-1/2/3 {
    unit 0 {
        family inet {
            address 172.16.2.2/24;
            address 172.16.3.2/24;
            address 172.16.4.2/24;
            address 172.16.5.2/24;
            address 172.16.6.2/24;
        }
    }
}
lo0 {
    unit 0 {
        family inet {
            address 192.168.0.2/32;
        }
    }
}
content_copy zoom_out_map
user@R1# show protocols
bgp {
    group to_r0 {
        idle-after-switch-over 300;
        neighbor 10.0.0.1 {
            import dyn_policy1;
            export dyn_policy2;
            peer-as 100;
        }
    }
    group to_R2 {
        import static_policy1;
        export static_policy2;
        idle-after-switch-over 300;
        neighbor 10.1.0.2 {
            peer-as 300;
        }
    }
}
content_copy zoom_out_map
user@R1# show policy-options
prefix-list static_prfx1 {
    172.16.2.0/24;
    172.16.3.0/24;
    172.16.4.0/24;
    172.16.5.0/24;
}
prefix-list static_prfx2 {
    172.16.1.0/24;
    172.16.2.0/24;
    172.16.3.0/24;
    172.16.4.0/24;
}
policy-statement dyn_policy1 {
    dynamic-db;
}
policy-statement dyn_policy2 {
    dynamic-db;
}
policy-statement static_policy1 {
    term t1 {
        from {
            prefix-list static_prfx1;
        }
        then accept;
    }
    term t2 {
        then reject;
    }
}
policy-statement static_policy2 {
    term t1 {
        from {
            prefix-list static_prfx2;
        }
        then accept;
    }
    term t2 {
        then reject;
    }
}
content_copy zoom_out_map
user@R1# show routing-options
autonomous-system 200;

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

验证

确认配置工作正常。

检查设备 R1 上配置的策略

目的

验证设备 R1 的动态和静态策略是否有效。

操作

从设备 R1 中,输入 show policy 命令。

content_copy zoom_out_map
user@R1> show policy
Configured policies:
dyn_policy1
dyn_policy2
static_policy1
static_policy2
dyn_policy1
dyn_policy2

意义

动态策略被列出两次,因为它们配置了两次,即动态数据库中的第一次配置和集中配置。辅助配置位于引用动态数据库的静态数据库中,如下所示:

在动态数据库中配置

content_copy zoom_out_map
policy-statement dyn_policy1 {
    term t1 {
        from {
            prefix-list dyn_prfx1;
        }
        then accept;
    }
    term t2 {
        then reject;
    }
}
policy-statement dyn_policy2 {
    term t1 {
        from {
            prefix-list dyn_prfx2;
        }
        then accept;
    }
    term t2 {
        then reject;
    }
}

从静态数据库引用

content_copy zoom_out_map
policy-statement dyn_policy1 {
    dynamic-db;
}
policy-statement dyn_policy2 {
    dynamic-db;
}

检查从设备 R0 播发到设备 R1 的路由

目的

验证设备 R0 的路由策略是否正常工作。

操作

从设备 R0 中,输入命令,并使用 show route advertising-protocol bgp 设备 R1 的邻居地址。

content_copy zoom_out_map
user@R0> show route advertising-protocol bgp 10.0.0.2
inet.0: 28 destinations, 28 routes (28 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 172.16.1.0/24              Self                                    I
* 172.16.2.0/24              Self                                    I
* 172.16.3.0/24              Self                                    I
* 172.16.4.0/24              Self                                    I
* 172.16.5.0/24              Self                                    I
* 172.16.6.0/24              Self                                    I
* 172.16.7.0/24              Self                                    I
* 172.16.8.0/24              Self                                    I
* 172.16.9.0/24              Self                                    I
* 172.16.10.0/24             Self                                    I
* 10.0.0.0/30             Self                                    I

意义

设备 R0 正在向设备 R1 发送预期的路由。

检查设备 R1 从设备 R0 接收的路由

目的

验证设备 R1 的导入路由策略是否正常工作。

操作

在设备 R1 中,输入命令,并使用 show route receive-protocol bgp 设备 R0 的邻居地址。

content_copy zoom_out_map
user@R1> show route receive-protocol bgp 10.0.0.1
inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
  172.16.1.0/24              10.0.0.1                                100 I
  172.16.2.0/24              10.0.0.1                                100 I
  172.16.3.0/24              10.0.0.1                                100 I
  172.16.4.0/24              10.0.0.1                                100 I
  172.16.5.0/24              10.0.0.1                                100 I
  172.16.6.0/24              10.0.0.1                                100 I
  172.16.7.0/24              10.0.0.1                                100 I
  172.16.8.0/24              10.0.0.1                                100 I

意义

设备 R0 发送的某些路由未被设备 R1 接收。缺少路由 172.16.9.0/24、172.16.10.0/24 和 10.0.0.0/30。这是因为设备 R1 的导入策略(使用该语句应用于 import dyn_policy1 与设备 R0 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:

content_copy zoom_out_map
prefix-list dyn_prfx1 {
    172.16.1.0/24;
    172.16.2.0/24;
    172.16.3.0/24;
    172.16.4.0/24;
    172.16.5.0/24;
    172.16.6.0/24;
    172.16.7.0/24;
    172.16.8.0/24;
}

检查从设备 R2 播发到设备 R1 的路由

目的

验证设备 R2 的路由策略是否正常工作。

操作

在设备 R2 中,输入命令,并使用 show route advertising-protocol bgp 设备 R1 的邻居地址。

content_copy zoom_out_map
user@R2> show route advertising-protocol bgp 10.1.0.1
inet.0: 17 destinations, 17 routes (17 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 172.16.2.0/24              Self                                    I
* 172.16.3.0/24              Self                                    I
* 172.16.4.0/24              Self                                    I
* 172.16.5.0/24              Self                                    I
* 172.16.6.0/24              Self                                    I

意义

设备 R2 正在向设备 R1 发送预期的路由。

检查设备 R1 从设备 R2 接收的路由

目的

验证设备 R1 的导入路由策略是否正常工作。

操作

在设备 R1 中,输入命令,并使用 show route receive-protocol bgp 设备 R0 的邻居地址。

content_copy zoom_out_map
user@R1> show route receive-protocol bgp 10.1.0.2
inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
  172.16.2.0/24              10.1.0.2                                300 I
  172.16.3.0/24              10.1.0.2                                300 I
  172.16.4.0/24              10.1.0.2                                300 I
  172.16.5.0/24              10.1.0.2                                300 I

意义

设备 R2 发送的路由之一未被设备 R1 接收。缺少路由 172.16.6.0/24。这是因为设备 R1 的导入策略(使用该语句应用于 import static_policy1 与设备 R2 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:

content_copy zoom_out_map
prefix-list static_prfx1 {
    172.16.2.0/24;
    172.16.3.0/24;
    172.16.4.0/24;
    172.16.5.0/24;
}

检查设备 R1 向设备 R0 播发的路由

目的

验证设备 R1 的导出路由策略是否正常工作。

操作

在设备 R1 中,输入命令,并使用 show route advertising-protocol bgp 设备 R0 的邻居地址。

content_copy zoom_out_map
user@R1> show route advertising-protocol bgp 10.0.0.1
inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 172.16.2.0/24              Self                                    I
* 172.16.3.0/24              Self                                    I
* 172.16.4.0/24              Self                                    I
* 172.16.5.0/24              Self                                    I
* 172.16.6.0/24              Self                                    I

意义

也许出乎意料的是,设备 R1 未通过 BGP 从设备 R2 (172.16.6.0/24) 接收的路由仍然由设备 R1 通过 BGP 播发到设备 R0。发生这种情况有两个原因。第一个原因是路由 172.16.6.0/24 位于设备 R1 的路由表中,尽管是直接路由,如下所示:

content_copy zoom_out_map
user@R1> show route 172.16.6.0/24 protocol direct
inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden)
+ = Active Route, - = Last Active, * = Both

172.16.6.0/24         *[Direct/0] 2d 22:51:41
                    > via fe-1/2/3.0

第二个原因是设备 R1 的导出策略(使用该语句应用于 export dyn_policy2 与设备 R0 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:

content_copy zoom_out_map
prefix-list dyn_prfx2 {
    172.16.2.0/24;
    172.16.3.0/24;
    172.16.4.0/24;
    172.16.5.0/24;
    172.16.6.0/24;
}

请注意包含 172.16.6.0/24。

检查设备 R1 向设备 R2 播发的路由

目的

验证设备 R1 的导出路由策略是否正常工作。

操作

在设备 R1 中,输入命令,使用 show route advertising-protocol bgp 设备 R2 的邻居地址。

content_copy zoom_out_map
user@R1> show route advertising-protocol bgp 10.1.0.2
inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 172.16.1.0/24              Self                                    I
* 172.16.2.0/24              Self                                    I
* 172.16.3.0/24              Self                                    I
* 172.16.4.0/24              Self                                    I

意义

设备 R1 正在向设备 R2 发送预期的路由。设备 R1 的导出策略(使用该语句应用于 export static_policy2 与设备 R2 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:

content_copy zoom_out_map
prefix-list static_prfx2 {
    172.16.1.0/24;
    172.16.2.0/24;
    172.16.3.0/24;
    172.16.4.0/24;
}
footer-navigation