Forum Discussion
SNAT Based on Source and Destination
I am trying to apply conditional SNAT based on source and destination for any service otherwise leave them alone and allow the static NAT to take effect. What I did is ...
NOTE: The client servers normally have static NATs applied.
1. Created Forwarding (IP) VIP available only on the VLAN where the client servers reside with the following configuration:
virtual vsANY-NodeNet
destination any:any
disable
ip forward
rule snat_rule
vlans NodeNet enable
NOTE: NodeNet is the VLAN where the client servers reside.
2. Created an iRule labeled 'snat_rule' as follows:
when CLIENT_ACCEPTED {
if {[matchclass IP::local_addr eq $::the_destination_ip] and [matchclass IP::client_addr eq $::the_source_ip]} {
snat 10.10.1.1
} else {
snat none i tried using 'forward' here too
}
}
2a. I tried this too:
when CLIENT_ACCEPTED {
if {[matchclass IP::local_addr eq $::the_destination_ip]} {
snat 10.10.1.1
} else {
snat none i tried using 'forward' here too
}
}
The result was that all traffic matched the rule and everything started failing, because traffic destined for the internal network is subjected to specific firewall rules, which include source, destination and port as the rule parameters. After this new iRule, the server static NATs are not applied rather all get the 10.10.1.1 SNAT, which obviously is not in any of the firewall rules.
Technically the iRule could be based on matching the destination only but I included the source too as I thought that it will be less invasive/more efficient the more specific it is. Was I correct?
HELP !!!
14 Replies
- Maxim_Taskov_90
Nimbostratus
That can't be true citizen_elah. I already have similar rules/configurations. The only difference between this one and the other ones is that the others have a more specific VS, e.g. it is a wildcard destination but specific service and protocol. This one is a wildcard on everything ... destination, service, and protocol. I don't see how that would affect it but I would not place any bets either as I am not that familiar with the LTM internals. - JRahm
Admin
Then the documentation is wrong. I'd be really curious to see a scrubbed version of your configuration. - Maxim_Taskov_90
Nimbostratus
I can certainly offer any configuration pieces of interest to you. - Elias_O_16228
Nimbostratus
I have posted on this link below before I saw this thread. I know this is old thread, but it appears similar to my problem.
https://devcentral.f5.com/questions/two-snat-irule-with-same-origin-ip-addresses-54056comment50703
The SNAT1 VIP is currently 443 and SNAT2 VIP is only port 80.
I want some SSL traffic going through SNAT2 as well (443 and 80).
The SNAT1 traffic is only to two destinations, which could be URL or IP address.
The goal is to add https traffic to SNAT2 (https and http) via irule.
If https and http SNAT to SNAT2 virtual IP (default)
If https://www.abc123.com and/or https://www.utts123.com SNAT to SNAT1 virtual server.
I am running version 12.1.1. There used to be SNAT rule on version 10.x where you can define the ip addresses, but it appears missing on 12.x.
Recent Discussions
Related Content
* 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