Molet

路由路径的流量负载均衡配置

Molet 运维技术 2022-11-16 436浏览 0

想必大家对路由器负载均衡功能都不会陌生,那么我们可以通过对路由器的转发表进行设置,从而达到流量负载均衡的目的。那么让我们一起来看看具体的路径配置内容吧。

缺省状态下,转发表中只安装路由表里的最佳路径

lab@juniper#run show route 6.6.6.6

inet.0:19destinations,22routes(19active,0holddown,0hidden) 
+=ActiveRoute,-=LastActive,*=Both 

6.6.6.6/32*[IS-IS/18]00:03:33,metric42 
to10.0.0.2viafxp1.1 
>to10.0.1.2viafxp1.2 

[edit] 
lab@juniper#runshowrouteforwarding-table 
5.5.5.5/32user010.0.1.2ucst4907fxp1.2 
6.6.6.6/32user010.0.1.2ucst4907fxp1.2 
10.0.0.0/30intf0rslv4591fxp1.1

现在进行配置将路由表里的所有路径都安装进转发表

lab@juniper#showrouting-options 
forwarding-table{ 
exportload-balance-route; 
} 

lab@juniper#showpolicy-options 

policy-statementload-balance-route{ 
then{ 
load-balanceper-packet; 
} 
}

查看路由表,路由器选择10.0.1.2作为最佳路由

lab@juniper#runshowroute6.6.6.6 

inet.0:19destinations,22routes(19active,0holddown,0hidden) 
+=ActiveRoute,-=LastActive,*=Both 

6.6.6.6/32*[IS-IS/18]00:03:33,metric42 
to10.0.0.2viafxp1.1 
>to10.0.1.2viafxp1.2

#p#转发表里对其所有前缀安装了多条路径

(注:安装的条目和PFE有关,IP-ASIC最多安装8条等价路径,以每个包为单位进行流量负载均衡,IP-II-ASIC最多安装16条,以每个流为单位进行流量负载均衡)

lab@juniper#runshowrouteforwarding-table 
1.1.1.1/32intf01.1.1.1locl4681 
2.2.2.2/32user0ulst48911 
10.0.0.2ucst4972fxp1.1 
10.0.1.2ucst4902fxp1.2 
3.3.3.3/32user0ulst48911 
10.0.0.2ucst4972fxp1.1 
10.0.1.2ucst4902fxp1.2 
4.4.4.4/32user0ulst48911 
10.0.0.2ucst4972fxp1.1 
10.0.1.2ucst4902fxp1.2 
5.5.5.5/32user0ulst48911 
10.0.0.2ucst4972fxp1.1 
10.0.1.2ucst4902fxp1.2 
6.6.6.6/32user0ulst48911 
10.0.0.2ucst4972fxp1.1 
10.0.1.2ucst4902fxp1.2 
10.0.0.0/30intf0rslv4591fxp1.1

配置路由器,只对特定前缀的多条路径安装进转发表,6.0.0.0/8,4.0.0.0/8,2.0.0.0/8

[edit] 
lab@juniper#showpolicy-optionspolicy-statementload-balance-route 
from{ 
route-filter6.0.0.0/8orlonger; 
route-filter2.0.0.0/8orlonger; 
route-filter4.0.0.0/8orlonger; 
} 
then{ 
load-balanceper-packet; 
} 
lab@juniper#showrouting-options 
forwarding-table{ 
exportload-balance-route; 
}

观察转发表,只对其特定前缀安装了多条路径,6.0.0.0/8,4.0.0.0/8,2.0.0.0/8

lab@juniper#runshowrouteforwarding-table 
1.1.1.1/32intf01.1.1.1locl4681 
2.2.2.2/32user0ulst4893 
10.0.0.2ucst4976fxp1.1 
10.0.1.2ucst4906fxp1.2 
3.3.3.3/32user010.0.1.2ucst4906fxp1.2 
4.4.4.4/32user0ulst4893 
10.0.0.2ucst4976fxp1.1 
10.0.1.2ucst4906fxp1.2 
5.5.5.5/32user010.0.1.2ucst4906fxp1.2 
6.6.6.6/32user0ulst4893 
10.0.0.2ucst4976fxp1.1 
10.0.1.2ucst4906fxp1.2 
10.0.0.0/30intf0rslv4591fxp1.1 
10.0.0.0/32dest010.0.0.0recv4571fxp1.1

#p#对5.5.5.5进行traceroute,每次都使用相同的下一跳

lab@juniper>traceroute5.5.5.5 
tracerouteto5.5.5.5(5.5.5.5),30hopsmax,40bytepackets 
110.0.1.2(10.0.1.2)0.457ms0.774ms0.224ms 
210.0.2.2(10.0.2.2)0.317ms0.360ms0.287ms 
310.0.3.2(10.0.3.2)0.398ms0.439ms0.383ms 
45.5.5.5(5.5.5.5)0.495ms0.533ms1.149ms 

lab@juniper>traceroute5.5.5.5 
tracerouteto5.5.5.5(5.5.5.5),30hopsmax,40bytepackets 
110.0.1.2(10.0.1.2)0.431ms0.380ms0.225ms 
210.0.2.2(10.0.2.2)0.320ms0.367ms0.310ms 
310.0.3.2(10.0.3.2)0.402ms0.438ms0.392ms 
45.5.5.5(5.5.5.5)0.495ms0.546ms0.491ms 

lab@juniper>traceroute5.5.5.5 
tracerouteto5.5.5.5(5.5.5.5),30hopsmax,40bytepackets 
110.0.1.2(10.0.1.2)0.427ms0.381ms0.220ms 
210.0.2.2(10.0.2.2)0.315ms0.362ms0.305ms 
310.0.3.2(10.0.3.2)0.401ms0.431ms0.383ms 
45.5.5.5(5.5.5.5)0.492ms0.529ms0.479ms 

lab@juniper>

对6.6.6.6进行traceroute,每次都使用不同的下一跳

lab@juniper>traceroute6.6.6.6 
tracerouteto6.6.6.6(6.6.6.6),30hopsmax,40bytepackets 
110.0.1.2(10.0.1.2)0.427ms0.375ms10.0.0.2(10.0.0.2)0.224ms 
210.0.2.2(10.0.2.2)0.364ms0.349ms0.292ms 
310.0.3.2(10.0.3.2)0.385ms0.433ms0.386ms 
410.0.5.2(10.0.5.2)0.467ms0.518ms0.462ms 
56.6.6.6(6.6.6.6)0.572ms0.622ms0.567ms 

lab@juniper>traceroute6.6.6.6 
tracerouteto6.6.6.6(6.6.6.6),30hopsmax,40bytepackets 
110.0.0.2(10.0.0.2)0.436ms10.0.1.2(10.0.1.2)0.382ms0.355ms 
210.0.2.2(10.0.2.2)0.316ms0.372ms0.315ms 
310.0.3.2(10.0.3.2)0.394ms0.443ms0.391ms 
410.0.5.2(10.0.5.2)0.473ms0.519ms0.465ms 
56.6.6.6(6.6.6.6)0.572ms0.610ms0.586ms 

lab@juniper#runtraceroute6.6.6.6 
tracerouteto6.6.6.6(6.6.6.6),30hopsmax,40bytepackets 
110.0.1.2(10.0.1.2)7.488ms0.511ms10.0.0.2(10.0.0.2)0.243ms 
210.0.2.2(10.0.2.2)0.367ms0.351ms0.299ms 
310.0.3.2(10.0.3.2)0.404ms0.435ms0.384ms 
410.0.5.2(10.0.5.2)0.478ms0.542ms0.470ms 
56.6.6.6(6.6.6.6)0.589ms0.615ms0.572ms 

[editlogical-routers] 
lab@juniper#runtraceroute6.6.6.6 
tracerouteto6.6.6.6(6.6.6.6),30hopsmax,40bytepackets 
110.0.0.2(10.0.0.2)0.429ms10.0.1.2(10.0.1.2)0.388ms0.363ms 
210.0.2.2(10.0.2.2)0.322ms0.361ms0.304ms 
310.0.3.2(10.0.3.2)0.393ms0.452ms0.387ms 
410.0.5.2(10.0.5.2)0.471ms0.522ms0.471ms 
56.6.6.6(6.6.6.6)0.594ms0.632ms0.571ms

基本上转发表流量负载均衡的所有路径配置就完成了。

继续浏览有关 网络 的文章
发表评论