作者: reistlin
来源: http://www.reistlin.com/blog/273
更新时间: 2009.03
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要

f5.gif

[F5] 多链路负载均衡设备主要采用以下几种技术来处理 Outbound 流出流量。

f5_products.gif

Default Gateway Pool

在 Default Gateway Pool 中,定义相应的 ISP 对端路由器地址,作为负载均衡的对象,并且可以捆绑健康检查,负载均衡算法以及会话保持等属性。Default Gateway Pool 中 的Nodes 定义为多个 F5 多链路负载均衡设备的缺省路由。

For Example:

pool default_gateway_pool {
lb_method dynamic_ratio
member 100.1.1.1:0
member 200.1.1.1:0
}

Default Gateway Pool 中的 Nodes 为若干个下一跳路由器(Next Hop Router)的地址,用作 Outbound 负载均衡,可以通过三种方式生成。

1、Setup Utility 中配置多个 Gateway IP,用空格分开;
2、在 Configuration Utility 中 Link Configuration 下增加多个 Links;
3、在 Pool 中定义一个 Default Gateway Pool。

将 Default Gateway Pool 中的 Nodes 配置为 F5 多链路负载均衡器的 Default Gateway,可以通过 netstat -rn 命令查看路由表。

Destination  Gateway    Flags  MTU   If
default        100.1.1.1   UGS    1500  vlan2
default        200.1.1.1   UGS    1500  vlan3

Wildcart Virtual Server

Wildcart Virtual Server – 0.0.0.0:0/internal,Wildcart Virtual Server 是指 0.0.0.0 这个特殊的虚拟服务器,一般用于捆绑 Default Gateway Pool。

下面的配置中的 * 代表 0.0.0.0:0 这个特殊的 Virtual Server,称为Wildcart Virtual Server,用来表示访问外网任意地址和服务端口,也可以配置为 0.0.0.0:80 等等,这样 Outbound 流量会先命中 0.0.0.0:80 这个 Virtual Server,然后再命中 0.0.0.0:0 这个 Virtual Serve。

For Example:

virtual internal:* unit 1 {
use pool default_gateway_pool
}

Monitor

F5 多链路负载均衡器可以通过相应的配置,检查 NHR 或更上层 Router 的连通状态来决定链路的可用性,并且可以使用 ICMP/TCP 等多种测试方法。

For example:

node 100.1.1.1 200.1.1.1 monitor use icmp

iRule

在 Outbound 负载均衡中,iRules 经常被配置用来进行复杂的链路选择,这里的 ISP1_Class 和 ISP2_Class 可能包含许多地址或地址段,使用 one of 命令就不需要在 iRules 中写许多 Class 涵盖的具体内容。

For example:

if (server_addr ==one of ISP1_Class) {
Use pool ISP1_Pool
}
else if (server_addr ==one of ISP2_Class) {
Use pool ISP2_Pool
}
else {
Use pool Default_Gateway_Pool
}

SNAT / SNAT Automap

对于 Outbound 流量的地址翻译,F5 多链路负载均衡设备使用了称为 SNAT (Secure NAT / Source NAT)的方法。当选定一个路由器(ISP Gateway)传送 Outbound 流量时,多链路负载均衡设备将选择该 ISP 提供的地址。如果多链路负载均衡设备选择 ISP1 作为 Outbound 流量的路径,则它将把内部的主机地址 192.168.1.A 翻译为 100.1.1.A,并作为 Outbound 数据包的源地址。同样,如果多链路负载均衡设备选择 ISP2 作为 Outbound 流量的路径,则它将把内部的主机地址192.168.1.A 翻译为 200.1.1.A,并作为 Outbound 数据包的源地址。

当 F5 多链路负载均衡设备定义:将内部的主机地址翻译为 Vlan Self-IP 时,即 100.1.1.A=100.1.1.2;200.1.1.A=200.1.1.2 时,称为 SNAT Automap。

SNAT(Secure NAT)通过将源地址翻译成可路由的地址,来访问外网。SNAT IP 能够等于 Virtual Server IP,可以用来解决特殊应用(例如:Email转发)的地址反向解析问题;SNAT Automap 将源地址翻译成 F5 多链路负载均衡的 Vlan Self-IP,由于 Vlan Self-IP 可以是多个地址,因此能够实现SNAT一个地址池的目的。

For Example:

snat map { 192.168.1.34 to 100.1.1.34 unit 1 }
snat map { 192.168.1.35 to 200.1.1.35 unit 1 }
snat map { internal to auto unit 1 }

标签: f5