Forum Discussion
Yaniv_99962
Mar 22, 2011Nimbostratus
SNAT persistency
Hi F5 experts. i want to achieve the following: 1) I want the F5 to choose an IP in round-robin manner from a SNAT pool and to persist using the same IP from the SNAT pool in case an HTT...
Steve_Brown_882
Mar 22, 2011Historic F5 Account
Alright, I decided to give this a try. I am sure this irule probably needs some work yet, and it may not be the most efficient, but I think it comes close do doing what you are looking for.
when HTTP_REQUEST {
Set var with username header
set uname [HTTP::header "username"]
set clname "snatpool_class"
set searchID [class startsearch "snatpool_example" ]
Check to see if the uname already has a snat
if { [table lookup -subtable "snat_table" $uname] ne "" } {
set snatpool_member [table lookup -subtable "snattable" $uname]
} else {
while { [class anymore $clname $searchID] } {
look up an ip from the class
set snatpool_member [class nextelement -value $clname $searchID]
check to see if the IP has been assigned yet
if { [table lookup -subtable "snat_table" -notouch $snatpool_meember] eq "" } {
add snat assignement to tables
table set -subtable "snat_table" $snatpool_member $uname 300
table set -subtable "snat_table" $uname $snatpool_member 300
local log entry this should be changed to a highspeed log off box.
log local0.info "Snat assignment of $snatpool_member made to $uname"
}
}
}
snatpool mysnatpool member $snatpool_member
HTTP::header remove "username"
}
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