Forum Discussion
AlexJ
Nimbostratus
Feb 08, 2017Universal persistence using header values for multiple client IPs.
Hello all,
I require universal persistence based upon a XFF header value, but for any source IP.
The scenario is that an initial client connection hits the F5 and is load balanced to node A (the...
Kai_Wilke
MVP
Feb 08, 2017Hi ajohnson,
take a look to the iRule below and tell me what you think?
The iRule uses the
CLIENT_ACCEPTED event to differentiate between client and backend connections. If a backend connection is identified, then it will be checked during the LB_SELECTED event if [LB::server addr] (currently selected pool member) equals the [IP::client_addr] (backend IP address). If the IPs are matching no action is taken. But if the IPs are different the [IP::client_addr] will be used as new [LB::server addr] by executing the [pool] command a second time.
when CLIENT_ACCEPTED {
if { ( [IP::client_addr] starts_with "1.2.3.4" )
or ( [IP::client_addr] starts_with "1.2.3.5" ) } then {
set backend_connection 1
} else {
set backend_connection 0
}
}
when LB_SELECTED {
if { $backend_connection } then {
if { [LB::server addr] equals [IP::client_addr] } then {
The selected node is already correct...
} else {
pool [LB::server pool] member [IP::client_addr] [LB::server port]
}
} else {
Use LB decissions / persistence records for client connections.
}
}
Note: The iRule can be combined with any persistence profile / LB algorythm you wish. The backend connection will be overwritten on demand without affecting client connections.
Warning: Didn't tested nor saved the iRule at all. So better apply this iRule on a test-system... 😉
Cheers, Kai
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
