Need help debugging an iRule to route to a specific pool memeber based on source ip
Hello,
I am trying to create an iRule that does source based routing to specific pool members. I have found a few examples online that I based the below code off of. My iRule is not working. What seems to be the issue is the "member memberIP port" portion of the code that comes after the pool designation. If I remove that, it works fine in that it does route to the pool, just not a specific member (the virtual server does not have a default pool). Also based on observing the logging, the logic of the conditionals works, as the correct source ips attempt to route to the correct destination ips, somehow, I just can't get them to connect to a specific pool member. I have also tried this without specifying the ports of the pool members, that also fails. Incidentally, I also tried using switch statement logic and will probably go back to it, as I know it is a more efficient way to handle this; however, I ran into the same issue where the inclusion of the "member" syntax and related arguments cause the execution to fail. Any ideas would be appreciated.
when CLIENT_ACCEPTED {
set myPort
set myPool ""
set destination1 ""
set destination2 ""
set destination3 ""
set destination4 ""
if { [IP::client_addr] contains "" }{
log local0. "IP = [IP::client_addr] attempted to connect to "
pool $myPool member $destination1 $myPort
} elseif {
[IP::client_addr] contains "" }{
log local0. "IP = [IP::client_addr] attempted to connect to "
pool $myPool member $destination2 $myPort
} elseif {
[IP::client_addr] contains "" }{
log local0. "IP = [IP::client_addr] attempted to connect to "
pool $myPool member $destination3 $myPort
} elseif {
[IP::client_addr] contains "source4>" }{
log local0. "IP = [IP::client_addr] attempted to connect to "
pool $myPool member $destination4 $myPort
} else {
log local0. "IP = [IP::client_addr] attempted to connect to default location"
pool $myPool member $destination1 $myPort}
}