Forum Discussion

Eric_Watters_25's avatar
Eric_Watters_25
Icon for Nimbostratus rankNimbostratus
Oct 30, 2014

SNAT Using iRule and Variables

I want to SNAT traffic based on following criteria:

 

1) If source network is 10.10.1.x/24 and 2) If destination network is 10.13.71.x THEN 3) SNAT source IP to 192.168.20.x and forward to pool.

 

What I want to be able to do is have the iRule pull the last octect out of the 10.10.1.x address and plug it into the last octect of the 192.168.20.x subnet. How would I go about doing this?

 

Thanks!

 

Eric

 

2 Replies

  • You could use something like that :

        set myip 1.2.3.4
        scan $myip %d.%d.%d.%d ip1 ip2 ip3 ip4
        set newip [IP::addr 192.168.20.$ip4 mask 255.255.255.255]
        log local0. "$newip"
    
  • Thanks for the response Arnaud.........follow up.......how does your solution above address the fact that I ONLY want this rule to SNAT if the source of the traffic is 10.10.1.x /24? I plan to apply this to various VIPs on the the LTMs.

     

    Thanks a lot!

     

    Eric