Forum Discussion
LillyM_9417
Dec 15, 2011Altostratus
Switch & external datagroup file
Hello,
I need to create an irule with the following properties..
Thanks a lot in advance..
---Firstly, I am doing all the following items with IF claues in prod enviromen...
hooleylist
Dec 15, 2011Cirrostratus
I agree with Hamish that it would be more efficient to combine the entries into one datagroup if it will work with your scenario. However, if you want to check a separate datagroup for different IP ranges, you could do something like this with a datagroup which maps host/networks to separate datagroups:
Datagroups
class ip_to_dg_name_dg {
{
host 10.10.10.10 { "classA" }
host 10.11.10.10 { "classB" }
network 10.12.0.0/16 { "classB" }
network 10.13.0.0/16 { "classC" }
}
}
class classA {
{
"classA_trx1" { "poolA" }
"classA_trx2" { "poolB" }
}
}
class classB {
{
"classB_trx1" { "poolC" }
"classB_trx2" { "poolD" }
}
}
class classC {
{
"classC_trx1" { "poolE" }
"classC_trx2" { "poolF" }
}
}
iRule snippet
when CLIENT_DATA {
set pay1 [TCP::payload 8]
binary scan $pay1 IA4 len1 trx
Check if $trx was matched
if {$trx ne ""}{
Look up the client IP in the ip to datagroup name datagroup
set dg [class match -value [IP::client_addr] equals ip_to_dg_name_dg]
Check if there was a match and the datagroup exists
if {$dg ne "" and [class exists $dg]}{
Look up $trx and get the corresponding pool
set trx_value [class match -value $trx equals $dg]
Check if there was a value returned from the class match
if {$trx_value ne ""}{
Do something with the return value, like assign a pool
if {[catch {pool $trx_value} result]==0}{
Assigned the $trx_value pool successfully, so stop processing the iRule
return
} else {
Failed to assign the $trx_value pool
}
} else {
Lookup of $trx in $dg failed
}
} else {
$dg was not matched or did not exist
}
} else {
$trx was not found
}
}
Aaron
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