I have a need to snat based on the incoming IP. It should be relatively straight forward but I can’t seem to make my mind wrap around this.. or what’s the best way to do it.
I have a private subnet that is divided into 3 ranges (prod/dev/test) and I need to SNAT based on which IP is connecting… For example if server in the DEV range connects then it should get SNAT A, test should get SNAT B and production should get SNAT C.
So I need the iRule to evaluate something similiar
10.9.9.0/26 gets SNAT A
10.9.9.65/26 gets SNAT B and
10.9.9.128/26 gets SNAT C
Also, do you know what the load would be of implementing such a rule on the CPU? I would guess that there would be less than 50 connections per minute.
Give this a look and post back if you’ve got any questions. Regarding the load, this is a very lean-and-mean operation. I wouldn’t be concerned here at all.
This looks good but I was really hoping for a solution that would examine all 3 choices at once. This would have to be 3 separate rules if I read this right. Would it be possible to examine the incoming IP and make one of 3 choices od SNAT IPs?
I think you’re limited to string comparisons with switch.
If you’re on 10.1, you could use a new feature for address type datagroups described in this post (Click here) and reference the datagroup with the class command (Click here).
Else, for older versions, I think you’re stuck doing three checks in an if/elseif/elseif block. Though, this could be done in a single iRule.
Gah - what was I thinking? Sorry about that, try this one instead. Obviously change your snat IPs to something sensible, and be sure and change the last “else” to something if you don’t want to simply forward the traffic on.
Gah - what was I thinking? Sorry about that, try this one instead. Obviously change your snat IPs to something sensible, and be sure and change the last “else” to something if you don’t want to simply forward the traffic on.
This works great in version 9, but is there a way to do this this if you 7 subnets total? The elseif statement argument is limited to three. That plus the initial statement only gets you 4 total subnets.