This is a selective SNAT based on the server that is selected.
There are servers on multiple subnets and BIGIP is also connected to these networks.
Since the BIGIP is NOT the default GW for these networks, all traffic that is sent to the server from the BIGIP need to SNAT’d in order for load balancing to work.
We need the SNAT address to be on the same subnet as the sever. Then use a default SNAT if the BIGIP does not have a directly connected self IP address on the same network.
You’re right. That wasn’t working! I’m wondering if the connection is already begun in the LB_SELECTED event. Doing an LB::detach seems to have fixed things:
when LB_SELECTED {
set dst_server [LB::server addr]
LB::detach
pool [LB::server pool] member $dst_server
set local_subnet_snat [findclass $dst_server $::snat_map " "]
log local0. "Local Server $dst_server, Snatpool $local_subnet_snat"
if { $local_subnet_snat ne "" } {
snatpool $local_subnet_snat
}
}
The developers could probably be more precise in responding, but the behavior without the LB::detach indicated to me that the server side connection had already begun at the LB_SELECTED event. If that’s the case, then I can no longer change my source IP, which is why I issued the LB::detach. This could be faulty logic, though.
Since I was detaching the connection, I wanted to make sure I re-attached to the same server, which is why I used the pool [LB::server pool] member $dst_server line. Without this line, detaching would kick off another load balancing decision, which may or may not impact your snat selection. As I’ve become more comfortable with iRules, I’ve tried to make the rules as generic as possible so I can reuse them on different virtuals or systems with as little rework as possible.
I have no idea on your third question. I haven’t convinced my employer that I need the web accelerator yet, so I have no experience with that piece.
BTW, the reason it wasn’t working with WAM on the surface is because the value returned by [LB::server addr] is a loopback, which probably isn’t defined in your class. I’m not sure how this would be handled.