Debian12轻量抗DDOS攻击设置方法
技术问题
Debian12轻量抗DDOS攻击设置方法
2025-08-29 09:01
Debian12轻量抗DDOS攻击设置方法
# Debian 12 最大化抗 DDoS 优化参数 # 编辑完成后执行 sysctl -p 生效 ###################################### # 启用 SYN Cookies 防御 SYN Flood net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_max_syn_backlog = 4096 # 限制同时半连接(SYN_RECV)数量 net.ipv4.tcp_max_orphans = 32768 # 限制 TIME_WAIT 数量和超时时间 net.ipv4.tcp_fin_timeout = 15 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 0 # 避免 NAT 用户访问异常 # 减少内存耗尽风险 net.ipv4.tcp_max_tw_buckets = 5000 # 启用 IP 伪造防护 net.ipv4.conf.all.rp_filter = 1 net.ipv4.conf.default.rp_filter = 1 # 忽略 ICMP 广播 net.ipv4.icmp_echo_ignore_broadcasts = 1 # 限制 ICMP 请求速率 net.ipv4.icmp_ratelimit = 100 net.ipv4.icmp_ratemask = 88089 # 启用 ARP 防护 net.ipv4.conf.all.arp_ignore = 1 net.ipv4.conf.all.arp_announce = 2 net.ipv4.conf.default.arp_ignore = 1 net.ipv4.conf.default.arp_announce = 2 # 丢弃无效包 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.default.accept_redirects = 0 net.ipv4.conf.all.secure_redirects = 0 net.ipv4.conf.default.secure_redirects = 0 # 禁止源路由 net.ipv4.conf.all.accept_source_route = 0 net.ipv4.conf.default.accept_source_route = 0 # 防止 socket 被过度占用 net.core.somaxconn = 4096 net.core.netdev_max_backlog = 5000 net.ipv4.tcp_fastopen = 3 # 防 UDP Flood net.ipv4.udp_mem = 262144 327680 393216 net.ipv4.udp_rmem_min = 8192 net.ipv4.udp_wmem_min = 8192 # 增加系统文件描述符限制 fs.file-max = 2097152
nano /etc/sysctl.conf 编辑文件,保存后执行sysctl -p生效。
标签:
- Debian12轻量抗DDOS攻击设置方法