If you haven’t already figured out how to do what you want, could you clarify it a bit?
Are you’re trying to allow LTM to select the pool member, but hard code the destination IP address? If so you could create a pool for each destination port you want LTM to connect to. Or you could use a single pool, allow LTM to select the pool member and then rewrite the destination port. I’m not sure which solution you’re aiming for.
Im trying to use the same pool and redirect to a different tcp port, It works fine if I create a different pool and listener but im trying to keep the amount of objects created to a minimum,
I think that’s clearer now. So you can force a load balancing selection in CLIENT_ACCEPTED and then rewrite the port to the one you’ve calculated. I’m not sure whether you can use the pool command if the IP:port you’re specifying isn’t defined as a pool member. So give this a try and if it doesn’t work, try changing the pool command to node :
when CLIENT_ACCEPTED {
log local0. "[IP::client_addr]:[TCP::client_port]: New connection to [IP::local_addr]:[TCP::local_port]"
Calculate destination port based on destination port and IP address
switch [TCP::local_port] {
443 {
set port [expr {[getfield [IP::local_addr] "." 4] + 2000}]
}
8443 {
set port [expr {[getfield [IP::local_addr] "." 4] + 3000}]
}
default {
Take some default action? For now, set this to some arbitrary value
If this should be the same value as 443 requests,
you could remove the 443 case and just use this default to catch it
set port [expr {[getfield [IP::local_addr] "." 4] + 2000}]
}
}
log local0. "[IP::client_addr]:[TCP::client_port]: Selecting pool by TCP listener: $port"
Force a load balancing selection
set pool_selection [LB::select]
log local0. "[IP::client_addr]:[TCP::client_port]: LB selection: $pool_selection"
Replace the selected pool member port with the calculated port
And use eval to make the load balancing selection
eval [lreplace $pool_selection 4 4 $port]
Or without the intermediate variables:
eval [lreplace [LB::select] 4 4 $port]
log local0. "[IP::client_addr]:[TCP::client_port]: Using [lreplace $pool_selection 4 4 $port]"
}
when SERVER_CONNECTED {
Debug logging. Remove/comment out this event when done testing
log local0. "[IP::client_addr]:[TCP::client_port]: Connected to [IP::server_addr]:[TCP::server_port]"
}
Thanks for the info, Tried the iRule suggested but still the packets dont get forwarded to end server on the port I want it to be forwarded to
Think I will have you use pool command to node , Is there anyway I can split traffic over two nodes ? if I use the node command it will only forward to one node of my pool.