I am guessing that your BIG-IP Version is 9.x.x. If you are running v10.x.x you should change from “matchclass” to “class match” and drop the “$::” from the class name.
Try this:
when CLIENT_ACCEPTED {
if { [matchclass [IP::client_addr] equals $::src_nets ] and [[TCP::local_port] equals "8181" ] } {
snat 172.16.1.100
}
}
Try this and let me know how it works out. I have converted it to v10.x.x (match class), modified the second condition, and modified the event from CLIENT_ACCEPTED to HTTP_REQUEST:
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals src_nets ] and [[LB::server port] equals "8181" ] } {
snat 172.16.1.100
}
}
I don’t think LB::server port will return a value until a load balancing selection has been made. If you want to check the client’s destination port, you can use TCP::local_port in CLIENT_ACCEPTED as you did earlier in this thread:
when HTTP_REQUEST {
if { [class match [IP::client_addr] equals src_nets ] and [TCP::local_port] == 8181 } {
snat 172.16.1.100
}
}
Hrm… [LB::server] and [LB::server pool] return the VS default pool name before a load balancing selection has been made (normally in LB_SELECTED). I wonder what LB::server port actually returns before a load balancing selection has been made. Is it the client destination port or a port of one of the pool members? I’m guessing the former, but it’s not very intuitive that the command would even work as it should return info on the load balancing selection.
The environment I tested the even in had the request incoming on Port 80, with Port Translation enabled.
I executed the following iRule and only received a response in the HTTP_REQUEST Event. A Load Balancing decision would have had to have been made in order to determine what the server Destination Port would have been.