SNAT based upon destination port

I have a requirement to load balance to a pool of IP address:ports and additionally present a dedicated IP source address based upon the destination port. I have a simple iRule that I thought would accomplish that but it isn’t performing the SNAT function. It is load balancing to the correct destination ports but the source IP is the native IP of the client. Is there something wrong with my rule?

when LB_SELECTED {

if {[TCP::remote_port] equals 13261} {

snat 192.168.248.81

}

elseif {[TCP::remote_port] equals 13262} {

snat 192.168.248.82

}

elseif {[TCP::remote_port] equals 13263} {

snat 192.168.248.83

}

}

Thanks.

Use different when clause

Just to clarify, the snat Command is only available in these events: CLIENT_ACCEPTED, HTTP_REQUEST, SERVER_CONNECTED

Thanks for the clarification. I was following an example given in the iRule descriptions so I didn’t do a whole lot of digging. DevCentral - An F5 Technical Community

I’ll try one of the others.

OK, great.

The actual fix was to change the ‘if’ check from TCP::remote_port to LB::server port.

Hmmm, interesting.