Forum Discussion
Liu_Li_18953
May 07, 2008Nimbostratus
Posted By rodrigo.ev on 10/19/2006 2:17 PM
I'd like to propose another scenario we got in a customer:
Suppose we have the Wildcard Virtual Server (0.0.0.0:0) pointed to a Default Gateway Pool with my two ISP routers (200.1.0.1 and 200.2.0.1).
I want the outbound connection for specific internal servers to use another IP other than SelfIP/SNAT Automap (let's say Static SNAT Addresses 200.1.0.10 and 200.2.0.10).
With the iRule described above I can get this result, but the destination router will be selected by the SNAT, not leveraging the router/link status in a Link Controller Box.
The best would be to let the pool select the better router based on its metrics and then execute the iRule to SNAT to the proper static address.
class class_static_snat_servers {
host 10.0.0.10
host 10.0.0.11
}
class class_static_snat_gateways {
"200.1.0.1 200.1.0.10"
"200.2.0.1 200.2.0.10"
}
when CLIENT_ACCEPTED {
set static_snat_server [IP::client_addr]
}
when LB_SELECTED {
if {$::static_snat_server eq $::class_static_snat_servers]} {
set selected_gateway [findclass [LB::server addr] $::class_static_snat_gateways " "]
if { $selected_gateway ne "" } {
snat $selected_gateway
}
}
}
Or, in a short way:
when LB_SELECTED {
if {[matchclass [IP::client_addr] eq $::class_static_snat_servers]} {
set my_gw [findclass [LB::server addr] $::class_static_snat_gateways " "]
if { $my_gw ne "" } {
snat $my_gw
}
}
}
if i have many internal servers , i want use the networks instead of host IPs, every networks use a different snat ip ,can i build the class like this???
class class_static_snat_servers {
network 10.0.0.0 mask 255.255.255.0
network 10.0.1.0 mask 255.255.255.0
or
class class_static_snat_servers {
"10.0.0.0/24 200.1.0.10"
"10.0.1.0/24 200.1.0.11"
}