I would try to avoid using so many repeated 'if' statements as it can be come quite cumbersome and small changes could ended up breaking your iRule.
Using a datagroup with IP to pool mappings can be a cleaner way to achieve the same result. Switch statements are also faster and are a good alternative to using successive 'or' operators.
Also the second 'if' block looks like it could be placed within the first - for this reason I've included it within the same switch 'or' block.
Datagroup
ltm data-group internal my_dg {
records {
10.1.1.1 {
data pool_a
}
10.1.1.2 {
data pool_b
}
}
type string
}
iRule
when CLIENT_ACCEPTED {
switch [TCP::local_port] {
"7002" -
"443" -
"8443" -
"7001" -
"80" {
if {[set my_app [class match -value [IP::addr[IP::client_addr] equals "my_dg"]]]} {
persist none
pool $my_app
}
}
}
}