Forum Discussion
hooleylist
Nov 23, 2009Cirrostratus
Actually, it looks like getfield is a lot more efficient for this compared with scan. So you could replace the scan command with getfield:
when CLIENT_ACCEPTED {
Use a local array to configure the 5 SNAT addresses
set snat_ips(0) 1.1.1.1
set snat_ips(1) 2.2.2.2
set snat_ips(2) 3.3.3.3
set snat_ips(3) 4.4.4.4
set snat_ips(4) 5.5.5.5
Use getfield to parse the third octet from the client IP address
Get the modulus of the third octet against the number of the SNAT IPs in the array
set snat_number [expr {[getfield [IP::client_addr] "." 3] % [array size snat_ips]}]
log local0. "Client IP: [IP::client_addr], SNAT number $snat_number, SNAT IP: $snat_ips($snat_number)"
Apply the SNAT
snat $snat_ips($snat_number)
}
Aaron