Forum Discussion
F5 force connection reset on pool member
Hi Satish,
you may take a look to the iRule below.
The iRule deploys a periodic
[after]
taskjob within each TCP connection, which compares every few seconds your selected pool member with the currently prefered pool member (influenced by its health, forced offline status and priority group settings) and reject the ongoing TCP connection if those are not matching anymore.
Cleaned iRule
when RULE_INIT {
set static::connection_check_interval 5000 ; msec
}
when LB_SELECTED {
after $static::connection_check_interval -periodic {
if { [lindex [LB::select] 3] ne [LB::server addr] } then {
reject
}
}
}
Debug enabled iRule
when RULE_INIT {
set static::connection_check_interval 5000 ; msec
}
when LB_SELECTED {
set connection_timestamp "[TMM::cmp_group][TMM::cmp_unit][clock clicks]"
log local0.debug "Node UP Check: $connection_timestamp : The pool member [LB::server addr] is currently active. Scheduling initial status check in $static::connection_health_interval ms."
after $static::connection_check_interval -periodic {
log local0.debug "Node UP Check: $connection_timestamp : Performing status check for pool member [LB::server addr]"
if { [lindex [LB::select] 3] ne [LB::server addr] } then {
log local0.debug "Node UP Check: $connection_timestamp : [LB::server addr] is not the active member anymore. Rejecting the TCP connection."
reject
} else {
log local0.debug "Node UP Check: $connection_timestamp : [LB::server addr] is still the active member. Scheduling next status check in $static::connection_health_interval ms."
}
}
}
Cheers, Kai
Hi, Kai.
Thank you for this iRule! May I know what exactly this line does and what significance is the number 3?
if { [lindex [LB::select] 3]
May I also ask how to tweak the iRule so that it will still work when there are multiple pool members assigned on each priority group? I have noticed that the iRule is only applicable if there is only one pool member assigned on each priority grp.
- Kai_WilkeFeb 21, 2020MVP
Hi Aries22,
the [lindex 3] command parses the output of the [LB::select] as a whitespace speperated list and then selects the fourth ([lindex] starts counting on zero) element.
The output of [LB::select] has the following format and the bold part is the string we are going to extract...
pool <poolname> member <ip_addr><port>
Cheers, Kai
Recent Discussions
Related Content
* 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