Forum Discussion
Kenny_Lussier_5
Nimbostratus
Jul 27, 2010Limiting connections based on data group
Hi All,
Please excuse my lack of knowledge. I am very new to F5, and I am trying to work through a PoC with LTM v10.1. I have searched through and found several examples of how to limit traffic based on IP address. I am currently using this iRule with some success:
when CLIENT_ACCEPTED {
set client_ip [IP::remote_addr]
if { [table keys -subtable $client_ip -count] > 10 } {
log "Client $client_ip has too many connections"
reject
return
} else {
log local0. "$::active_clients($client_ip)"
table add -subtable $client_ip [TCP::remote_port] 1
}
}
when CLIENT_CLOSED {
table delete -subtable $client_ip [TCP::remote_port]
}
However, what I really need to do is limit the number of concurrent connections based on data group. What I would like to do is create 10+ data groups, each containing anywhere from 2 to 50 IP addresses, and limit the number of connections of all addresses in the group. Can someone help me with 1) how to search all existing data groups for client_ip and b) add up all of the existing connections of all of the other addresses in the datagroup.
Is there a better way to accomplish this?
Thanks,
Kenny
- Hamish
Cirrocumulus
You want the class command... There's two ways to do this...if { [class lookup [IP::CLIENT] $className] } { do whatever... }
address1:connlimit address2:connlimit
- Hamish
Cirrocumulus
Oh. The class function docs are at - Kenny_Lussier_5
Nimbostratus
Hamish, - Kenny_Lussier_5
Nimbostratus
I think I am missing something. What I need to do is search all classes, but it seems like wild cards can't be used, and there is no way to list classes and match against a `for each in ` type of array. `class match` and `class lookup` require the name of a specif class to search. What I need to do is search through all classes to find which class an ip address is in. - hoolio
Cirrostratus
Hi Kenny,class conn_limit_class { { host 1.1.1.1 { "cust1" } network 2.2.2.0/24 { "cust1 } network 3.3.3.0/24 { "cust2" } network 4.4.5.0/24 { "cust2" } } }
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