Forum Discussion
Ken_Wong_48678
Sep 30, 2005Historic F5 Account
limit client connection
Hi guys,
Is it possible using irule to limit number of connections from each client ip address?
If yes, pls. give me some samples how to do it. Thanks!
Regards,
Ken
Ken_Wong_48678
Oct 05, 2005Historic F5 Account
Hi Colin,
I have tested the following irule and it can sucessfully to check the number of connections. However, it cannot reject the connections more than 5.
I opened a few browsers to access BIG-IP vip, i see the log show "Client $client_ip has too many connections" after the connection greater than 5. But, when I open additional browser to access the vip, it still can access the server. Based on my understand, the rule should block the sixth connection from same ip address. Is it true? Thanks!
when RULE_INIT {
array set ::active_clients { }
log local0. "phase1"
}
when CLIENT_ACCEPTED {
set client_ip [IP::remote_addr]
if { [info exists ::active_clients($client_ip)] } {
if {$::active_clients($client_ip) > 5 } {
log "Client $client_ip has too many connections"
reject
return
} else {
log local0. "$::active_clients($client_ip)"
incr ::active_clients($client_ip)
}
} else {
set ::active_clients($client_ip) 1
}
}
when CLIENT_CLOSED {
if { [info exists ::active_clients($client_ip)] } {
incr ::active_clients($client_ip) -1
if { $::active_clients($client_ip) <= 0 } {
unset ::active_clients($client_ip)
}
}
}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