tcp-keepalive

Configure Linux system-wide TCP keepalive parameters for long-lived connections.

Updated Mar 6, 2026
One-click install
npx skills add https://github.com/renne/skills --skill tcp-keepalive
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: tcp-keepalive
Source: https://github.com/renne/skills/tree/main/linux/tcp-keepalive
Command: npx skills add https://github.com/renne/skills --skill tcp-keepalive

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the issue of long-lived TCP connections dropping unexpectedly due to intermediate network devices (like routers or firewalls) timing out idle connections, or to detect dead connections more rapidly.

Core Features & Use Cases

  • Tune TCP Keepalive Parameters: Adjust tcp_keepalive_time, tcp_keepalive_intvl, and tcp_keepalive_probes system-wide.
  • Maintain NAT State: Ensures that intermediate devices keep NAT entries active for idle connections.
  • Detect Dead Connections: Speeds up the detection of unresponsive remote hosts.
  • Use Case: Resolve dropped VPN tunnels, gRPC streams, WebSocket connections, or SSH sessions that disconnect after periods of inactivity.

Quick Start

Apply the recommended TCP keepalive settings for systems behind a home router.

Frequently Asked Questions about tcp-keepalive

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why do my SSH sessions and WebSocket connections drop after periods of inactivity?

Idle TCP connections drop when intermediate network devices like routers time out NAT entries. Configuring TCP keepalive sends periodic probes to maintain NAT state and detect dead peers faster.

How do I configure Linux TCP keepalive parameters to prevent VPN disconnections?

Adjust system-wide parameters `net.ipv4.tcp_keepalive_time`, `tcp_keepalive_intvl`, and `tcp_keepalive_probes` to control probe intervals. This maintains long-lived connections by ensuring intermediate devices keep NAT entries active.

What is the best way to detect dead TCP peers faster on a Linux system?

Detecting dead TCP peers faster requires reducing the `tcp_keepalive_time` and `tcp_keepalive_probes` values. This speeds up the detection of unresponsive remote hosts by sending probes sooner during idle periods.

Does tuning TCP keepalive settings work for gRPC streams behind a home router?

Yes, tuning TCP keepalive works for gRPC streams behind home routers. Adjusting system parameters ensures intermediate devices keep NAT entries active, preventing unexpected drops during idle connection states.

Can I apply TCP keepalive settings system-wide for all network connections?

Yes, you can apply TCP keepalive settings system-wide on Linux. Modifying `net.ipv4.tcp_keepalive_time`, `tcp_keepalive_intvl`, and `tcp_keepalive_probes` affects all TCP connections, including VPNs, gRPC, WebSockets, and SSH.