RIPng 网络中的流量控制
了解 RIPng 流量控制与优化路径成本的指标
要调整 RIPng 网络并控制通过网络的流量,您可以增加或降低通过网络的路径的成本。RIPng 提供了两种修改路径成本的方法:传入指标和传出指标,默认分别设置为 1。换句话说,默认情况下,RIPng 从邻接方导入或导出到邻接方路由的指标将递增 1。这些路由包括从 RIPng 学习的路由,以及从其他协议中学习的路由。指标是指定通过主机播发的任何路由的成本的属性。通过增加或减少整个网络链路的指标,从而降低成本,您可以控制网络上的数据包传输。
当跨分段的路由导入路由表中时,传入指标会修改单个分段的成本。例如,如果将该分段上的传入指标设置为 3,则链路上的单个分段成本将从 1 变为 3。增加的成本会影响通过该链路进行的所有路由计算。之前因高跃点计数而排除的其他路由现在可能会选择到路由器的转发表表中。
传出指标会修改从特定接口播发的所有路由的路径成本。与传入指标不同,传出指标会修改其他路由器正在学习的路由,从而控制其发送流量的方式。
如果从同一 RIPng 组的成员那里获知导出的路由,则与该路由关联的指标是正常的 RIPng 指标。例如,当向同一组的邻接方播发时,从邻居那里获知的指标为 5 的 RIPng 路由,其总指标为 7。但是,如果从不同组或不同协议中的 RIPng 邻接方获知此路由,则使用该组的传出指标中配置的指标值播发路由。
您可能希望提高路由的指标,以降低在路由表中选择并安装特定路由的可能性。此过程有时称为 路由中毒。您可能想要毒害路由的一些原因是路由使用成本相对较高,或者其带宽相对较低。
指标高于其他路由的路由仅在低指标路由不可用时成为活动路由。这样,更高指标的路由将用作备份路径。
增加导入路由指标的一种方法是配置导入策略。另一种方法是将 metric-in
语句包含在 RIPng 邻接方配置中。增加导出路由指标的一种方法是配置导出策略。另一种方法是将 metric-out
语句包含在 RIPng 邻接方配置中。
示例:配置为导入的 RIPng 路由添加的指标值,以控制路由选择流程
此示例说明如何更改要添加到传入路由的默认指标,以控制路由选择流程。
要求
配置此示例之前,不需要除设备初始化之外的特殊配置。
概述
通常,当存在多个路由时,RIPng 会选择跃点计数最低的路由。通过更改默认指标,您可以控制路由选择流程,以便跃点计数较高的路由优先于跃点计数较低的路由。
图 1 显示了此示例中使用的拓扑。

设备 R1 有两条可能到达 2001:db8::2/128 的路径。默认行为是向面向设备 R2 的 2001:db8:0:1:/64 接口发送流量。但是,假设通过设备 R3 的路径使用成本较低,或者具有更高的带宽链路。此示例说明如何使用 metric-in
语句来确保设备 R1 使用通过设备 R3 的路径到达 2001:db8::2/128。 CLI 快速配置 显示了 图 1 中所有设备的配置。第 #d51e58__d51e200 节介绍了设备 R1 上的步骤。
拓扑
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,然后将命令复制并粘贴到层级的 [edit]
CLI 中。
设备 R1
set interfaces fe-1/2/0 unit 1 description to-R2 set interfaces fe-1/2/0 unit 1 family inet6 address 2001:db8:0:1::/64 eui-64 set interfaces ge-1/2/1 unit 10 description to-R3 set interfaces ge-1/2/1 unit 10 family inet6 address 2001:db8:0:5::/64 eui-64 set interfaces lo0 unit 1 family inet6 address 2001:db8::1/128 set protocols ripng group primary export advertise-routes-through-ripng set protocols ripng group primary neighbor ge-1/2/1.10 set protocols ripng group secondary export advertise-routes-through-ripng set protocols ripng group secondary neighbor fe-1/2/0.1 metric-in 4 set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol direct set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol ripng set policy-options policy-statement advertise-routes-through-ripng term 1 then accept
设备 R2
set interfaces fe-1/2/0 unit 2 family inet6 address 2001:db8:0:2::/64 eui-64 set interfaces fe-1/2/1 unit 5 description to-R3 set interfaces fe-1/2/1 unit 5 family inet6 address 2001:db8:0:3::/64 eui-64 set interfaces lo0 unit 2 family inet6 address 2001:db8::2/128 set protocols ripng group ripng-group export advertise-routes-through-ripng set protocols ripng group ripng-group neighbor fe-1/2/0.2 set protocols ripng group ripng-group neighbor fe-1/2/1.5 set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol direct set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol ripng set policy-options policy-statement advertise-routes-through-ripng term 1 then accept
设备 R3
set interfaces fe-1/2/0 unit 6 family inet6 address 2001:db8:0:4::/64 eui-64 set interfaces ge-1/2/1 unit 9 description to-R1 set interfaces ge-1/2/1 unit 9 family inet address 10.0.0.9/30 set interfaces ge-1/2/1 unit 9 family inet6 address 2001:db8:0:6::/64 eui-64 set interfaces lo0 unit 3 family inet6 address 2001:db8::3/128 set protocols ripng group ripng-group export advertise-routes-through-ripng set protocols ripng group ripng-group neighbor fe-1/2/0.6 set protocols ripng group ripng-group neighbor ge-1/2/1.9 set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol direct set policy-options policy-statement advertise-routes-through-ripng term 1 from protocol ripng set policy-options policy-statement advertise-routes-through-ripng term 1 then accept
逐步过程
以下示例要求您在配置层次结构中的各个级别上导航。有关导航 CLI 的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
要配置 RIPng 指标:
配置网络接口。
[edit interfaces] user@R1# set fe-1/2/0 unit 1 description to-R2 user@R1# set fe-1/2/0 unit 1 family inet6 address 2001:db8:0:1::/64 eui-64 user@R1# set ge-1/2/1 unit 10 description to-R3 user@R1# set ge-1/2/1 unit 10 family inet6 address 2001:db8:0:5::/64 eui-64 user@R1# set lo0 unit 1 family inet6 address 2001:db8::1/128
创建 RIPng 组并添加接口。
要在 Junos OS 中配置 RIPng,必须配置一个或多个组,其中包含启用了 RIPng 的接口。无需在环路接口上启用 RIPng。
对于面向设备 R2 的接口, 指标 4 设置会使此路由不太可能被选为活动路由。
[edit protocols ripng] user@R1# set group primary neighbor ge-1/2/1.10 user@R1# set group secondary neighbor fe-1/2/0.1 metric-in 4
创建路由策略以播发直接路由和 RIPng 学习路由。
[edit policy-options policy-statement advertise-routes-through-ripng term 1] user@R1# set from protocol direct user@R1# set from protocol ripng user@R1# set then accept
应用路由策略。
在 Junos OS 中,只能在组级别应用 RIPng 导出策略。
[edit protocols ripng] user@R1# set group primary export advertise-routes-through-ripng user@R1# set group secondary export advertise-routes-through-ripng
结果
在配置模式下,输入 、 show protocols
和show policy-options
命令,show interfaces
以确认您的配置。如果输出未显示预期的配置,请重复此示例中的配置说明,以便进行更正。
user@R1# show interfaces
fe-1/2/0 {
unit 1 {
description to-R2;
family inet6 {
address 2001:db8:0:1::/64 {
eui-64;
}
}
}
}
ge-1/2/1 {
unit 10 {
description to-R3;
family inet6 {
address 2001:db8:0:5::/64 {
eui-64;
}
}
}
}
lo0 {
unit 1 {
family inet6 {
address 2001:db8::1/128;
}
}
}
user@R1# show protocols
ripng {
group primary {
export advertise-routes-through-ripng;
neighbor ge-1/2/0.10;
}
group secondary {
export advertise-routes-through-ripng;
neighbor fe-1/2/0.1 {
metric-in 4;
}
}
}
user@R1# show policy-options
policy-statement advertise-routes-through-ripng {
term 1 {
from protocol [ direct ripng ];
then accept;
}
}
完成设备配置后,请在配置模式下输入 提交 。
验证
确认配置工作正常。
验证预期的路由是否处于活动状态
目的
请确保设备 R1 使用通过设备 R3 的路径到达 2001:db8:0:2:2a0:a514:0:24c/128。
行动
在操作模式下,输入 show route 2001:db8:0:2:2a0:a514:0:24c
命令。
user@R1> show route 2001:db8:0:2:2a0:a514:0:24c inet6.0: 16 destinations, 17 routes (16 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 2001:db8:0:2::/64 *[RIPng/100] 01:54:35, metric 3, tag 0 > to fe80::2a0:a514:0:94c via ge-1/2/1.10
意义
通过 ge-1/2/1.10 输出到 fe80:2a0:a514:0:94c 表示设备 R1 使用通过设备 R3 的路径达到 2001:db8:0:2a0:2a0:a514:0:24c/128。此路由的指标为 3。
移除指标 in 语句
目的
删除或停用指标 in 语句,以查看 2001:db8:0:2:2a0:a514:0:24c/128 路由会发生什么情况。
行动
在配置模式下,停用
metric-in
语句。[edit protocols ripng group secondary neighbor fe-1/2/0.1] user@R1# deactivate metric-in user@R1# commit
在操作模式下,输入
show route 2001:db8:0:2:2a0:a514:0:24c
命令。user@R1> show route 2001:db8:0:2:2a0:a514:0:24c inet6.0: 16 destinations, 17 routes (16 active, 0 holddown, 0 hidden) + = Active Route, - = Last Active, * = Both 2001:db8:0:2::/64 *[RIPng/100] 00:00:02, metric 2, tag 0 > to fe80::2a0:a514:0:24c via fe-1/2/0.1
意义
通过 fe-1/2/0.1 输出到 fe80:2a0:a514:0:24c 表示设备 R1 使用通过设备 R2 的路径达到 2001:db8:0:2a0:2a0:a514:0:24c/128。此路由的指标为 2。