Forum Discussion
class variable pairs possible?
when CLIENT_ACCEPTED {
if {[IP::addr [IP::client_addr] equals "10.64.40.0/24"] } {
node 10.64.40.2
} elseif {[IP::addr [IP::client_addr] equals "10.64.41.0/24"] } {
node 10.64.41.2
}
}
etc...
Is it possible to use class with a pair of matched variables? I'm going to have quite a number of these statements and would prefer to keep the irule as small as possible.
Thanks,
-Ken
7 Replies
- Hi Ken,
class ip_subnets_class { { host 1.1.1.1 { "10.11.0.1" } network 2.2.2.0/24 { "10.10.10.10" } } }
- So to re-write your current iRule using hoolio's (sweet and simple) logic above:
when CLIENT_ACCEPTED { set dest [class match -value [IP::client_addr] equals ip_subnets_class] node $dest }
- Thanks!
Didn't work when I defined the class in the irule itself, but worked fine if I defined it in the data group list from the GUI.
- Yes, by design, datagroups/classes are separate objects from iRules, so they need to be defined independently.
- made a small change to it too, otherwise it broke other stuff since it's being applied to a 0.0.0.0/0.0.0.0 forwarding VS.
when CLIENT_ACCEPTED {
if {[class match [IP::client_addr] equals subnets] } {set dest [class match -value [IP::client_addr] equals subnets]node $dest}}
- Hi Yammy,
when CLIENT_ACCEPTED { set dest [class match -value [IP::client_addr] equals subnets] if {$dest ne ""} { node $dest } }
- Good to know it's working, thanks. And yes, classes are intentionally separate config objects.
Recent Discussions
Related Content
* 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