Forum Discussion
Ameya_4149
Nimbostratus
Feb 16, 2012iRules 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...
Michael_Yates
Nimbostratus
Feb 16, 2012Hi Ameya,
It really depends on how far you want to go. Generally the more efficient the iRule the harder it is to maintain, but you could save yourself some cycles by only performing the class match on a single Datagroup instead of three. This could be accomplished by creating an Address Datagroup and setting the value of the IP Address or Network to a specific value to key from.
Then you could do something like this:
when CLIENT_ACCEPTED {
log local0. "Client IP Address: [IP::client_addr]"
set groupvalue [class match -value [IP::client_addr] equals address.datagroup.list ]
set defaultpool "pool.ltm.ve.nightclub.com"
log local0. "Group Value: $groupvalue"
switch $groupvalue {
"groupa" { set destination "pool.one" }
"groupb" { set destination "pool.two" }
"groupc" { set destination "pool.three" }
default { set destination $defaultpool }
}
if { [active_members $destination] < 0 } {
log local0. "Destination Pool: $destination"
pool $defaultpool
}
else {
log local0. "Destination Pool: $destination"
pool $destination
}
}
Hope this helps.
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