Forum Discussion
Ron_Kim_110696
Nimbostratus
Mar 23, 2007Selective SNAT based on server network
I'm trying to do a selective SNAT based on where the servers are located.
The BIGIP has multiple network connections.
This iRule does not work.
Any suggestions?
I have three SNAT Pools. End-users as week as servers will access these virtual servers.
=================================
when LB_SELECTED {
if {[IP::addr "[IP::server_addr]/23" equals "192.168.68.0/23"]} {
use snatpool dmz192.168.68_SNAT
}
elseif {[IP::addr "[IP::server_addr]/23" equals "192.168.70.0/23"]} {
use snatpool dmz192.168.70_SNAT
} else {
use snatpool Corpnet-SNAT
}
}
==================================
- Ron_Kim_110696
Nimbostratus
This is a selective SNAT based on the server that is selected. - JRahm
Admin
Here's an example of matching single hosts. This has not been tested, but passes the syntax checker on version 9.1.2.class snat_map { "192.168.168.10 dmz192.168.68_SNAT" "192.168.170.10 dmz192.168.70_SNAT" } when LB_SELECTED { set local_subnet_snat [findclass [LB::server addr] $::snat_map " "] if { $local_subnet_snat ne "" } { snatpool $local_subnet_snat } }
- Ron_Kim_110696
Nimbostratus
I'm running version 9.4.0. - JRahm
Admin
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 } }
- Ron_Kim_110696
Nimbostratus
Thanks it is working, but I did have issues. I was seeing the following messages in the /var/log/ltm file. - JRahm
Admin
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. - JRahm
Admin
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. - Ron_Kim_110696
Nimbostratus
Thank you very much citizen_elah.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects