Forum Discussion
david_wang_2073
Apr 27, 2009Historic F5 Account
Is there a way in iRule to check the connection table for specific client IP address
I met a SMS load balancing case. Each SMS client was allowed to setup 4 concurrent connections with SMS gateway. Now we try to use LTM to load balance for two SMS gateways. One requirement is that for each client, the 4 concurrent connection should be distributed between these two gateways evenly, which means for each client, there is two connections with each SMS gateway.
This requirement is different with general Round Robin LB method, because it is round robin LB based on each client ip address.
I worked out below email to distribute the connections from the same IP address evenly among pool member:
rule srcip_roundrobin {
when RULE_INIT {
Clear the array of clients with open connections to the VIP
array set ::active_clients { }
Replace this array with a datagroup of type 'address' once done testing!
}
when CLIENT_ACCEPTED {
log local0. "\$::active_clients: [array get ::active_clients] (size: [array size ::active_clients])"
Check if the client is already in the active clients array
if { ([info exists ::active_clients([IP::client_addr])]) } {
incr ::active_clients([IP::client_addr])
log local0. "Incremented \$::active_clients([IP::client_addr]) to: $::active_clients([IP::client_addr])"
} else {
Client wasn't already in the array, so add them to the array with a count of 1.
set ::active_clients([IP::client_addr]) 0
log local0. "Initialised \$::active_clients([IP::client_addr]) to: 1"
}
set picked [lindex [active_members -list sms_gw_pool] [expr $::active_clients([IP::client_addr]) % [active_members sms_gw_pool]]]
set picked [lindex [active_members -list sms_gw_pool] [expr $::active_clients([IP::client_addr]) % 2]]
pool sms_gw_pool member [lindex $picked 0] [lindex $picked 1]
log local0. "[IP::client_addr] : [TCP::client_port]select pool member [lindex $picked 0]"
}
}
With this irule, for client 10.10.5.33, the connection can be distributed evenly when both servers 172.16.20.1 and 172.16.20.2 are ok.
10.10.5.33:42174 <-> 10.10.8.100:http <-> 172.16.20.1:9080 tcp
10.10.5.33:42177 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp
10.10.5.33:42178 <-> 10.10.8.100:http <-> 172.16.20.1: 9080 tcp
10.10.5.33:42179 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp
When one server is down, such as 172.16.20.1:http is down, the active server 172.16.20.2 can take over the connections should be handled by 172.16.20.1
10.10.5.33:34218 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp
10.10.5.33:34219 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp
10.10.5.33:34220 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp
10.10.5.33:34221 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp
But now I want, when 172.16.20.1 come back, some of connections in server 172.16.20.2 can be switched back to server 172.16.20.1 (by re-establish new connections).
Is there a way in iRule to check the connection table for specific client IP address, just like “ b conn client client_ip_address show” and “b conn delete”, so that I can delete come of connection, for example,
To delete two connections “10.10.5.33:34218 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp “ and “10.10.5.33:34219 <-> 10.10.8.100:http <-> 172.16.20.2: 9080 tcp”
1 Reply
- hoolio
Cirrostratus
There isn't a way to check the connection table from an iRule. And if you could you would still need an event to trigger the logic off of. If the TCP connection was established already, you would have to collect the payload to do this. You might be able to check/modify the connection table with an iControl script. You could post in the iControl forum to get more info.
Aaron
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
