feat: add WireGuard VPN stack #33
@@ -342,9 +342,12 @@
|
|||||||
|
|
||||||
# Rate limiting and attack prevention
|
# Rate limiting and attack prevention
|
||||||
extraCommands = ''
|
extraCommands = ''
|
||||||
# Rate limit SSH connections (max 4 new connections per 60 seconds)
|
# 1. Wipe the INPUT chain clean at the start of every activation
|
||||||
|
iptables -F INPUT
|
||||||
|
|
||||||
|
# Rate limit SSH connections (max 20 new connections per 60 seconds)
|
||||||
iptables -A INPUT -p tcp --dport 2424 -m state --state NEW -m recent --set
|
iptables -A INPUT -p tcp --dport 2424 -m state --state NEW -m recent --set
|
||||||
iptables -A INPUT -p tcp --dport 2424 -m state --state NEW -m recent --update --seconds 60 --hitcount 4 -j DROP
|
iptables -A INPUT -p tcp --dport 2424 -m state --state NEW -m recent --update --seconds 60 --hitcount 20 -j DROP
|
||||||
|
|
||||||
# Rate limit HTTP/HTTPS (protects Traefik)
|
# Rate limit HTTP/HTTPS (protects Traefik)
|
||||||
iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
|
iptables -A INPUT -p tcp --dport 80 -m state --state NEW -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
|
||||||
@@ -355,6 +358,10 @@
|
|||||||
|
|
||||||
# Log dropped packets (rate limited)
|
# Log dropped packets (rate limited)
|
||||||
iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "IPTables-Dropped: " --log-level 4
|
iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "IPTables-Dropped: " --log-level 4
|
||||||
|
|
||||||
|
# 3. CRITICAL: Re-link the NixOS default firewall chain
|
||||||
|
# Without this line, the 'allowedTCPPorts' in your Nix config will be ignored!
|
||||||
|
iptables -A INPUT -j nixos-fw
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -433,7 +440,7 @@
|
|||||||
services.openssh.settings = {
|
services.openssh.settings = {
|
||||||
PermitRootLogin = "no";
|
PermitRootLogin = "no";
|
||||||
MaxAuthTries = 3;
|
MaxAuthTries = 3;
|
||||||
MaxSessions = 5;
|
MaxSessions = 10;
|
||||||
LoginGraceTime = 30;
|
LoginGraceTime = 30;
|
||||||
ClientAliveInterval = 300;
|
ClientAliveInterval = 300;
|
||||||
ClientAliveCountMax = 2;
|
ClientAliveCountMax = 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user