DDoS attacks are traffic assaults aimed at servers. Here are some commands to help you detect them:
top: Displays real-time system load and process distribution. You can see which processes are consuming resources during overload.
htop: A more user-friendly version of 'top', allowing for easier process management.
dmesg: Displays kernel messages, useful for network-related issues or errors.
iftop: Used to monitor network traffic, showing incoming and outgoing traffic for a specific interface.
DDoS Protection Solutions
To ensure DDoS protection, you can follow these steps:
Step 1: Basic Protection with UFW (Uncomplicated Firewall)
First, enable UFW to create a basic firewall:
sudo ufw enable
Step 2: Blocking Specific IPs
To block incoming traffic from specific IP addresses:
sudo ufw deny from
Step 3: Rate Limiting Settings
To limit the number of requests within a certain timeframe using UFW:
sudo ufw limit http/tcp
Step 4: DDoS Protection with Nginx
Open the Nginx configuration file and add rate limiting and other security measures:
sudo nano /etc/nginx/nginx.conf
Add the following settings:
http {
limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s;
server {
location / {
limit_req zone=mylimit burst=5;
# other settings
}
}
}
Step 5: Restarting Nginx
Restart Nginx to apply the changes made in the configuration file:
sudo systemctl restart nginx
Conclusion
Protecting against DDoS attacks is crucial for enhancing your server's security. By following the steps above, you can safeguard your server and be prepared for potential attacks.