Forum Discussion
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
- r_dynamo_79563NimbostratusThis iRule works, but I need an iRule to be applied only on the new one. Can this objective be met, without touching the wild card VS that is configured already?
- What_Lies_Bene1CirrostratusOK, well I guess it can just be applied to the wildcard VS like so;
when CLIENT_ACCEPTED { if { [IP::addr [IP::client_addr] equals 1.1.1.1] } { do something } elseif { virtual 'new virtual name' } }
- What_Lies_Bene1CirrostratusSorry, no elseif required;
when CLIENT_ACCEPTED { if { [IP::addr [IP::client_addr] equals 1.1.1.1] } { do something } else { virtual 'new virtual name' } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects