Interview Prep/Networking/Sockets, ports, TIME_WAIT and conntrack

`dmesg` shows `TCP: request_sock_TCP: Possible SYN flooding on port 443. Sending cookies.`

IntermediateTroubleshootingSockets, ports, TIME_WAIT and conntrack
Answer

Likely causes → The SYN (half-open) queue for that listener overflowed and the kernel fell back to SYN cookies. Either it's a real SYN flood, or a legitimate burst (deploy, reconnect storm) with a small backlog. SYN cookies keep you up but drop TCP options such as window scaling in some cases.

Diagnose →

nstat -az | grep -E 'TcpExtSyncookiesSent|TcpExtListenOverflows|TcpExtListenDrops'
ss -ltn 'sport = :443'
sysctl net.ipv4.tcp_max_syn_backlog net.core.somaxconn net.ipv4.tcp_syncookies
sudo tcpdump -ni eth0 'tcp[tcpflags] == tcp-syn and dst port 443' -c 200 | awk '{print $3}' | sort | uniq -c | sort -rn | head

Many distinct spoofed sources that never complete the handshake means a flood.

Fix → For bursts: raise tcp_max_syn_backlog, somaxconn and the app's listen() backlog (nginx listen 443 ssl backlog=4096;). For floods: put DDoS protection (AWS Shield, Cloudflare) or an L4 LB in front; keep tcp_syncookies=1.

Prevent → Alert on SyncookiesSent and ListenDrops rates.

All Networking questions Roadmap: Networking for DevOps

More on Sockets, ports, TIME_WAIT and conntrack