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 →
- Confirm:
ss -tan state time-wait | wc -landsysctl net.ipv4.ip_local_port_range. - Fix in the app first: use connection pooling and keep-alive.
- Tune:
sudo sysctl -w net.ipv4.ip_local_port_range="10240 65535"
sudo sysctl -w net.ipv4.tcp_tw_reuse=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.
More on Networking, SSH and remote access
A key belonging to a departed engineer may be in `authorized_keys` on 300 servers. How do you rotate SSH keys across the fleet?IntermediateYou need to reach a database on a private subnet from your laptop through a bastion. How?BeginnerYour security team wants SSH hardened on all servers. What changes do you make?BeginnerA new server needs a static IP, gateway and DNS on RHEL 9. How do you configure it persistently?BeginnerYou're changing the network config of a remote server over SSH and could lose access. How do you protect yourself?IntermediateA web server should accept HTTP/HTTPS from anywhere but SSH only from the office. Configure the firewall.Beginner