Overview
DDoS Deflate is a lightweight script designed to mitigate distributed denial of service (DDoS) attacks on Linux servers by monitoring the number of active connections per IP address. IP addresses that exceed a predefined threshold will be blocked, reducing the load caused by malicious traffic.Original Project
| Author | Contributors | Version | Last Update |
|---|---|---|---|
| Zaf | Colin Mollenhour | 0.6 | 2012 |
System Requirements
Operating System
Ubuntu 20.04/22.04/24.04 x64
Dependencies
bash, iptables, dnsutils, net-tools
Installation
Download Project
First, download the project using the gitfolder utility:Install DDoS Deflate
Run the installation script:The script automatically configures a cron job to run every minute and monitor active connections.
Configuration
Default Settings
The script runs every minute with these default settings:- Ban Limit: 150 simultaneous active connections
- Ban Period: 600 seconds (10 minutes)
- Excluded IPs: System IPs running DDoS-Deflate
Customize Configuration
Edit the configuration file to adjust thresholds:Key Configuration Options
Configuration Files
| File | Purpose | Location |
|---|---|---|
| Configuration | Main settings and thresholds | /usr/local/ddos/ddos.conf |
| Whitelist | IP addresses to never ban | /usr/local/ddos/ignore |
| Ban Log | Record of banned IPs | /usr/local/ddos/ddos.log |
Usage
Add IPs to Whitelist
Prevent specific IPs from being banned:Monitor Banned IPs
Check which IPs have been banned:View System Logs
Check cron execution logs:How It Works
Detection Process
- Connection Monitoring: Script runs every minute via cron
- Count Active Connections: Uses
netstatto count connections per IP - Threshold Check: Compares connection count against
BAN_LIMIT - Whitelist Verification: Checks if IP is in ignore list
- Apply Ban: Adds iptables rule to block traffic from offending IP
- Logging: Records ban event with timestamp and hostname resolution
- Automatic Unban: Removes block after
BAN_PERIODexpires
Uninstallation
To completely remove DDoS Deflate:Limitations
End of Life Status
End of Life Status
This project is no longer maintained. The last update was in 2012. Consider using modern alternatives like fail2ban, CSF (ConfigServer Security & Firewall), or cloud-based DDoS protection services.
Simple Detection Method
Simple Detection Method
DDoS Deflate uses basic connection counting which may not detect sophisticated distributed attacks or application-layer attacks.
False Positives
False Positives
Legitimate users behind NAT or shared IPs might trigger bans if multiple users access your service simultaneously.
Temporary Protection
Temporary Protection
Bans are temporary (10 minutes by default). Determined attackers can resume attacks after the ban period expires.
No Layer 7 Protection
No Layer 7 Protection
Only protects against connection-based attacks. Does not analyze HTTP requests or application-layer threats.
Alternatives
Since DDoS Deflate is deprecated, consider these modern alternatives:Fail2Ban
Active project with comprehensive attack detection and flexible ban rules
CSF Firewall
ConfigServer Security & Firewall with advanced DDoS protection
ModSecurity
Web application firewall for Apache/Nginx with OWASP rules
Cloudflare
Cloud-based DDoS protection with CDN and WAF capabilities
Troubleshooting
Script not running
Script not running
- Check cron service:
systemctl status cron - Verify cron entry:
sudo crontab -l | grep ddos - Check script permissions:
ls -l /usr/local/ddos/ddos.sh - Review syslog for errors:
grep ddos /var/log/syslog
IPs not being banned
IPs not being banned
- Verify BAN_LIMIT threshold in
/usr/local/ddos/ddos.conf - Check if IP is whitelisted in
/usr/local/ddos/ignore - Ensure iptables is running:
sudo iptables -L - Monitor connection counts:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Legitimate users blocked
Legitimate users blocked
- Add their IPs to
/usr/local/ddos/ignore - Increase BAN_LIMIT threshold
- Check for NAT/proxy scenarios
- Review ban logs:
cat /usr/local/ddos/ddos.log
Manual unban needed
Manual unban needed
Remove iptables rule manually:
Best Practices
Configure Whitelist
Add all trusted IPs (management, monitoring, APIs) to
/usr/local/ddos/ignore before enablingSet Appropriate Thresholds
Adjust
BAN_LIMIT based on your typical traffic patterns. Too low causes false positives, too high reduces effectivenessMonitor Logs Regularly
Review
/usr/local/ddos/ddos.log to identify attack patterns and adjust configurationCombine with Other Tools
Use alongside fail2ban, proper firewall rules, and rate limiting for comprehensive protection
License
Artistic License 1.0
Original code licensed under Artistic License 1.0
CC BY-SA 4.0
Documentation under Creative Commons Attribution-ShareAlike 4.0