Forum Discussion
Datagroup and switch command
Hello,
I created different datagroup (list of TCP ports) and based on this setting, selecting the correct pool within my irule.
ltm data-group internal DG_TCP-010901-10902 { records { 10901 { } 10902 { } } type string }
when CLIENT_ACCEPTED { switch [TCP::local_port] { DG_TCP-010901-10902 { pool P_010901-10902 } etc etc default { reject } } }
Unfortunatly, it doesn't work...
If I change the irule to the following it works... when CLIENT_ACCEPTED { switch [TCP::local_port] { "10901" { pool P_010901-10902 } "10902" { pool P_010901-10902 } etc etc default { reject } } }
Regards,
I prefer to use the switch command instead of if commands and using datagroup to avoid mistake when editing irule...
HA
- Lee_Sutcliffe
Nacreous
You cant really use datagroups in a switch statement (unless you nest an
within the switch)if
To look up a datagroup you'll need to use the
commandclass
when CLIENT_ACCEPTED { if {[class match [TCP::local_port] equals "DG_TCP-010901-10902"]} { reject }
- Stanislas_Piro2
Cumulonimbus
You can try with this code:
when CLIENT_ACCEPTED { switch [TCP::local_port] { "10901" - "10902" { pool P_010901-10902 } default { reject } } }
or use a data group containing pool name as value
ltm data-group internal DG_TCP { records { 10901 {P_010901-10902} 10902 {P_010901-10902} XXXX {P_XXXX} } type string } when CLIENT_ACCEPTED { if {[set pool [class match -value [TCP::local_port] equals "DG_TCP"]] ne ""} { pool $pool } else { reject } }
- HA13029
Nimbostratus
Hi,
Thanks Stanislas, it works fine !!
Regards
Hedi
- HA13029
Nimbostratus
One last question... Can I use datagroup to reference some URLs (sometimes with wildcard) and based on the result, select the correct pool ?? Example : if the uri match /000552/1743* then select the pool P_0005521743 What's the irule looks like ??
Regards,
HA
- HA13029
Nimbostratus
Hello,
Do you think it's ok with the following ??
ltm data-group internal DG_URI { records { "/000042/16001" {pool P_name } } type string }
when HTTP_REQUEST { if {[set pool [class match [HTTP::uri] starts_with "DG_URI"]} { pool $pool } else { pool default } }
Regards,
HA
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