Forum Discussion
madi_56757
Nimbostratus
Jan 17, 2005inteligent SNAT with iRule
Hi,
I have in the version 4.5.10 a iRule for an inteligent SNAT,
VIRTUAL ANY UNIT 1
|
|
|
+---+--> WILDCARD SERVICE ENABLED
|
|
|
+---+--> RULE SNAT
+---+--> POOL forward_no_snat
+---+--> POOL forward_snat
the rule is configured
----------------------------------------------------------------------
if (server_addr == 10.0.0.0 netmask 255.0.0.0) {
use pool forward_no_snat
}
else {
if (server_addr == xxx.xxx.xxx.0 netmask 255.255.255.0) {
use pool forward_no_snat
}
else {
use pool forward_snat
}
}
----------------------------------------------------------------------
and it works fine !
currently we have a new B6400 (Version 9.0.3) in test phase and I tried to configure the same with the new syntax
but it doesn't work
I've configured an 0.0.0.0:0 forwarding server for all Vlans and a iRule "mysnat" attached.
This iRule has the folowing statement (it is not exactly the same like the IRule descipted above
but this example makes it easier to point up my problem)
----------------------------------------------------------------------
when SERVER_CONNECTED {
if {[IP::remote_addr] egual "2.2.2.0 netmask 255.255.255.0"}
{forward }
else {use snatpool test_snat}
}
---------------------------------------------------------------------
I have tried with another statment
---------------------------------------------------------------------
when SERVER_CONNECTED {
if { [IP::addr [IP::remote_addr] egual 2.2.2.0 netmask 255.255.255.0] }
{forward }
else {use snatpool test_snat}
}
---------------------------------------------------------------------
following architecture
-------------- 1.1.1.0/24
|
-------------
| Router |
-------------
|2.2.2.1
|
-----------------------------------------
Network 2.2.2.0/24 VLAN 50
|
| 2.2.2.27 VIP.26
---------------
| BIGIP |
---------------
| 30.30.30.2 VIP.1
|
-----------------------------------------
Privat Network 30.30.30.0/24 VLAN 60
---------------------------------------------------------------------
connecting from the server 30.30.30.10 to the Network 2.2.2.0 => the BIgIP forward this paket with the Origin IP address
connecting from the server 30.30.30.10 to other networks => should be forwarded with the SNAT address
fact is the rule is matching (looking in the iRule statistics) ...but any connection is forwarded without the SNAT
I tried the same iRule with a drop statment instead "else {use snatpool test_snat}"
----------------------------------------------------------------------
when SERVER_CONNECTED {
if {[IP::remote_addr] eg "2.2.2.0 netmask 255.255.255.0"}
{forward }
else {drop}
}
-----------------------------------------------------------------------
this works !
...it seems that's only a problem with the SNAT !
Could anybody give me a hand ?
Thanks in advance
- unRuleY_95363Historic F5 AccountI believe the problem you are experiencing is due to the event you have chosen for your rule. The SERVER_CONNECTED event is evaluated after the serverside of the proxy has been connected. At this point, it is too late to change any aspects of the serverside that would effect the address or port. This is why you don't see any change in the SNAT behavior. Since, the rule you have written doesn't appear to use anything but addresses to make the decisions, you should probably use the CLIENT_ACCEPTED event.
- unRuleY_95363Historic F5 AccountTwo things:
when CLIENT_ACCEPTED { if {not [IP::addr [IP::remote_addr] equals "2.2.2.0 netmask 255.255.255.0"]} { use snatpool test_snat } forward }
- madi_56757
Nimbostratus
Ok your suspicion was good - unRuleY_95363Historic F5 AccountOk, I will run some tests this weekend so I can better understand all the issues around this. You may want to use a different approach, like putting the snat on the virtual (or maybe you already have it that way which could be why it's always snat'ing) and then use the rule to disable the snat via the "snat none" command:
when CLIENT_ACCEPTED { if {[IP::addr [IP::local_addr] equals "2.2.2.0 mask 255.255.255.0"]} { snat none } }
- unRuleY_95363Historic F5 AccountOk, I have run more tests to confirm that this does work as designed.
- madi_56757
Nimbostratus
hello - Tao_Liu_90341Historic F5 AccountCould you try:
- madi_56757
Nimbostratus
Hello tliu & unRuley
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