Interview Prep/Linux/Networking, SSH and remote access

Your application opens thousands of outbound connections per second to an API and starts failing with "Cannot assign requested address". How do you tune the host?

AdvancedScenarioNetworking, SSH and remote access
Answer

Situation read → Ephemeral port exhaustion from many short-lived connections in TIME_WAIT.

What I'd do →

  1. Confirm: ss -tan state time-wait | wc -l and sysctl net.ipv4.ip_local_port_range.
  2. Fix in the app first: use connection pooling and keep-alive.
  3. Tune:
sudo sysctl -w net.ipv4.ip_local_port_range="10240 65535"
sudo sysctl -w net.ipv4.tcp_tw_reuse=1
  1. Spread across more destination IPs or source IPs if needed.

Why → Each connection needs a unique 4-tuple; with one destination IP:port you only have the ephemeral port range to vary.

Interview tip → Never mention tcp_tw_recycle; it was removed in Linux 4.12 because it broke NAT clients.

All Linux questions Roadmap: Linux

More on Networking, SSH and remote access