Forum Discussion

Patrick_Chang_7's avatar
Patrick_Chang_7
Historic F5 Account
Feb 14, 2008

selective SNAT on Forwarding VS

I want to selectively SNAT on a forwarding VS based upon the IP address of the destination. My iRule would look like the following:


when CLIENT_ACCEPTED {
   if [matchclass $$::internal_networks not equal IP destination] {
      snatpool pool_snat
   }
}

The questions I have are the following:

What is the syntax for not equal?

What structure should I use to get the IP of the destination in this case? Is it IP::local_addr?

3 Replies

  • Hi,

    You can use not or ! to negate the comparison. I'm pretty sure you need to wrap the test in parens. And yes, IP::local_addr in the clientside context will be the destination IP.

    
    when CLIENT_ACCEPTED {
       if {not ([matchclass $::internal_networks equals [IP::local_addr])}{
          snatpool pool_snat
       }
    }

    Aaron
  • I need a little bit of explanation what the above irule is doing. What I have understood is the following,

     

    1. There is an address object "internal_networks" created under irule with the internal subnet defined.

       

    2. The irule compares this subnet to the request coming to this VS and if it does not matches then it sends the connection from outbound_snat snat address pool. but if it matches what will happen then??