Two physics circuits
perimeter and core.

UFW rate-limit lines with proprietary signature comments plus seven sysctl parameters armed in a single transaction. On-disk receipts keep the armor alive across reboots.

Limits with signatures

Every rule carries a canonical comment ( "Amber Guard Lab. … " ), so purging and reconciliation find their own by exact match and never touch foreign rules.

Three circuits of truth

The process circuit walks /proc , the socket circuit audits ss -lntp , the correlation circuit links sockets to owners. An unknown listener is marked suspicious before any decision.

Raise the limit, clear tombstones

Outdated rules without receipts are removed as tombstones. UFW status cache — 2 seconds, so races do not enter the transaction.

Armor survives reboot

Persistent receipts live in states/ . Receipt without a rule after reboot → restore. Rule without receipt → warning: the perimeter was touched manually.

The trap is always available

The honeypot port remains unconditional ALLOW; the stale limit on it is cleared without a tombstone. Bots must not be blocked accidentally.

ARMOR_ON / ARMOR_OFF in one breath

sysctl → ports → services → reload Netfilter, with live logging. A failed step leaves the system in its previous state, never in half-armor.

Seven defense lines

P1 · net.ipv4.tcp_syncookies — cryptographic shield

Reference Combat (AGL) Range
distribution-dependent 1 0 | 1 · fail-safe → 1

Anatomy of the threat: the mechanics of SYN-Flood strangulation

In normal mode, the client sends SYN, the server allocates a data structure in RAM for the socket, reserves a buffer, and replies with SYN-ACK; the client sends ACK — the session is established. During a SYN-Flood attack, a botnet sends millions of SYN packets per second, spoofing source IP addresses. The Linux kernel, following the standard protocol, honestly allocates system memory for every hostile probe and freezes waiting for the final ACK, which will never arrive. The half-open connection queue instantly becomes clogged with zombie sessions: RAM is exhausted, the CPU operates in overload mode servicing dead descriptors, and legitimate users encounter denial of service.

Physics of the AGL defensive circuit (ON mode)

When the administrator switches the network armor to ON mode, the Laboratory arms the net.ipv4.tcp_syncookies parameter with the value 1. A fundamental restructuring of the network stack logic occurs: the server completely stops allocating RAM for incoming half-open TCP connections. Instead of reserving RAM buffers, the kernel generates a cryptographic tag — a SYN Cookie: the attacker's IP address and port, local IP and port, the system's secret compile-time salt, and the current timestamp are run through a fast hash algorithm; the result is packed into the 32-bit initial Sequence Number of the outgoing SYN-ACK packet — and the server fires the packet back into the Internet, instantly forgetting the connection. The server's memory remains clean. If a bot with a spoofed IP attacked the socket, the SYN-ACK flies into the void, without spending a byte of RAM. If a real user connects, their OS must return an ACK, incrementing the received Sequence Number by one; the kernel subtracts one, verifies the hash against the secret salt — and the socket is born in memory in nanoseconds, bypassing the queue.

Architectural fail-safe guard of the Laboratory

Disabling this parameter during an assault means instant clinical death of the operating system, so the Laboratory implements an uncompromising security validator at the point of application: in config.go, the trigger is hard-clamped to binary boundaries 0 or 1. Even if an inexperienced administrator makes a typo or enters a garbage, invalid, or negative value in config.json, the hard fail-safe circuit ignores the error and forcibly sets 1 — protection is active.

P2 · net.ipv4.tcp_fin_timeout — disposal of hung sockets

Reference Combat (AGL) Range
60 sec 15 sec 10–60 sec · fail-safe → 15

Anatomy of the threat: resource starvation and memory exhaustion attacks

When a legitimate communication session ends, the socket cannot vanish from memory instantly: the TCP protocol must guarantee that packets delayed in transit nodes reach their destination. After closing the connection from its side, the socket enters the FIN-WAIT-2 state. In standard Linux distributions, the lifetime of a closed socket in this state is 60 seconds. In peacetime this is unnoticeable. However, during FIN-Flood or mass connection resets by a botnet, millions of zombie nodes simultaneously initiate a session and immediately tear it down. Each dead session stuck in FIN-WAIT-2 leaves a socket structure in the kernel, holding receive and transmit buffers: about 4 KB of pure kernel memory. Under an assault of 10,000 requests per second and a factory timeout of 60 seconds, 600,000 sockets are simultaneously held in memory — approximately 2.4 GB of RAM. On a typical VPS with 1–2 GB, this guarantees activation of the OOM Killer: the kernel, in panic, terminates the server's own processes; the web server crashes, databases disconnect, and full isolation occurs.

Physics of the AGL defensive circuit (ON mode)

When the complex switches to active perimeter protection mode, the Laboratory, through the executive protocol sysctl_tune_protocol.go, forcibly compresses the net.ipv4.tcp_fin_timeout parameter from 60 seconds to an extreme 15 seconds. Compressing the time window by four times radically changes the balance of forces at the level of RAM physics: under the same assault of 10,000 requests per second, the kernel under the Laboratory's control disposes of dead structures four times faster; the maximum simultaneous number of hung sockets is limited to 150,000, yielding approximately 585 MB of RAM instead of 2.4 GB. RAM pressure is reduced by 1.8 GB: the server continues to function stably, not even noticing that it is currently under assault by a distributed botnet.

Architectural fail-safe guard and runtime control

Extreme lowering of timeouts is a surgical intervention into the network stack, so two-factor verification of security boundaries is implemented. Protection against operator typos: a hard range is embedded in the configuration circuit — the value cannot be lowered below 10 seconds (otherwise the kernel will begin mass-breaking slow legitimate TLS handshakes) and cannot exceed 60 seconds; if out of bounds, the complex will reset the invalid value and apply the safe reference value of 15 seconds. Two-factor runtime CHECK control: every second, the TUI panel and backend do not just check a box in the config — the SetSysctlProtocol("CHECK") function performs a real poll of the OS kernel. If an external program or an attacker manually changes tcp_fin_timeout bypassing the Laboratory, the complex instantly records an EventConfigLoadFailed incident with code CORE_MISCONFIGURATION, invalidates the runtime marker, and raises an alarm to the administrator about perimeter desynchronization.

P3 · net.ipv4.tcp_syn_retries — barrier against outbound congestion

Reference Combat (AGL) Range
6 2 1–5 · zero blocked · fail-safe → 2

Anatomy of the threat: mechanics of avalanche-like queue accumulation

Most administrators mistakenly believe that a DDoS attack destroys a server only with incoming traffic. This is a dangerous misconception: any modern server continuously initiates outgoing requests — APIs to payment gateways, update checks, DNS queries, accesses to external databases. When a host is under assault from an incoming botnet and its channels are overloaded, an internal application tries to send a legitimate SYN outward. According to the TCP protocol, if the remote server does not respond, the kernel must retry: by default net.ipv4.tcp_syn_retries is armed to 6 attempts. Each is sent through exponentially growing intervals (the pause doubles: 1, 2, 4, 8, 16, 32 seconds) — a single hung outgoing socket is held by the kernel in memory for more than 60 seconds, continuously loading the CPU with timer recalculations. If, under load, hundreds of local processes simultaneously try to reach external resources through a clogged channel, avalanche-like congestion occurs: each attempt reserves a socket structure in kernel RAM; compute threads waste cycles servicing geometrically growing timers for thousands of hung sockets; processes queue up for the network stack — an internal deadlock and an avalanche-like spike in Load Average; the CPU is loaded to 100% servicing its own congestion.

Physics of the AGL defensive circuit (ON mode)

When perimeter armor is activated, the Defender, through the central dispatcher sysctl_tune_protocol.go, hard-blocks the internal congestion by reducing the limit of outgoing retry attempts from the factory 6 to an extreme 2. Limiting to two attempts completely eliminates the longest and most resource-intensive tails of exponential waiting (16 and 32 second timeouts). The lifetime of a socket trying to break outward through the assault is reduced from a minute to a safe 3 seconds (1 sec + 2 sec): if the remote node does not respond within 3 seconds, the kernel immediately tears the session down. Server processes do not hang waiting but receive a fast refusal — the Go scheduler and CPU instantly dispose of dead descriptors, freeing cycles for filtering incoming botnet traffic. Load Average stays within the green zone.

Architectural fail-safe guard of the Laboratory

Lowering outgoing attempts is a hard compromise between CPU cleanup speed and stability on unstable external channels, so the Laboratory implements a strict security boundary validator. Protection against total disconnection: the validator in config.go blocks attempts to lower the parameter to 0 — a value below 1 would completely deprive the server of the ability to perform outgoing transactions. The safety range is clamped from 1 to 5. For any attempt to pass an invalid or garbage value, the fail-safe circuit resets the error and applies the Laboratory's proven combat standard — 2 attempts, preserving the balance between external API availability and CPU protection against overload.

P4 · net.ipv4.tcp_synack_retries — suppressing the reverse flood

Reference Combat (AGL) Range
5 2 1–5 · fail-safe → 2

Anatomy of the threat: burning CPU cycles on dead responses

When a standard network interface is hit by a SYN-flood assault, the operating system kernel, according to basic RFC standards, must send a response SYN-ACK to every incoming SYN packet. If an attacking bot uses a spoofed IP address or simply ignores the server's response, the kernel cannot immediately close the session: it assumes that the response packet got lost in backbone channels. By default, the parameter is armed to 5 attempts — the kernel obediently resends SYN-ACK to the bot five more times. Intervals double exponentially: 1, 2, 4, 8, 16 seconds — the kernel services one phantom session for more than 30 seconds. If a botnet generates a dense flow of 50,000 SYN packets per second, the CPU falls into a fictitious loop of irrational computations: for each retry, the kernel starts a timer, recalculates the TCP packet checksum, and transmits it to the network card; geometric progression multiplies outgoing junk to 250,000 parasitic packets per second. Compute cores go into 100% congestion, performing idle cycles of generating answers into the void; the operating system stops responding to administrator commands, the task scheduler becomes paralyzed — total denial of service.

Physics of the AGL defensive circuit (ON mode)

When the complex enters combat mode, the Laboratory, through the low-level layer sysctl_tune_protocol.go, strikes preemptively against the parasitic progression by hard-cutting the retry response limit from 5 to 2 attempts. Cutting off the exponential tail eliminates the longest waiting intervals (8, 16, and 32 seconds); the phantom socket is held by the kernel not for half a minute but only 3 seconds (1 sec + 2 sec), after which it is forcibly invalidated. The counter of outgoing parasitic traffic drops several times: instead of 250,000 packets, the CPU processes at most 100,000; the load on checksum computation and timer servicing collapses avalanche-like, freeing up to 60% of CPU compute power for useful work and cryptographic shields (SYN Cookies).

Architectural fail-safe guard of the Laboratory

Manipulations with SYN-ACK responses directly affect server availability for legitimate clients with unstable mobile Internet, so strict security boundary validation is implemented. The fail-safe range in config.go: the parameter cannot be lowered below 1 (otherwise the server would not be able to retry responding to a legitimate client if a packet is accidentally lost) and cannot exceed 5. If anyone, including a third-party malicious script, tries to set an invalid value, the complex automation will instantly ignore the error and apply the Laboratory's reference combat standard — 2 attempts.

P5 · net.core.somaxconn — system gateway for buffer distribution

Reference Combat (AGL) Range
128 4096 128–32768 · fail-safe → 4096

Anatomy of the threat: mechanics of avalanche-like Connection Refused failures

When an incoming TCP connection passes preliminary stages, including the SYN-cookies cryptographic shield, it enters the ESTABLISHED state and arrives in the Linux kernel's system listen queue, where it waits until the application (Nginx, Apache2, or another package complex) picks it up via the accept() system call. By default, in conservative distributions, the size of this queue is hard-clamped to a factory limit — only 128 connections. During HTTP-Flood, Slowloris attacks, or an avalanche-like influx of bots, thousands of malicious threads try to occupy sockets simultaneously; if the application software, due to CPU load, delays accept() even for a fraction of a second, the 128-slot queue fills instantly. As soon as the queue overflows, the kernel enables a fail-closed mode of the network stack in a manner destructive to the server: it begins hard-dropping new incoming packets, firing the hardware-level error Connection Refused at legitimate users. The CPU spends colossal cycles generating reset packets (RST); kernel memory cannot redistribute socket structures fast enough — one short, low-power assault is enough to completely isolate the server from the external world with absolutely empty RAM.

Physics of the AGL defensive circuit (ON mode)

When switching to combat mode, the Laboratory, through the sysctl_tune_protocol.go layer, performs a large-scale expansion of the system gateway, raising net.core.somaxconn from 128 to the combat reference value of 4096 connections. One fully established but not yet processed socket in the queue reserves a metadata structure of about 2 KB of kernel memory: the maximum controlled limit of RAM filling when the gateway is extremely clogged to the upper limit — 4096 slots × 2 KB ≈ 8 MB. By allocating only 8 megabytes for maximum queue congestion, the complex creates a gigantic amortization buffer: even if application software temporarily hangs under CPU load, the kernel does not throw out legitimate clients with the error Connection Refused, but carefully holds them in a safe RAM queue, waiting for threads to free. Nanosecond disposal of slots allows processing up to 100,000 touches per minute while keeping RAM consumption within microscopic green-zone values.

Architectural fail-safe guard of the Laboratory

Unlimited expansion of socket queues on servers with weak hardware configuration can provoke avalanche-like exhaustion of network card buffers, so strict security validation of system boundaries is implemented. The fail-safe range in config.go: the parameter cannot be lowered below 128 (protection against artificial strangulation of the server by malicious scripts) and cannot exceed 32768 (a safeguard against kernel OOM crash during gigantic network assaults). If an administrator specifies a negative, garbage, or zero value, fail-safe automation will instantly intercept the error and apply the Laboratory's balanced combat standard — 4096 slots, guaranteeing uninterrupted perimeter availability.

P6 · net.ipv4.tcp_max_syn_backlog — half-open session damper

Reference Combat (AGL) Range
128 / 256 4096 128–32768 · fail-safe → 4096

Anatomy of the threat: mechanics of instant overflow of the input accumulator

During a SYN-flood attack, incoming SYN packets do not enter the somaxconn queue instantly — they first get stuck in the kernel's preliminary accumulator, the half-open connection queue (SYN Backlog), where sockets are held in the SYN-RECV state awaiting confirmation from the client. In standard distributions, the size of this buffer is limited to 128 or 256 slots. During a massive DDoS assault, when a botnet generates thousands of requests in a fraction of a second, the tiny accumulator becomes clogged in less than a second. The resource dead end is dangerous even when the cryptographic shield is enabled: the Linux kernel does not generate SYN-cookies constantly — it is a resource-intensive operation; the shield activates only when the tcp_max_syn_backlog queue is 100% full. If the buffer is too small (factory 128 slots), an architectural failure occurs: the influx of bots instantly fills the slots, the kernel enters a panic overload state and abruptly activates SYN-cookies mode, but due to the microscopic buffer size and scheduler overhead, it does not have time to switch the network stack logic in time and begins dropping incoming packets of legitimate users before the crypto-shield can fully deploy. The host's input interface is blocked — a blind denial of service with absolutely empty RAM.

Physics of the AGL defensive circuit (ON mode)

When switching to combat mode, the Laboratory, through the sysctl_tune_protocol.go layer, performs a large-scale expansion of the input amortization accumulator, raising net.ipv4.tcp_max_syn_backlog to the combat standard of 4096 connections — symmetric to the capacity of somaxconn. One half-open socket waiting in the queue reserves a minimal metadata structure of about 1 KB of kernel memory: the maximum controlled limit of RAM filling while holding an extreme peak assault before crypto-shield activation — 4096 slots × 1 KB ≈ 4 MB. By allocating only 4 megabytes for peak congestion, the complex creates a colossal damper zone: the buffer fills smoothly, allowing the CPU, without panic, delays, or packet drops, to activate and deploy the SYN-cookies cryptographic shield. Legitimate clients are carefully held in the expanded accumulator while bots are filtered by crypto computations; the throughput of the input circuit grows avalanche-like with microscopic RAM consumption.

Architectural fail-safe guard of the Laboratory

Unlimited expansion of input queues on servers with weak hardware configuration can provoke avalanche-like exhaustion of network card buffers, so strict security validation of system boundaries is implemented. Fail-safe range: the parameter cannot be lowered below 128 (protection against artificial strangulation of the server by malicious scripts) and cannot exceed 32768 (a safeguard against kernel OOM crash during gigantic network assaults). If an administrator mistakenly specifies an invalid, negative, or zero value, fail-safe automation will instantly intercept the error and apply the Laboratory's balanced combat standard — 4096 slots, guaranteeing uninterrupted perimeter availability.

P7 · net.ipv4.conf.all.rp_filter + default.rp_filter — anti-spoofing shield

Reference Combat (AGL) Range
0 / 2 (loose) 1 (strict) 0–2 · intentional 2 preserved

Anatomy of the threat: mechanics of IP-Spoofing attack (blind assault)

During powerful distributed DDoS attacks, hacker groups seek to solve two tasks: hide the true IP addresses of their mother servers from forensic analysis and bypass precise UFW firewall limits on the host. For this, IP-Spoofing technology is used — generation of RAW packets in whose headers the “sender address” field (Source IP) is filled with absolutely random, invented, or someone else's legitimate Internet IP addresses. In standard Linux configurations, the kernel's protective mechanism is often disabled or in Loose mode (value 0 or 2) — a dangerous architectural breach. When the kernel accepts a packet with a spoofed IP, it spends colossal CPU cycles processing it: moves the packet through all Netfilter chains, processes it with buffers, passes it to the application, then tries to generate a response packet and send it to the specified fake address. Under an assault of 100,000 packets with spoofed IPs per second, the kernel network stack becomes overwhelmed, endlessly computing response routes into the void; kernel routing tables swell avalanche-like with dead entries, consuming kernel RAM; the CPU goes into 100% congestion servicing parasitic traffic of phantom nodes, while legitimate users cannot break through the clogged routing buffers.

Physics of the AGL defensive circuit (ON mode)

When perimeter armor is activated through the sysctl_tune_protocol.go layer, the Laboratory Defender moves both parameters — net.ipv4.conf.all.rp_filter and net.ipv4.conf.default.rp_filter — to the strict combat value 1 (Strict Mode, strict reverse path filtering). The kernel begins applying the Reverse Path Forwarding algorithm to each incoming packet: when a packet arrives on an interface (for example, eth0), the kernel on the fly reads the Source IP specified in it; it instantly checks against the internal FIB routing base (Forwarding Information Base), computing: “if I myself were now sending a response packet to this IP, would my answer go through this same interface?” If a packet with a spoofed IP arrived on eth0, but the legitimate route to that address lies through another host interface, the kernel instantly recognizes the IP-Spoofing attack. Fail-closed, high-speed drop: the packet is destroyed by the kernel immediately at the network card hardware level — before RAM buffers are allocated, timers started, or heavy UFW rule chains traversed. It is dropped into the void, leaving no trace and spending not a single host CPU cycle on generating responses.

Architectural fail-safe guard of the Laboratory

Strict mode rp_filter = 1 is an uncompromising weapon: on servers with complex network configuration (two Internet providers, asymmetric routing, where traffic legitimately enters through one interface and leaves through another), Strict mode may mistakenly block clean users. The Laboratory accounts for this nuance with a flexible security validator in config.go: the allowed range is clamped from 0 to 2, where 2 is Loose Filter mode, checking only that a route to that IP exists in principle, which is an ideal compromise for multi-channel VPS. If an invalid value is entered, automation will apply the Laboratory's reference Strict standard — 1. However, if in the SETTINGS menu or through CORE_SETTINGS the administrator intentionally moves the slider to mode 2 for the conditions of their asymmetric network, the complex preserves this decision, carefully writing it through a transactional Update to config.json and instantly rebuilding the kernel runtime logic.

Snapshot before the storm

The kernel state is captured before the first ON. OFF returns to the baseline or factory references — the operator's choice.

The kernel is polled, not taken on faith

Every second, the CHECK circuit reads the real kernel, not a checkbox in the config. External change → incident CORE_MISCONFIGURATION , runtime marker invalidated, alarm to the operator.