Forum Discussion
Multiple Switch statements in a single iRule
- Aug 11, 2016
Yes, but what you really want to do is use a Data Group. Let's say you have a Data Group that looks like this:
create ltm data-group internal dg-address-matchers type ip \ records add { 10.11.0.0/16 { data "action1" } \ 10.12.0.0/16 { data "action2" } \ 10.13.13.0/22 { data "action3" } ... }
You would then use it thusly:
when CLIENT_ACCEPTED { set indicator [class lookup [IP::client_addr] dg-address-matchers] switch [class lookup [IP::client_addr] dg-address-matchers] { action1 { ... do something ... } action2 { ... do something else ... } ... etc ... "" { this means the IP matches no netblocks in the data-group } } }
Yes, but what you really want to do is use a Data Group. Let's say you have a Data Group that looks like this:
create ltm data-group internal dg-address-matchers type ip \
records add { 10.11.0.0/16 { data "action1" } \
10.12.0.0/16 { data "action2" } \
10.13.13.0/22 { data "action3" } ... }
You would then use it thusly:
when CLIENT_ACCEPTED {
set indicator [class lookup [IP::client_addr] dg-address-matchers]
switch [class lookup [IP::client_addr] dg-address-matchers] {
action1 {
... do something ...
}
action2 {
... do something else ...
}
... etc ...
"" {
this means the IP matches no netblocks in the data-group
}
}
}
- squeezebox_2829Aug 11, 2016Nimbostratus
Thanks for this information, I have two questions:
1) I am currently operating on Firmware version 10.2.4, is this the correct format for this version? 2) Second, I am trying to get some more information on how this comparison is going to work. I was under the impression I would need to provide a netmask for [IP::client_addr] to convert it to its given class IP address (network IP) ie. 192.168.1.45/24 == 192.168.1.0 for comparison purposes. Is the provided data-group performing that operation natively due to the data-group type ip? I am searching for more information on this.
Thanks,
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