system-view
# 1. 删除现有无效配置
undo policy-based-route 1
# 2. 配置NQA检测(确保已配置)
nqa entry admin test1
type icmp-echo
destination ip 1.1.1.5
frequency 10
reaction 1 checked-element probe-fail threshold-type consecutive 3 action-type trigger-only
quit
nqa schedule admin test1 start-time now lifetime forever
nqa entry admin test2
type icmp-echo
destination ip 1.1.1.6
frequency 10
reaction 1 checked-element probe-fail threshold-type consecutive 3 action-type trigger-only
quit
nqa schedule admin test2 start-time now lifetime forever
# 3. 创建Track对象
track 1
nqa entry admin test1 reaction 1
quit
track 2
nqa entry admin test2 reaction 1
quit
# 4. 配置负载均衡策略路由(正确方式)
policy-based-route LOAD_BALANCE permit node 10
if-match acl 3001
apply next-hop 1.1.1.5 track 1
quit
policy-based-route LOAD_BALANCE permit node 20
if-match acl 3001
apply next-hop 1.1.1.6 track 2
quit
# 5. 应用策略路由到接口
interface GigabitEthernet 0/0 # 入口流量接口
ip policy-based-route LOAD_BALANCE
quit
# 6. 配置等价路由(ECMP)实现负载均衡(推荐)
ip route-static 0.0.0.0 0.0.0.0 1.1.1.5 track 1 preference 60
ip route-static 0.0.0.0 0.0.0.0 1.1.1.6 track 2 preference 60 # 相同优先级
# 7. 启用负载均衡
ip load-sharing mode per-flow # 基于流的负载均衡
ip load-sharing mode per-packet # 基于包的负载均衡(更均衡但可能乱序)
# 8. 保存配置
save force
weight
参数:# 错误语法
apply next-hop 1.1.1.5 track 1 weight 1
apply next-hop
不会实现负载均衡,而是按顺序尝试:policy-based-route LOAD_BALANCE permit node 10
if-match acl 3001
apply next-hop 1.1.1.5 track 1
quit
policy-based-route LOAD_BALANCE permit node 20
if-match acl 3001
apply next-hop 1.1.1.6 track 2
quit
ip route-static 0.0.0.0 0.0.0.0 1.1.1.5 track 1 preference 60
ip route-static 0.0.0.0 0.0.0.0 1.1.1.6 track 2 preference 60
display policy-based-route LOAD_BALANCE
display ip routing-table
# 应显示两条等价默认路由
display ip load-sharing
# 连续ping测试
ping -c 100 8.8.8.8
# 查看流量分布
display ip policy-based-route statistics
ip load-sharing mode per-flow
ip load-sharing mode per-packet
# 创建ACL匹配不同流量
acl basic 3001
rule 5 permit source 192.168.1.0 0.0.0.255 # 网段1
rule 10 permit source 192.168.2.0 0.0.0.255 # 网段2
policy-based-route LOAD_BALANCE permit node 10
if-match acl 3001 rule 5 # 网段1走路径1
apply next-hop 1.1.1.5 track 1
quit
policy-based-route LOAD_BALANCE permit node 20
if-match acl 3001 rule 10 # 网段2走路径2
apply next-hop 1.1.1.6 track 2
quit
display track all
display nqa result
display policy-based-route statistics
# 尝试不同模式
undo ip load-sharing mode
ip load-sharing mode per-flow
# 或
ip load-sharing mode per-packet
system-view
# 1. 配置NQA和Track
nqa entry admin test1
type icmp-echo
destination ip 1.1.1.5
frequency 10
reaction 1 checked-element probe-fail threshold-type consecutive 3 action-type trigger-only
quit
nqa schedule admin test1 start-time now lifetime forever
nqa entry admin test2
type icmp-echo
destination ip 1.1.1.6
frequency 10
reaction 1 checked-element probe-fail threshold-type consecutive 3 action-type trigger-only
quit
nqa schedule admin test2 start-time now lifetime forever
track 1
nqa entry admin test1 reaction 1
quit
track 2
nqa entry admin test2 reaction 1
quit
# 2. 配置等价路由
ip route-static 0.0.0.0 0.0.0.0 1.1.1.5 track 1 preference 60
ip route-static 0.0.0.0 0.0.0.0 1.1.1.6 track 2 preference 60
# 3. 配置负载均衡模式
ip load-sharing mode per-flow
# 4. 保存配置
save force
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作
举报
×
侵犯我的权益
×
侵犯了我企业的权益
×
抄袭了我的内容
×
原文链接或出处
诽谤我
×
对根叔社区有害的内容
×
不规范转载
×
举报说明
暂无评论