Forum Discussion
clowe_16759
Nimbostratus
Nov 07, 2007iRule to SNAT Server
I am very inexperienced in writing iRules.
Background: there are virtual severs that serve our web servers and virtual servers that serve our database server. The Web and DB servers are on dif...
hoolio
Cirrostratus
Nov 09, 2007If you have a spare IP address per client you will be SNAT'ing, you could create a datagroup (type: string) with the client IP and SNAT IP. When a client request is received, you could search the class using findclass and look up the corresponding IP you want to SNAT with. You can then use the snat command to apply it.
citizen_elah added a good example using a similar scenario a while back (Click here).
You could adapt that like this using a class with the client IP first, followed by the IP you want to translate it to:
class snat_map {
"1.1.1.1 1.1.2.1"
"1.1.1.2 1.1.2.2"
"1.1.1.3 1.1.2.3"
"........ ......"
}And then a rule which performs the SNATing:
when CLIENT_ACCEPTED {
set snat_ip [findclass [IP::client_addr] $::snat_map " "]
if { $snat_ip ne "" } {
snat $snat_ip
} else {
client IP wasn't found in the class, so use a default SNAT address
snat 2.2.2.2
}
}Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects