LogBeast CrawlBeast Consulting Blog Glossary Download Free

Detecting DDoS Attacks in Server Logs

Learn to identify DDoS attacks before they take down your server. Traffic pattern analysis, attack signatures, and real-time detection techniques.

🔒
✨ Summarize with AI

What is a DDoS Attack?

A Distributed Denial of Service (DDoS) attack floods your server with traffic from multiple sources, making it unavailable to legitimate users. Unlike single-source DoS attacks, DDoS attacks are harder to stop because traffic comes from thousands of IPs.

⚠️ Critical: A 10x sudden traffic spike is often the first sign of a DDoS attack. Early detection can mean the difference between a minor slowdown and complete downtime.

Types of DDoS Attacks

1. Volumetric Attacks

Flood bandwidth with massive traffic volume:

2. Protocol Attacks

Exploit weaknesses in network protocols:

3. Application Layer Attacks (Layer 7)

Target specific applications - most visible in server logs:

Early Warning Signs in Logs

Traffic Anomalies

# Requests per minute (normal vs attack)
awk '{print $4}' access.log | cut -d: -f1-2 | uniq -c | sort -rn | head -20

# Compare to baseline - 10x+ increase = red flag

Single IP Floods

# Top IPs by request count
awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -20

# If one IP has 10,000+ requests in an hour = suspicious

Unusual User-Agents

# Identical User-Agents across many IPs
awk -F'"' '{print $6}' access.log | sort | uniq -c | sort -rn | head -20

# Bots often use identical or empty User-Agents

Suspicious Patterns

# Requests to non-existent pages
grep " 404 " access.log | awk '{print $1}' | sort | uniq -c | sort -rn

# Same URL hit thousands of times
awk '{print $7}' access.log | sort | uniq -c | sort -rn | head -10

# POST requests (often used in attacks)
grep "POST" access.log | awk '{print $1}' | sort | uniq -c | sort -rn

Detection Techniques

Real-time Monitoring Script

#!/bin/bash
# Simple DDoS detection - run every minute via cron

LOG="/var/log/nginx/access.log"
THRESHOLD=1000  # requests per minute triggers alert

REQUESTS=$(tail -n 10000 $LOG | wc -l)

if [ $REQUESTS -gt $THRESHOLD ]; then
    echo "ALERT: $REQUESTS requests detected - possible DDoS"
    # Add notification (email, Slack, PagerDuty)
fi

Geographic Anomalies

# If you normally get US traffic but see 90% from one foreign country
# This can indicate a botnet from that region

# Use GeoIP lookup on top attacking IPs
geoiplookup 123.45.67.89

💡 Pro Tip: LogBeast includes built-in DDoS detection with automatic alerts when traffic exceeds your baseline by 200%, 500%, or 1000%.

Mitigation Strategies

Immediate Response

  1. Identify attacking IPs - Block the worst offenders
  2. Enable rate limiting - Limit requests per IP
  3. Activate CDN protection - Cloudflare, AWS Shield
  4. Scale resources - If cloud-based, add capacity

nginx Rate Limiting

# Add to nginx.conf
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;

server {
    location / {
        limit_req zone=one burst=20 nodelay;
    }
}

iptables Blocking

# Block specific IP
iptables -A INPUT -s 123.45.67.89 -j DROP

# Block entire subnet
iptables -A INPUT -s 123.45.67.0/24 -j DROP

# Rate limit connections per IP
iptables -A INPUT -p tcp --dport 80 -m connlimit --connlimit-above 50 -j DROP

Prevention Best Practices

🎯 Recommendation: Set up baseline monitoring before an attack happens. Know your normal traffic patterns so you can quickly identify anomalies.

See it in action with GetBeast tools

Analyze your own server logs and crawl your websites with our professional desktop tools.

Try LogBeast Free Try CrawlBeast Free