4.11. Implementing TCP Keepalive Proxy Support

4.11.1. What it is

This feature is implemented in 9.0 as a new iRule command to enable variable TCP keepalive times for dynamic traffic flows.


4.11.2. How to build it

To enable TCP keepalive, insert an iRule on the Interception Rule using the new TCP::keepalive command. The following example enables a specific keepalive time value for traffic that matches a source IP address data group:

when CLIENT_ACCEPTED {
    set ka 0
    if [class match [IP::client_addr] equals "keepalive_clients_dg"] } {
        TCP::keepalive 5
        set ka 1
    }
}
when SERVER_CONNECTED {
    if { ${ka} } {
        TCP::keepalive 5
    }
}