Skip to content

Instantly share code, notes, and snippets.

@fishnix
Created March 12, 2012 17:29
Show Gist options
  • Select an option

  • Save fishnix/2023509 to your computer and use it in GitHub Desktop.

Select an option

Save fishnix/2023509 to your computer and use it in GitHub Desktop.
exchange snat pool irule
when RULE_INIT {
# Use a local array to configure SNAT addresses.
# These addresses do not need to be defined in a SNAT pool or elsewhere;
# they simply need to be free IP addresses LTM can use to as a source
# for server-side connections, and are typically on the same subnet as
# the pool members. In this example, we use three addresses. Replace
# these with free IP addresses appropriate to your network topology.
# Follow the pattern of the existing addresses to add more than three.
set static::snat_ips(0) 10.0.0.1
set static::snat_ips(1) 10.0.0.2
set static::snat_ips(2) 10.0.0.3
}
when CLIENT_ACCEPTED {
# Calculate the crc32 checksum of the client IP.
# Use the modulo of the checksum and the number of SNAT IPs in the array
# to select a SNAT IP address.
snat $static::snat_ips([expr {[crc32 [IP::client_addr]] % [array size static::snat_ips]}])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment