Ameya_4149
Feb 16, 2012Nimbostratus
iRules for Source IP based routing
Hi folks,
I am trying to write an iRule for Source IP based routing. So what I am trying to do is if a packet comes from a specific pool of IP's, my LTM should fooward it to a specific server. If the IP is not from that pool, it will be forwarded to the default pool. Also if all the servers in a specific pool are down, the packets should be forwarded to the default pool.
This is my code, want to know if we can do better. I am also looking for a low processing time.
when CLIENT_ACCEPTED {
if { [ class match [IP::client_addr] equals DataGroup_RegionA ] } {
if { [active_members Pool_A] < 1 } {
pool Default_pool}
else {pool Pool_A}
} elseif { [ class match [IP::client_addr] equals DataGroup_RegionB ] } {
if { [active_members Pool_B] < 1 } {
pool Default_pool}
else {pool Pool_B}
} elseif { [ class match [IP::client_addr] equals DataGroup_RegionC ] } {
if { [active_members Pool_C] < 1 } {
pool Default_pool}
else {pool Pool_C}
} else {pool Default_pool}
}
Pool A, B, C has more than 1 members (servers)
Default_pool has all the servers listed in Pool A, B and C
Thanks,
Ameya