TCP Ephemeral port#
Linux 默认 TCP Ephemeral port 范围#
Linux 2.4 kernel sysctl net.ipv4.ip_local_port_range 32768 60999
Load balancer 应对 Ephemeral port 用尽的方法#
Enabling Keepalive Connections
同一网口多 ip: Dynamically Binding Connections to a Defined List of Local IP Addresses
减少主动关闭后的 TIME_WATIT :
sysctl net.ipv4.tcp_tw_recycle
sysctl net.ipv4.tcp_tw_reuse
Ref.#
- How to stop running out of ephemeral ports and start to love long-lived connections
- Outgoing connections on Linux part 1 - TCP
- Long-lived connections
- Basics - how port allocation works
- Vanilla TCP is a happy case
- Manually selecting source IP address
- IP_BIND_ADDRESS_NO_PORT
- Explicitly selecting a source port
- Userspace connectx implementation
- Outgoing connections on Linux - part 2 - UDP
- Vanilla UDP is limited
- SO_REUSEADDR is hard
- Detecting socket conflicts with eBPF
- Socket traversal - SOCK_DIAG ss way
- SO_REUSEADDR as a lock
- Faking source IP and port discovery
- Putting it all together
- Summary
- Ephemeral port exhaustion and how to avoid it
- A story of a production incident