-
Notifications
You must be signed in to change notification settings - Fork 0
DDOS Protection
Lean's edited this page Jan 30, 2026
·
5 revisions
- Basic UDP
#!/bin/sh
# Create a custom chain only once (if it doesn't already exist
iptables -N UDP_FLOOD 2>/dev/null
# Redirects traffic from each port to the UDP_FLOOD chain
iptables -A INPUT -p udp --dport 27015 -j UDP_FLOOD
iptables -A INPUT -p udp --dport 27016 -j UDP_FLOOD
# Anti UDP Bandwidth Flood
iptables -A UDP_FLOOD -p udp -m length --length 1200:65535 -j DROP
iptables -A UDP_FLOOD -f -p udp -j DROP
# Filters within the UDP_FLOOD chain
# Server 1
iptables -A UDP_FLOOD -p udp --dport 27015 -m recent --name server1ddos --rcheck --seconds 5 --hitcount 150 -j DROP
iptables -A UDP_FLOOD -p udp --dport 27015 -m recent --name server1ddos --set -j RETURN
# Server 2
iptables -A UDP_FLOOD -p udp --dport 27016 -m recent --name server2ddos --rcheck --seconds 5 --hitcount 150 -j DROP
iptables -A UDP_FLOOD -p udp --dport 27016 -m recent --name server2ddos --set -j RETURN
# General throttling (all other UDP packets pass here)
iptables -A UDP_FLOOD -m limit --limit 5/second --limit-burst 250 -j RETURN
# Blocks everything that goes through and is not accepted
iptables -A UDP_FLOOD -j DROP