Mohanad
Jul 30, 2019Cirrostratus
iRule for Conditional SNAT
i need to configre iRule for Conditional SNAT while (10.10.10.1 & 10.10.10.2) connecting to the VS SNAT will be 10.214.214.148 and the rest of clients the SNAT will be 10.214.214.147
current setup:
snat pool "DPG-147" = 10.214.214.147 & i have another snat pool "DPG-148" = 10.214.214.148
ltm virtual DPG-Staging-5006
description Cube
destination 192.168.30.147:pxc-spvr
ip-protocol tcp
mask 255.255.255.255
source 0.0.0.0/0
source-address-translation
pool DPG-147
type snat
Thanks
Mohanad
Hi,
Do you really need the SNAT pool, or you just need to definean IP address to SNAT on iRule?
e.g.
# Classic syntax when CLIENT_ACCEPTED { if { [IP::client_addr] eq "10.10.10.1" || [IP::client_addr] eq "10.10.10.2" } { snat 10.214.214.148 } else { snat 10.214.214.147 } } # Short way when CLIENT_ACCEPTED { if { "10.10.10.1, 10.10.10.2" contains [IP::client_addr] } { snat 10.214.214.148 } else { snat 10.214.214.147 } } # Expansive way, increase list when needed when CLIENT_ACCEPTED { switch [IP::client_addr] { 10.10.10.1 - 10.10.10.2 { snat 10.214.214.148 } default { snat 10.214.214.147 } } }
You must change line from "snat <IP ADDR>" to "snatpool <POOLNAME>" if you need to use a SNAT pool.
I hope it helps.