SYNCACHE(4)
π SYNCACHE(4) π
okay bestie, pull up a chair because we're talking about syncache and syncookies β the sysctl(8) MIBs that let you control TCP SYN caching in the system. this is the Kernel Interfaces Manual page, and honestly? it's giving "the internet's bouncer at the door." let's go π«Ά
β¨ NAME β¨
syncache, syncookies β the sysctl(8) MIBs for controlling TCP SYN caching. periodt. π
π SYNOPSIS π
sysctl net.inet.tcp.syncookies
sysctl net.inet.tcp.syncookies_only
sysctl net.inet.tcp.syncache.hashsize
sysctl net.inet.tcp.syncache.bucketlimit
sysctl net.inet.tcp.syncache.cachelimit
sysctl net.inet.tcp.syncache.rexmtlimit
sysctl net.inet.tcp.syncache.count
πΈ DESCRIPTION πΈ
so the syncache sysctl(8) MIB is literally the control panel for TCP SYN caching in the system, and its whole entire job is handling SYN flood Denial of Service attacks. main character energy, honestly. π
here's the vibe: when a TCP SYN segment shows up on a port that corresponds to a listen socket, an entry gets made in the syncache, and a SYN,ACK segment gets sent right back to the peer. that syncache entry is holding the TCP options from the initial SYN, plus enough state to do a SYN,ACK retransmission, and it takes up less space than a TCP control block endpoint. tiny but mighty β¨. then, if an incoming segment contains an ACK for the SYN,ACK and it matches a syncache entry, the system goes ahead and creates a TCP control block using the options stored in that syncache entry β and the entry is then released. bye bestie π¦
the syncache protects the system from SYN flood DoS attacks by minimizing the amount of state kept on the server, and by limiting the overall size of the syncache. no cap.
syncookies is the little trick that virtually expands the size of the syncache by keeping state regarding the initial SYN in the network. enabling syncookies sends a cryptographic value in the SYN,ACK reply to the client machine, and that value comes right back in the client's ACK. if the corresponding entry isn't found in the syncache but the value passes specific security checks, the connection gets accepted. this is only used if the syncache is unable to handle the volume of incoming connections, and a prior entry has been evicted from the cache.
β οΈ okay so syncookies has a certain number of disadvantages that a paranoid administrator may wish to take note of. since the TCP options from the initial SYN are not saved, they are not applied to the connection β which precludes use of features like window scale, timestamps, or exact MSS sizing. and because the returning ACK establishes the connection, it may be possible for an attacker to ACK flood a machine in an attempt to create a connection. while steps have been taken to mitigate this risk, this may provide a way to bypass firewalls which filter incoming segments with the SYN bit set. π
to disable the syncache and run only with syncookies, set net.inet.tcp.syncookies_only to 1.
π§ the syncache variables π§
the syncache implements a number of variables in the net.inet.tcp.syncache branch of the sysctl(3) MIB. several of these may be tuned by setting the corresponding variable in the loader(8).
hashsizeβ size of the syncache hash table, must be a power of 2. read-only, tunable vialoader(8).bucketlimitβ limit on the number of entries permitted in each bucket of the hash table. this should be left at a low value to minimize search time. read-only, tunable vialoader(8).cachelimitβ limit on the total number of entries in the syncache. defaults to(hashsize Γ bucketlimit), and may be set lower to minimize memory consumption. read-only, tunable vialoader(8).rexmtlimitβ maximum number of times a SYN,ACK is retransmitted before being discarded. the default of3retransmits corresponds to a45second timeout, and this value may be increased depending on the RTT to client machines. tunable viasysctl(3).countβ number of entries present in the syncache (read-only).
π the netstat(1) stats π
statistics on the performance of the syncache may be obtained via netstat(1), which provides the following counts:
syncache entries addedβ entries successfully inserted in the syncache.retransmittedβ SYN,ACK retransmissions due to a timeout expiring.dupsynβ incoming SYN segment matching an existing entry.droppedβ SYNs dropped because SYN,ACK could not be sent.completedβ successfully completed connections.bucket overflowβ entries dropped for exceeding per-bucket size.cache overflowβ entries dropped for exceeding overall cache size.resetβ RST segment received.staleβ entries dropped due to maximum retransmissions or listen socket disappearance.abortedβ new socket allocation failures.badackβ entries dropped due to bad ACK reply.unreachβ entries dropped due to ICMP unreachable messages.zone failuresβ failures to allocate new syncache entry.cookies receivedβ connections created from segment containing ACK.
π SEE ALSO π
netstat(1), tcp(4), loader(8), sysctl(8)
π HISTORY π
the existing syncache implementation first appeared in FreeBSD 4.5. the original concept of a syncache originally appeared in BSD/OS, and was later modified by NetBSD, then further extended here. glow-up after glow-up, fr fr. β
π AUTHORS π
the syncache code and manual page were written by Jonathan Lemon <jlemon@FreeBSD.org>.
and that's the whole page bestie, you ate that π β this one's from the Debian distribution, dated January 22, 2008, and it's the SYNCACHE(4) page. mwah π go forth and tune your hash tables responsibly. ππ
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms