Protecting VPS and Dedicated Servers from DDoS Attacks: A Practical Guide to Strategies and Tools
TL;DR
- A comprehensive approach is critical: Effective protection requires a combination of network filters, WAF, CDN, and specialized services. One tool cannot handle the full spectrum of attacks.
- Proactive monitoring is your best friend: Don't wait for an attack. Set up detailed monitoring of traffic, resource utilization, and anomalies to detect threats at an early stage.
- Know your vulnerabilities: Conduct regular security audits and penetration tests. Understand which parts of your infrastructure are most vulnerable and strengthen them.
- Hybrid solutions are the optimal choice for 2026: A combination of cloud-based DDoS mitigators and local protection tools (iptables, Nginx, Fail2Ban) provides maximum flexibility and fault tolerance.
- The cost of protection is an investment, not an expense: Downtime due to a DDoS attack can cost tens or hundreds of thousands of dollars. A pre-allocated budget for protection pays for itself many times over.
- Regular testing and training: Simulate attacks to test the effectiveness of your protection and train your incident response team.
- Automation and AI: Utilize automated systems and AI-driven solutions for quick and effective response to new types of attacks, minimizing human error.
Introduction
Diagram: Introduction
In a world where digital infrastructure is the foundation of virtually any business, service availability is not just an important characteristic, but a critical indicator of market survival. By 2026, the threat of Distributed Denial of Service (DDoS) attacks has reached an unprecedented level of complexity and scale. If ten years ago DDoS attacks were primarily associated with hacktivism or competitive struggles, today they are a common tool for cybercriminals, extortionists, and even state actors.
Why is this topic important now? Advances in technologies such as IoT, 5G, and cloud computing have led to an exponential increase in the number of connected devices and the volume of generated traffic. This, on the one hand, opens up new opportunities for businesses, and on the other, provides attackers with colossal resources to organize attacks. Botnets, consisting of millions of compromised devices, are capable of generating terabits per second of traffic, easily paralyzing even well-protected resources. The cost of renting such a botnet on the black market has fallen to a minimum, making DDoS attacks accessible to a wide range of individuals.
The problems addressed by this article are multifaceted: from understanding modern attack vectors and risk assessment to choosing optimal protection strategies and practical tool implementation. We will not limit ourselves to theory but will delve into specific configurations, real-world case studies, and economic aspects that will help you make informed decisions.
This article is written for a broad audience of technical specialists who face the need to ensure the continuous operation of their online services. If you are a DevOps engineer responsible for infrastructure deployment and operation, or a Backend developer striving to create fault-tolerant applications, you will find valuable recommendations here. Founders of SaaS projects and Technical Directors of startups will gain an understanding of how to effectively allocate a security budget and what risks to consider when scaling. System administrators will find practical commands and configurations to strengthen their servers. We aim to provide expert yet understandable content that can be immediately applied in practice.
Our goal is not just to talk about DDoS protection, but to provide you with a comprehensive guide that will enable you to build a multi-layered, adaptive, and cost-effective protection system capable of withstanding threats in 2026 and beyond.
Key Criteria and Factors for Choosing Protection
Diagram: Key Criteria and Factors for Choosing Protection
Choosing the optimal strategy and tools for DDoS attack protection is not a "one-size-fits-all" task. It depends on many factors that need to be carefully analyzed. A wrong choice can lead to unjustified expenses, a false sense of security, or, even worse, a complete inability to withstand a real threat. Here are the key criteria to consider:
1. Attack Type and Vector
Before defending, you need to understand what exactly you are defending against. DDoS attacks are divided into several main categories, each requiring its own approach:
- Volumetric Attacks (Volumetric Attacks): Goal – to overload channel bandwidth or server resources with a huge volume of traffic. Examples: UDP flood, ICMP flood, SYN flood. They are measured in Gbps or Mpps (millions of packets per second).
- Protocol Attacks (Protocol Attacks): Goal – to exhaust network equipment or server resources by exploiting vulnerabilities in protocols (OSI Layer 3/4). Examples: SYN flood (both volumetric and protocol-based), Fragmented Packet Attack, Smurf Attack.
- Application-Layer Attacks (Application-Layer Attacks): Goal – to disable a specific application or service by imitating legitimate requests that require significant computational resources. Examples: HTTP flood, Slowloris, SQL injection (via DDoS vector), XML-RPC flood. These attacks are harder to detect as they appear as normal traffic.
Why this is important: Different types of attacks require different mitigation methods. Cloud DDoS protection providers are effective against volumetric attacks. Application-layer attacks require Web Application Firewalls (WAF) and advanced filtering logic. Assess which types of attacks are most likely for your service, based on its architecture and business logic.
How to assess: Conduct a threat analysis. Which protocols and ports are open? Which applications are most critical and resource-intensive? Do you have an attack history? If not, study statistics for your industry.
2. Scale and Intensity of Potential Attacks
How powerful can an attack targeting your resource be? This is one of the most important questions determining the choice of solution.
- Bandwidth: Your communication channel and your provider's channels. If you have 1 Gbps and the attack is 10 Gbps, you will be unavailable without external help.
- Packets per second (PPS): Even a small volume of traffic, but consisting of millions of small packets, can overload routers and network interfaces.
- Server Resources: CPU, RAM, disk I/O. Application-layer attacks are often aimed at exhausting these resources, rather than bandwidth.
Why this is important: Many hosting providers offer basic protection up to 1-5 Gbps. This may be sufficient for a small website but completely inadequate for a popular SaaS project. Specialized DDoS protection services can filter traffic up to several Tbps.
How to assess: Analyze the maximum possible load your server can withstand. Review reports on the largest DDoS attacks in recent years (e.g., attacks on Google, Amazon, or gaming services) and assess the risks for your niche. Remember that by 2026, 1-2 Tbps attacks are no longer extraordinary.
3. Infrastructure Location and Geographical Distribution
Where are your servers located, and where are your users located?
- On-premise Protection: Applied directly on the server or at the data center level. Effective for small to medium-scale attacks, as well as for protecting against application-layer attacks.
- Cloud Protection: Traffic is first routed through the DDoS protection provider's network, where it is filtered, and then clean traffic is delivered to your server. Ideal for volumetric attacks and globally distributed services.
Why this is important: If your primary traffic comes from Europe, but the DDoS protection provider only has Points of Presence (PoP) in Asia, this can add undesirable latency. For global services, a distributed PoP network from the protection provider is critically important.
How to assess: Determine the geography of your target audience. Do you have multiple data centers or do you use a CDN? The closer the traffic scrubbing point is to the attack source and to your users, the better.
4. Budget and Cost-Effectiveness
DDoS protection is an investment, not just an expense. However, budgets are always limited.
- Solution Cost: Monthly fee, payment for used traffic, setup and support costs.
- Downtime Cost: Revenue loss, reputational damage, customer loss, SLA penalties.
Why this is important: Cheap solutions may not provide sufficient protection, while expensive ones might be overkill for a small project. It's important to find a balance between the risk of downtime and the cost of protection. By 2026, many providers have shifted to more flexible pricing models, including pay-per-attack or adaptive pricing.
How to assess: Calculate the potential damage from an hour of downtime for your service. This will help determine the maximum budget you are willing to allocate for protection. Include not only direct losses but also reputational ones, which can be much higher.
5. Implementation and Management Complexity
How easy is it to integrate the solution into existing infrastructure and manage it?
- DNS Integration: Most cloud solutions require changing DNS records to redirect traffic.
- BGP Announcing: For more advanced solutions (e.g., for protecting an entire subnet), BGP announcing may be required.
- API and Automation: Ability for automatic management and integration with CI/CD.
- Expertise Availability: Does your team have sufficient knowledge to configure and support the chosen solution?
Why this is important: A complex solution that no one knows how to configure or support is useless. Ease of management and the availability of good documentation or support are very important, especially for startups with limited resources.
How to assess: Assess your team's technical readiness. Do you prefer "out-of-the-box" solutions or are you ready for deep customization? Review the documentation and available APIs from potential providers.
6. Latency (Latency) and Performance
Any intermediate link in the traffic processing chain can increase latency.
- Additional Hops: Cloud solutions add additional network nodes between the user and the server.
- Processing Time: Traffic filtering requires computational resources and time.
Why this is important: For some applications (online games, streaming, financial transactions), minimal latency is critical. Excessive latency can degrade user experience and lead to customer loss.
How to assess: Examine the network architecture of the protection provider. Do they have a global PoP network? How do they optimize routing? Conduct latency tests before and after solution integration.
7. Support Quality and SLA
What happens when an attack begins and you need help?
- Support Availability: 24/7, response time, communication channels (phone, chat, tickets).
- Expertise Level: How qualified is the support team in DDoS mitigation?
- SLA (Service Level Agreement): Guarantees for uptime, incident response time, recovery time.
Why this is important: During an attack, every second counts. Reliable and fast support can save your business. Clear SLAs provide confidence that the provider is responsible for their work.
How to assess: Read reviews about the provider's support. Clarify SLA details, especially regarding DDoS incident response. Do they have a dedicated security team?
DDoS Protection Solutions Comparison Table (2026)
Diagram: DDoS Protection Solutions Comparison Table (2026)
For clarity and to facilitate choice, we have compiled a comparative table of current approaches and solutions for DDoS attack protection, taking into account the realities and technologies of 2026. Prices and characteristics are approximate and may vary depending on the specific provider and scope of services.
| Criterion |
Local Protection (iptables, Nginx, Fail2Ban) |
DDoS Protection from Hosting Provider (Basic) |
Cloud DDoS Mitigators (CDN-like, L3/L4) |
Cloud DDoS Mitigators (Enterprise, L7) |
Hybrid Solutions (On-Prem + Cloud) |
BGP Flowspec / Scrubbing Centers |
| Attack Types (Primary Coverage) |
L3/L4 (partial), L7 (basic) |
L3/L4 (volumetric, protocol-based) |
L3/L4 (volumetric, protocol-based) |
L3/L4, L7 (complex, adaptive) |
L3/L4, L7 (comprehensive) |
L3/L4 (volumetric, protocol-based) |
| Max. Attack Volume (Estimate) |
Up to 1-2 Gbps, 0.5-1 Mpps |
Up to 5-20 Gbps, 1-5 Mpps |
Up to 1-5 Tbps, 50-100 Mpps |
Up to 5-10 Tbps, 100-200 Mpps+ |
Up to 5-10 Tbps+, 200 Mpps+ |
Up to 5-10 Tbps+, 200 Mpps+ |
| Implementation Complexity |
High (requires deep knowledge of Linux/networking) |
Low (often "out of the box" or activation) |
Medium (DNS change, possible API integration) |
Medium-High (DNS, WAF rules, API) |
High (integration of two systems) |
Very High (requires BGP, interaction with provider) |
| Latency |
Minimal (no extra hops) |
Minimal (no extra hops) |
Low-Medium (depends on PoP and routing) |
Low-Medium (depends on PoP, WAF logic) |
Low-Medium (optimized) |
Low-Medium (depends on scrubbing center location) |
| Cost (Estimate 2026, USD/month) |
0-100 (engineer's time only) |
0-300 (included in plan or add-on option) |
200-2000 (basic plans), + for traffic/attacks |
1000-10000+ (fixed + usage-based) |
1500-15000+ (sum of components) |
From 5000+ (depends on traffic volume and SLA) |
| Customization Level |
High (full control) |
Low (limited settings) |
Medium (rule configuration, WAF) |
High (detailed WAF configuration, custom rules) |
Very High (full control over the local part) |
Medium (via provider, BGP rules) |
| Required Expertise |
High (network, OS, security) |
Low (basic knowledge) |
Medium (DNS, HTTP, basic security) |
High (network, security, WAF rules) |
Very High (integration, monitoring) |
Very High (BGP, network architecture) |
| Key Advantages |
Inexpensive, full control, fast for L7 |
Simple, basic level of protection, often free |
Scalability, L3/L4 protection, global coverage |
Comprehensive L7 protection, AI filtering, SLA |
Optimal balance, maximum flexibility |
Protection of entire subnets, very high capacity |
| Disadvantages |
Does not scale, does not protect against volumetric attacks |
Limited capacity, often no L7 |
Possible additional latency, cost, not always L7 |
High cost, additional latency |
High complexity, high cost |
Very high cost, high complexity, requires a provider |
Detailed Overview of Each Item/Option
Diagram: Detailed Overview of Each Item/Option
Now let's examine each of the protection options mentioned in the table in more detail, so you can gain a deeper understanding of their features, advantages, and disadvantages.
1. Local Protection (iptables, Nginx, Fail2Ban)
This is the foundation of any protection system that can and should be implemented directly on a server or VPS. It does not require additional external services, which makes it extremely attractive in terms of cost, but at the same time imposes serious limitations on scalability and the volume of attacks it can withstand.
Pros:
- Cost-effectiveness: Virtually zero direct costs, apart from your engineers' time for configuration.
- Full control: You have complete control over filtering rules and logic, and can adapt them to your application's specifics.
- Low latency: Traffic does not pass through third-party nodes, minimizing latency.
- Effectiveness against L7 attacks: Nginx and Fail2Ban can be very effective against low-frequency application-layer attacks that mimic legitimate traffic.
Cons:
- Ineffectiveness against volumetric attacks: If an attack exceeds your network channel's bandwidth or the server's CPU capacity to process packets, local protection is powerless. Traffic will simply "clog" the channel before it reaches your filters.
- Complexity of setup and maintenance: Requires deep knowledge of network protocols, Linux systems, Nginx, and regular rule updates.
- Limited scalability: Each server needs to be configured individually, which is difficult with a large number of instances.
- High server load: Traffic filtering, especially at L7, consumes significant CPU and RAM resources, which can lead to performance degradation during a strong attack.
Who it's for: Small projects, startups with limited budgets, test environments, and as a first line of defense for larger systems, complementing cloud solutions. Ideal for protecting against port scanning, brute-force attacks, and basic HTTP floods.
Use cases: Protecting SSH from password brute-forcing (Fail2Ban), blocking suspicious IP addresses at the firewall level (iptables), limiting the number of requests from a single IP on a web server (Nginx).
2. DDoS Protection from Hosting Provider (Basic)
Many hosting providers and VPS/dedicated server providers (e.g., OVHcloud, Hetzner, Scaleway) offer basic built-in DDoS protection. It is usually activated automatically upon detection of anomalous traffic or can be enabled manually.
Pros:
- Simplicity: Often requires no client-side configuration, activated "out of the box" or with a single click.
- Integration: Fully integrated into the provider's infrastructure, ensuring minimal latency.
- Cost-effectiveness: Often included in the tariff plan or available for a small additional fee.
- Effectiveness against volumetric attacks: Capable of filtering volumetric attacks up to several tens of Gbit/s, preventing channel overload to your server.
Cons:
- Limited capacity: The maximum volume of attacks that can be filtered is usually lower than that of specialized cloud services. For very large attacks, it may not be sufficient.
- Limited control: You have little or no ability to influence filtering logic or customize rules to your needs.
- Not always effective against L7 attacks: Basic protection is often focused on L3/L4 and may miss complex application-layer attacks.
- Risk of false positives: Automated systems can mistakenly block legitimate traffic.
Who it's for: Small and medium-sized websites, blogs, corporate portals where the risk of very large attacks is low, or as a first line of defense before specialized cloud solutions. An excellent option for startups in their early stages.
Use cases: WordPress blog, small online store, corporate brochure website.
3. Cloud DDoS Mitigators (CDN-like, L3/L4)
These are specialized services that act as a proxy between your users and servers. Traffic first passes through their global network of Points of Presence (PoPs), where it is cleaned of malicious packets, and then the clean traffic is directed to your server. Examples: Cloudflare (basic plans), Sucuri, Akamai (basic services).
Pros:
- High scalability: Capable of absorbing and filtering attacks in hundreds of Gbit/s and even Tbit/s due to their enormous network bandwidth.
- Global coverage: A distributed PoP network minimizes latency for users worldwide.
- Effectiveness against volumetric attacks: Ideally suited for repelling L3/L4 attacks, preventing them from reaching your infrastructure.
- Additional features: Often include CDN for faster content delivery, basic WAF, SSL/TLS encryption.
Cons:
- Potential latency: Although the PoP network is global, traffic still passes through additional nodes, which can slightly increase latency.
- Cost: Starts from relatively affordable plans but can quickly increase with strong or frequent attacks (traffic-based billing) or for advanced features.
- Provider dependency: You entrust your protection to a third-party service.
- Not always ideal for L7: Basic plans may have limited capabilities for filtering complex application-layer attacks.
Who it's for: Medium and large websites, online stores, SaaS applications that require protection against volumetric attacks and global traffic distribution. An excellent choice for projects that have already experienced DDoS attacks.
Use cases: News portals, large blogs, e-commerce projects, SaaS platforms.
4. Cloud DDoS Mitigators (Enterprise, L7)
These are premium versions of cloud services (e.g., Cloudflare Enterprise, Akamai Prolexic, AWS Shield Advanced, Google Cloud Armor Enterprise). They offer comprehensive protection, including advanced WAF, AI-driven analytics, custom rules, and dedicated support.
Pros:
- Maximum protection: Capable of withstanding the most complex and large-scale attacks, including advanced L7 attacks that mimic real user behavior.
- AI-driven analytics: Use machine learning to detect new attack vectors and adaptive filtering.
- Custom WAF rules: Allow for very detailed application-layer filtering rules.
- Guaranteed SLA and support: Provide a high level of support and service availability guarantees.
- Proactive protection: Often include features for proactive monitoring and notifications of potential threats.
Cons:
- Very high cost: These are the most expensive solutions, which can cost thousands and tens of thousands of dollars per month.
- Configuration complexity: Maximum effectiveness requires deep configuration of WAF and security rules, which demands a qualified team.
- Potential latency: Advanced L7 filtering can add some latency due to deeper traffic analysis.
Who it's for: Large corporations, financial institutions, gaming services, critical SaaS platforms that require uncompromising protection and can afford significant investments in security. Projects for which a few minutes of downtime means millions in losses.
Use cases: Banking systems, large streaming platforms, high-load API services, international e-commerce giants.
5. Hybrid Solutions (On-Prem + Cloud)
This approach combines local protection measures (e.g., physical firewalls, WAF devices, or software solutions on servers) with cloud DDoS mitigators. Local measures handle part of the traffic and protect against low-frequency attacks, and in the event of a strong attack, traffic is redirected to the cloud.
Pros:
- Maximum flexibility: Allows leveraging the advantages of both approaches, adapting to the type and scale of the attack.
- Cost optimization: During normal times, cheaper local resources are used; cloud services are activated only when necessary (on demand or automatically).
- Improved performance: Clean traffic is processed locally with minimal latency.
- Comprehensive protection: Effective against all types of attacks, from volumetric to complex L7.
Cons:
- High complexity: Requires complex integration, configuration, and monitoring of both systems, as well as traffic switching mechanisms (e.g., via BGP or DNS).
- High cost: Costs for local hardware/software and cloud services are combined.
- Required expertise: A highly qualified team is needed for the design, implementation, and support of such a solution.
Who it's for: Large enterprises, telecommunications operators, hosting providers, government agencies that require maximum reliability and flexibility, as well as the ability to quickly scale protection. This is a solution for those who cannot afford compromises in security.
Use cases: Data centers, large telecom operators, critical government infrastructure.
6. BGP Flowspec / Scrubbing Centers
These are advanced methods primarily used by large enterprises, Internet Service Providers (ISPs), and telecommunications operators. BGP Flowspec allows dynamic dissemination of filtering rules across the network, while scrubbing centers are specialized traffic cleaning centers where all traffic is redirected during an attack.
Pros:
- Very high capacity: Scrubbing centers are capable of processing traffic in tens of Tbit/s.
- Network-level protection: Filtering occurs before traffic reaches your server or even your data center.
- Fast response: BGP Flowspec allows instant application of filtering rules on routers across the entire network.
- Protection of entire subnets: Can protect not only individual IPs but also entire address ranges.
Cons:
- Very high cost: This is one of the most expensive solutions, primarily available to large players.
- High complexity: Requires deep knowledge of BGP, network architecture, and close cooperation with the internet provider.
- Provider dependency: Fully depends on the capabilities of your ISP or a specialized scrubbing services provider.
- Potential latency: Traffic is directed to a remote scrubbing center, which can increase latency.
Who it's for: Internet providers, large corporations with their own Autonomous System (AS), data centers, government organizations. This is a solution for those who own their network infrastructure and have a high level of network expertise.
Use cases: Protection of backbone networks, large cloud platforms, critical national infrastructure.
Practical Tips and Recommendations for Implementation
Diagram: Practical Tips and Recommendations for Implementation
Now that we have reviewed various options, let's move on to specific steps and configurations that will help you protect your VPS or dedicated server.
1. Hardening the Operating System and Network
Basic protection starts with the server itself. These measures are effective against scanning, certain types of floods, and attempts to exploit vulnerabilities.
1.1. Firewall Configuration (iptables/nftables)
Use a firewall to block unwanted traffic and restrict access to ports. Example of a basic configuration for Linux (for Ubuntu/Debian, use ufw for simplification):
# Очистка текущих правил
sudo iptables -F
sudo iptables -X
sudo iptables -Z
sudo iptables -t nat -F
sudo iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
# Политика по умолчанию: DROP все, кроме разрешенного
sudo iptables -P INPUT DROP
sudo iptables -P FORWARD DROP
sudo iptables -P OUTPUT ACCEPT
# Разрешить уже установленные соединения и связанные
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
# Разрешить localhost
sudo iptables -A INPUT -i lo -j ACCEPT
# Разрешить SSH (порт 22) - замените на ваш порт SSH
sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
# Разрешить HTTP (порт 80) и HTTPS (порт 443)
sudo iptables -A INPUT -p tcp --dport 80 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -m conntrack --ctstate NEW -j ACCEPT
# Разрешить ICMP (ping) - опционально
sudo iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
# Защита от SYN-флуда (ограничение новых соединений)
sudo iptables -A INPUT -p tcp --syn -m limit --limit 1/s --limit-burst 3 -j ACCEPT
sudo iptables -A INPUT -p tcp --syn -j DROP # Дропаем все остальные
# Сохранение правил (для Debian/Ubuntu)
sudo apt install iptables-persistent -y
sudo netfilter-persistent save
sudo netfilter-persistent reload
Important: Always test rules on a test server and be careful not to lock yourself out.
1.2. Optimizing Network Kernel Parameters (sysctl)
Some Linux kernel parameters can help in combating DDoS, especially SYN-flood.
# Откройте /etc/sysctl.conf
sudo nano /etc/sysctl.conf
# Добавьте или измените следующие строки:
net.ipv4.tcp_syncookies = 1 # Включить SYN-cookies для защиты от SYN-флуда
net.ipv4.tcp_max_syn_backlog = 8192 # Увеличить очередь для SYN-запросов
net.ipv4.tcp_synack_retries = 1 # Уменьшить число SYN-ACK ретрансляций
net.ipv4.tcp_max_tw_buckets = 200000 # Увеличить количество TIME_WAIT сокетов
net.ipv4.tcp_tw_reuse = 1 # Разрешить повторное использование TIME_WAIT сокетов
net.ipv4.tcp_fin_timeout = 30 # Уменьшить время ожидания закрытия соединения
net.ipv4.ip_local_port_range = 1024 65535 # Расширить диапазон локальных портов
net.ipv4.icmp_echo_ignore_all = 1 # Игнорировать ICMP echo запросы (ping) - опционально
net.ipv4.conf.all.rp_filter = 1 # Включить защиту от спуфинга IP-адресов
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.accept_source_route = 0 # Отключить Source Routing
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.send_redirects = 0 # Отключить ICMP редиректы
net.ipv4.conf.default.send_redirects = 0
# Примените изменения
sudo sysctl -p
2. Installing and Configuring Fail2Ban
Fail2Ban scans server logs (SSH, web server, mail server) and automatically blocks IP addresses that show suspicious activity (e.g., multiple failed login attempts).
# Установка Fail2Ban
sudo apt update
sudo apt install fail2ban -y
# Создание локального конфигурационного файла
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
# Редактирование jail.local (пример для SSH)
sudo nano /etc/fail2ban/jail.local
# В секции [DEFAULT]
# bantime = 1h # Время блокировки IP-адреса (1 час)
# findtime = 10m # Время, за которое нужно обнаружить maxretry попыток (10 минут)
# maxretry = 5 # Количество неудачных попыток до блокировки (5 попыток)
# ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24 # Список IP, которые не будут блокироваться
# Включите нужные "jail" (например, sshd)
# [sshd]
# enabled = true
# port = ssh
# filter = sshd
# logpath = /var/log/auth.log
# maxretry = 5
# Перезапуск Fail2Ban
sudo systemctl restart fail2ban
sudo systemctl enable fail2ban
3. Configuring Web Server (Nginx) for L7 Attack Protection
Nginx can be very effective in filtering HTTP-flood and other L7 attacks.
3.1. Request Rate Limiting
Use limit_req and limit_conn directives to limit the number of requests and concurrent connections from a single IP address.
# В http-блоке
http {
# Ограничение скорости запросов: 10 запросов в секунду с IP, очередь 20 запросов
limit_req_zone $binary_remote_addr zone=one:10m rate=10r/s;
# Ограничение числа одновременных соединений: 5 соединений с IP
limit_conn_zone $binary_remote_addr zone=per_ip:10m;
server {
listen 80;
server_name your_domain.com;
# Применение ограничений
limit_req zone=one burst=20 nodelay;
limit_conn per_ip 5;
# Дополнительные настройки для защиты
client_max_body_size 10m; # Ограничение размера тела запроса
client_body_timeout 10s; # Таймаут на чтение тела запроса
client_header_timeout 10s; # Таймаут на чтение заголовков
location / {
# ... ваш основной конфиг ...
}
# Блокировка известных User-Agent ботов (пример)
if ($http_user_agent ~* "badbot|spider|scanner") {
return 403;
}
# Блокировка по рефереру (если не ожидаете внешних ссылок)
# if ($http_referer !~* "^(http://your_domain.com|https://your_domain.com)") {
# return 403;
# }
}
}
3.2. Using Cloudflare (or another CDN/DDoS service)
For volumetric attacks and advanced L7 attacks, Nginx on a single server will not suffice. Integration with Cloudflare (or a similar service) is a must-have.
- Change DNS records: Point your domain's A-records to Cloudflare's IP addresses.
- Configure WAF rules: In the Cloudflare dashboard, configure WAF to block suspicious requests, CAPTCHA for bots, and rules to protect against specific vulnerabilities.
- Enable "Under Attack Mode": During a severe attack, activate this mode for enhanced filtering.
- Restrict server access: Ensure your Nginx is configured to accept connections only from Cloudflare IP addresses. This prevents attackers from bypassing Cloudflare.
# В http-блоке Nginx (для Cloudflare)
# Добавьте список IP-адресов Cloudflare (актуальный список можно найти на их сайте)
# Пример (в 2026 году список может быть длиннее и измениться):
# set_real_ip_from 103.21.244.0/22;
# set_real_ip_from 103.22.200.0/22;
# ...
# real_ip_header CF-Connecting-IP; # Используйте заголовок Cloudflare для реального IP
# real_ip_recursive on;
# Если у вас есть только один Cloudflare IP для вашего сервера, можно использовать:
# allow 172.64.0.0/13; # Пример диапазона Cloudflare IP
# allow 103.21.244.0/22; # ... и другие
# deny all; # Блокировать все остальные
Personal experience: In one of our projects, when a volumetric attack exceeded 50 Gbit/s, local Nginx filters and even the basic provider protection were insufficient. Switching to Cloudflare Enterprise with fine-tuned WAF not only repelled the attack but also revealed new bot behavior patterns that we then used for preventive blocking.
4. Monitoring and Alerts
You cannot protect against what you don't know about. Set up comprehensive monitoring.
- Traffic Monitoring: Use
vnstat, iftop, netdata, or Grafana + Prometheus to track incoming and outgoing traffic. Look for anomalous peaks.
- Server Resource Monitoring: CPU, RAM, disk I/O, number of open connections (
netstat -an | grep :80 | wc -l).
- Log Monitoring: Centralized log collection (ELK Stack, Loki) and analysis for suspicious activity.
- Alerting Systems: Configure alerts (Slack, Telegram, email, SMS) when traffic, CPU load, or the number of 5xx errors exceed threshold values.
5. Developing an Incident Response Plan
What to do when an attack has already started? A clear action plan will reduce downtime.
- Define Responsibilities: Who is responsible for what?
- Escalation Steps: Whom to contact if the problem is not resolved at the first level?
- Provider Contacts: Quick access to contacts for your hosting provider and DDoS protection provider.
- Message Templates: Pre-prepared messages for clients about temporary disruptions.
- Switchover Procedure: How to quickly switch traffic to a backup server or activate enhanced protection?
Practical example: During a massive DDoS attack on a gaming server, the team lacked a clear plan. Some engineers tried to configure iptables, others contacted hosting, and a third group tried to find a third-party service. As a result, instead of 15-20 minutes of downtime, the server was unavailable for over 2 hours. After this, a detailed plan was developed and practiced, which reduced the reaction time by 80%.
Common Mistakes in Organizing DDoS Protection
Diagram: Common Mistakes in Organizing DDoS Protection
Even experienced engineers can make mistakes in the process of organizing DDoS protection. Knowing these pitfalls will help you avoid costly downtime and strengthen your infrastructure.
1. Ignoring the problem or hoping it "will pass"
Mistake: Many startups and even established companies postpone implementing full-fledged DDoS protection, considering it excessive or too expensive, until they face their first attack. A common misconception: "We are too small to be attacked."
How to avoid: Accept the fact that a DDoS attack is not a matter of "if," but "when." In 2026, attacks have become so cheap and easy to organize that anyone can be attacked, even for fun or minor competitive struggle. Include a budget for DDoS protection in the initial infrastructure planning phase. Conduct a risk assessment and evaluate potential damage from downtime.
Real-world consequences: A small SaaS project providing analytics was attacked by competitors. Having no protection, the project was unavailable for 48 hours. Losses included not only direct revenue loss (~$5000) but also the loss of 30% of subscribers due to distrust in the service's reliability, which in the long run amounted to hundreds of thousands of dollars.
2. Relying on only one layer of protection
Mistake: Believing that a single tool or a single provider (e.g., only Cloudflare or only iptables) will provide complete protection against all types of attacks.
How to avoid: Implement multi-layered, echeloned protection. Use cloud services for volumetric L3/L4 attacks, and local tools (Nginx, Fail2Ban) and WAF for protection against L7 attacks and specific vulnerabilities. A hybrid approach is the gold standard for 2026. Your hosting provider may have basic protection, but it is unlikely to save you from a powerful attack.
Real-world consequences: A large e-commerce site relied solely on its hosting provider's basic DDoS protection. When attackers launched a sophisticated L7 attack, mimicking buyer activity and overloading the database, the basic protection let all traffic through because it looked "legitimate." The site went down, leading to millions of dollars in lost sales during peak season.
3. Incorrect DNS configuration and bypassing protection
Mistake: After connecting to a cloud DDoS mitigator (e.g., Cloudflare), many forget to hide their server's real IP address. Attackers can easily find it using various tools (e.g., Shodan, Censys, old DNS records, SSL certificates, MX mail records) and attack directly, bypassing your protection.
How to avoid: Ensure that all DNS records (A, AAAA, MX, TXT, SRV) point to your DDoS provider's proxy servers, not to your server's real IP. If direct records are necessary (e.g., for mail), use different IP addresses or subnets, or ensure your mail server is also protected. Configure the server firewall to accept traffic only from your DDoS provider's IP addresses.
Real-world consequences: A SaaS platform developer connected Cloudflare but forgot to update the MX record, which pointed to the server's real IP. Attackers quickly discovered this IP and directed all traffic directly, completely bypassing Cloudflare. The damage from downtime and subsequent manual firewall configuration amounted to several days of work.
4. Lack of monitoring and response plan
Mistake: Hoping that protection will work on its own, and not having a monitoring system and a clear action plan in case of an attack. Lack of monitoring leads to late detection, and lack of a plan leads to chaotic and ineffective actions.
How to avoid: Implement a comprehensive system for monitoring traffic, server resource utilization, and logs. Set up automatic alerts for anomalies. Develop and regularly update an incident response plan that includes clear roles, steps, contacts, and escalation procedures. Conduct regular drills for the response plan.
Real-world consequences: A medical portal processing confidential data was attacked. Due to a lack of adequate monitoring, administrators learned about the attack only hours later from users. The absence of a plan led to panic and an inability to quickly restore operations, resulting in not only reputational losses but also potential fines for SLA and GDPR violations.
5. Insufficient protection testing
Mistake: Implementing protection and never testing it. Often, protection can be misconfigured or have "blind spots" that are only discovered during a real attack.
How to avoid: Regularly test your DDoS protection. This can involve controlled stress testing using legitimate tools (e.g., ApacheBench, Siege, k6), or hiring specialized companies to simulate real DDoS attacks. Start with small attacks and gradually increase their intensity. Analyze the results, identify weaknesses, and adjust the configuration.
Real-world consequences: A fintech startup invested significant funds in an enterprise DDoS mitigator but never tested it. During the first serious attack, it turned out that the WAF was configured too aggressively, blocking some legitimate users, and there were also issues with server throughput after traffic scrubbing. This led to significant downtime and the need for urgent reconfiguration in production mode, which always carries the risk of new errors.
6. Forgetting about L7 attacks, focusing only on L3/L4
Mistake: Many engineers believe that "if Cloudflare protects against volumetric attacks, we are safe." However, Cloudflare (and other services) in basic plans can miss sophisticated L7 attacks that slowly but surely exhaust application resources.
How to avoid: Remember that L7 attacks are often more sophisticated and target specific vulnerabilities in your application (e.g., resource-intensive database queries, slow API endpoints). Use a WAF (Web Application Firewall) as part of your cloud solution or as a separate component. Regularly analyze your web server and application logs for anomalous request patterns. Optimize application performance so it can withstand higher loads.
Real-world consequences: A game server was protected against volumetric attacks, but hackers discovered an API vulnerability allowing repeated session creation requests, which overloaded the authentication database. Although the traffic volume was small, the server constantly crashed due to database resource exhaustion. The problem was only resolved after implementing custom WAF rules that blocked this specific request pattern.
Checklist for Practical DDoS Protection Implementation
To systematize the process of implementing and ensuring DDoS protection, use the following step-by-step algorithm.
- Assess risks and threats:
- Determine which types of DDoS attacks are most likely for your service (L3/L4 volumetric, L7 application-layer).
- Estimate the maximum traffic volume and PPS that your infrastructure can withstand without protection.
- Calculate the potential damage from downtime (financial, reputational).
- Choose a protection strategy:
- Determine which solution suits you best: on-premise, from a hosting provider, cloud-based (L3/L4, L7 Enterprise), or hybrid.
- If VPS/dedicated server, consider a cloud solution (CDN-like) as the primary echelon.
- Harden the server at the OS level:
- Configure a firewall (iptables/nftables) to block unwanted ports and limit traffic.
- Optimize kernel network parameters (sysctl) to protect against SYN floods and other network attacks.
- Install and configure Fail2Ban to protect against brute-force attacks on SSH, FTP, web servers, etc.
- Configure the web server (Nginx/Apache):
- Use request rate limiting (
limit_req) and connection limiting (limit_conn) directives.
- Apply basic rules to block known User-Agent bots or anomalous requests.
- Limit request body size and timeouts.
- Integrate cloud DDoS protection (if chosen):
- Change DNS records (A, AAAA) for the domain so that traffic passes through your protection provider (e.g., Cloudflare).
- Ensure that your server's real IP is not disclosed in any public sources (DNS, SSL certificates, logs).
- Configure the server firewall to accept connections only from the IP addresses of your cloud protection provider.
- Configure Web Application Firewall (WAF):
- Enable and configure WAF rules with your cloud provider or install a separate WAF (e.g., ModSecurity for Nginx).
- Create custom rules to protect against specific L7 attacks targeting your application.
- Implement a monitoring system:
- Set up monitoring for network traffic (inbound/outbound), PPS.
- Monitor server resources (CPU, RAM, Disk I/O, number of connections).
- Centralized collection and analysis of logs (web server, application, firewall).
- Configure an alerting system:
- Set thresholds for all key metrics (traffic, CPU, 5xx errors).
- Configure alerts (email, Slack, Telegram) when thresholds are exceeded.
- Develop and practice an incident response plan:
- Define team roles and responsibilities during a DDoS attack.
- Create a clear step-by-step action algorithm (escalation, provider contacts, switching to backup systems).
- Regularly conduct drills for the response plan.
- Conduct regular protection testing:
- Initiate controlled stress tests or hire specialized companies for penetration tests.
- Analyze results, identify weaknesses, and optimize settings.
- Automate and use AI:
- Where possible, automate the activation of enhanced protection modes or traffic switching.
- Use AI-driven solutions for adaptive protection against new and mutating attacks.
- Regularly update software and rules:
- Update the operating system, web server, applications, Fail2Ban, and other components.
- Review and update firewall and WAF rules in accordance with new threats and infrastructure changes.
Cost Calculation / DDoS Protection Economics
Diagram: Cost Calculation / DDoS Protection Economics
The question of DDoS protection cost often becomes a stumbling block. However, these costs should be viewed not as an expense, but as an investment in business continuity. The cost of downtime due to a DDoS attack can many times exceed the cost of preventive measures.
1. Calculation Examples for Different Scenarios (2026)
Let's consider a few typical scenarios and estimate the approximate costs of DDoS protection, taking into account current prices for 2026.
Scenario 1: Small Startup/Blog (limited budget)
- Infrastructure: 1-2 VPS, traffic up to 100-200 Mbps.
- Risks: Random attacks, small competitors, script kiddies.
- Solution:
- Local protection: iptables, Nginx rate limiting, Fail2Ban. (Free, engineer's time only ~0-50 USD/month, if outsourced)
- Basic protection from hosting provider: Often included in the plan or a small surcharge. (0-50 USD/month)
- Cloudflare Free/Pro: For L3/L4 protection and basic WAF. (Free/20 USD/month)
- Total monthly cost: ~0 - 70 USD
- Expected level of protection: Excellent protection against small-scale L7 attacks, medium against volumetric attacks up to 5-10 Gbps.
Scenario 2: Medium e-commerce project/SaaS platform (growing business)
- Infrastructure: 5-10 servers (VPS/Dedicated), traffic up to 1-5 Gbps.
- Risks: Targeted competitor attacks, extortion, active L7 attacks.
- Solution:
- Local protection: As a baseline on each server. (Engineer's time ~100-200 USD/month)
- Cloudflare Business/Enterprise Lite: Advanced L3/L4 and L7 protection, CDN, WAF with custom rules. (200 - 1000 USD/month, depends on traffic and features)
- Monitoring: Prometheus + Grafana + alerts. (Instance/service cost ~50-100 USD/month)
- Total monthly cost: ~350 - 1300 USD
- Expected level of protection: High protection against volumetric attacks up to 100-200 Gbps and complex L7 attacks.
Scenario 3: Large Corporation/Financial Service (critical infrastructure)
- Infrastructure: Dozens of dedicated servers, own AS, traffic up to 10-50 Gbps.
- Risks: State-sponsored attacks, APT groups, multi-terabit attacks, complex L7 attacks using AI.
- Solution:
- Hybrid protection: On-Premise (hardware WAFs/firewalls) + Cloudflare Enterprise / Akamai Prolexic / AWS Shield Advanced. (On-Premise equipment: 500-2000 USD/month depreciation + Cloud: 5000 - 30000+ USD/month, depending on traffic volume and SLA)
- BGP Flowspec / Scrubbing Center: Integration with ISP or specialized provider. (From 5000 - 20000+ USD/month)
- Dedicated security team: 24/7 monitoring and response. (Engineers' salaries: 10000 - 30000 USD/month)
- Penetration tests and audit: Regular testing. (Annually 10000 - 50000 USD)
- Total monthly cost: ~20000 - 80000+ USD
- Expected level of protection: Maximum protection against all types of attacks, with rapid response and guaranteed SLA.
2. Hidden Costs
In addition to the direct cost of services, there are other expenses:
- Engineer's time: Setup, monitoring, incident response. This can be a significant part of the budget, especially for small teams.
- Training: Training the team on new tools and methodologies.
- Performance overhead: Some solutions (especially L7 WAFs) can add latency or consume resources, which may require increasing server capacity.
- Unforeseen expenses: Payment for "over-limit" traffic during very strong attacks, if your plan does not include unlimited traffic.
- Damage from false positives: If the protection is too aggressive, it can block legitimate users, leading to loss of revenue and reputation.
3. How to Optimize Costs
- Start with the basics: For startups, begin with local protection and a free/low-cost cloud solution (Cloudflare Free/Pro). As your business and risks grow, scale up your protection.
- Use a hybrid approach: It allows you to save by using more expensive cloud solutions only when necessary.
- Optimize the application: The more performant your application, the more load it can withstand, reducing reliance on external mitigators for L7 attacks.
- Use a CDN: Distribute static content via CDN to reduce the load on your server and decrease the volume of traffic that needs filtering.
- Negotiate with providers: For large traffic volumes and long-term contracts, there is always an opportunity to get individual terms and discounts.
- Regular audit: Conduct an audit of current security costs. Perhaps some features or services are no longer needed, or more economical alternatives exist.
Table with Calculation Examples (averaged values 2026)
| Protection Component |
Monthly Cost (USD) |
Comment |
| Local protection (engineer's time) |
50 - 500 |
Setup of iptables, Nginx, Fail2Ban. Depends on complexity and number of servers. |
| Basic from hosting |
0 - 300 |
Often included or available as an add-on option. |
| Cloudflare Pro |
20 - 200 |
Depends on traffic and additional features. |
| Cloudflare Business |
200 - 1500 |
Advanced WAF, SLA, extended analytics. Depends on traffic. |
| Cloudflare Enterprise / Akamai Prolexic / AWS Shield Adv. |
5000 - 30000+ |
Highest level of protection, custom rules, dedicated support. |
| BGP Flowspec / Scrubbing Service |
5000 - 20000+ |
For protecting entire subnets, very high volumes. |
| Monitoring (Prometheus/Grafana/Netdata) |
50 - 300 |
Cost of monitoring instances or cloud services. |
| Penetration Tests / Audits (annual budget) |
800 - 4000 |
Divided by months. Average cost of a small audit. |
| Security Team (part of salary) |
500 - 5000+ |
Part of the salary of a DevOps/SysAdmin responsible for security. |
As seen from the table, the price range is enormous, and it directly correlates with the required level of protection and business scale. Effective budget management implies continuous risk analysis and adaptation of the protection strategy to current needs, rather than a "one-time" purchase.
Case Studies and Real-World Examples
Diagram: Case Studies and Real-World Examples
Theory is important, but real-world cases demonstrate how DDoS protection principles work in practice, what problems arise, and how they are solved.
Case 1: Small SaaS Project and a "Starter" DDoS Attack
Project:
Analytics SaaS for small businesses, running on a single VPS (8 CPU, 16GB RAM) with Nginx, Node.js API, and PostgreSQL. Daily audience of up to 5000 unique users. Minimal security budget.
Problem:
After launching an aggressive marketing campaign, the project attracted the attention of a minor competitor who ordered a DDoS attack. The attack was a combination of SYN-flood (up to 5 Gbps) and HTTP GET-flood on API endpoints (up to 10000 requests per second).
Initial State of Protection:
Only basic protection from the hosting provider (up to 2 Gbps) and minimal iptables settings on the server.
Attack Progression and Consequences:
The server immediately stopped responding. The hosting provider's communication channel was overwhelmed, and even SSH access was difficult. Attempts to manually configure iptables or Nginx were useless, as traffic was not reaching the server in sufficient volume. Downtime lasted 3 hours, leading to the loss of dozens of registrations and a serious blow to reputation.
Solution Adopted:
- Emergency Connection to Cloudflare Pro: DNS records were changed so that all traffic went through Cloudflare. This allowed filtering of the volumetric SYN-flood.
- WAF Configuration in Cloudflare: To combat HTTP GET-flood, WAF rules were configured to require CAPTCHA for suspicious requests and block IP addresses generating too many requests to the API.
- Strengthening Local Protection: After access was restored, more aggressive Nginx rules (
limit_req, limit_conn) and Fail2Ban were configured on the server to protect SSH and other services.
- Hiding the Real IP: Ensured that the server's real IP was not exposed anywhere, and the firewall was configured to accept traffic only from Cloudflare.
Results:
After implementing Cloudflare Pro and strengthening local protection, the project successfully withstood several more attacks of similar scale without any downtime. The cost of Cloudflare Pro (20 USD/month) proved negligible compared to the losses from downtime. The team gained invaluable experience and an understanding of the need for multi-layered protection.
Case 2: Large Gaming Server and a Complex Hybrid Attack
Project:
A popular multiplayer online shooter, running on a cluster of dedicated servers in multiple data centers. Peak online players up to 50,000. Latency sensitive.
Problem:
During peak season, the server was subjected to a complex hybrid attack, including:
- Volumetric UDP-flood (up to 500 Gbps) on game ports.
- SYN-flood on TCP ports (up to 50 Mpps).
- L7 attacks on the authorization API and matchmaking server, mimicking legitimate requests but with abnormal frequency and patterns.
Initial State of Protection:
A hybrid approach was used: basic protection from the data center (up to 200 Gbps), Cloudflare Enterprise for the web part and authorization API, as well as hardware firewalls (Juniper SRX) with configured rules on each server for game traffic.
Attack Progression and Consequences:
The first two waves (UDP and SYN-flood) were successfully repelled by the data center and Cloudflare. However, the L7 attack on the API began causing delays and errors in authorization, and also led to matchmaking freezes. Part of the game traffic (UDP) also suffered due to data center router overload, as hardware firewalls could not process such a volume.
Solution Adopted:
- Activation of "Under Attack" mode in Cloudflare Enterprise: Enhanced L7 traffic filtering, application of more aggressive CAPTCHA rules and JS challenges.
- Fine-tuning WAF rules in Cloudflare: Identification of anomalous API request patterns (e.g., too frequent session creation requests from a single IP or User-Agent) and creation of custom rules to block them.
- Interaction with the Data Center: Temporary redirection of all game UDP traffic through the data center provider's specialized scrubbing center (using BGP Flowspec to announce routes). This allowed filtering of the main volume of UDP-flood before it reached the servers.
- API Optimization: During the attack, "heavy" API endpoints were identified. Developers promptly implemented caching and optimized database queries to reduce the load.
Results:
Thanks to a multi-layered approach and the team's prompt reaction, the attack was fully repelled within 40 minutes. The game process was disrupted, but no critical downtime occurred. This case showed that even with "premium" protection, constant monitoring, flexibility in settings, and readiness for prompt interaction with providers are required.
Case 3: SaaS Project Founder and Unexpected Costs
Project:
A young SaaS project for project management, running on AWS (EC2, RDS, S3). AWS Shield Standard (free) and basic Security Groups were used. Monthly infrastructure budget around 1000 USD.
Problem:
The project faced an attack that generated about 20 Gbps of traffic, targeting the web server and API. The attack lasted 6 hours.
Initial State of Protection:
AWS Shield Standard provides protection against the most common L3/L4 attacks, but does not guarantee protection against all types of attacks and does not include L7 protection. Security Groups were configured as standard.
Attack Progression and Consequences:
AWS Shield Standard partially filtered the traffic, but a significant portion still reached the EC2 instances, overloading them. Auto-scaling kicked in, and additional instances were launched to handle the load. However, this led to a colossal increase in bills for traffic and EC2 usage.
Solution Adopted:
- Bill Analysis: Within 6 hours of the attack, the bill for traffic and additional EC2 instances increased by 2500 USD. This came as a shock to the founder.
- Switch to AWS Shield Advanced: The founder decided to invest in AWS Shield Advanced (3000 USD/month), which covers the costs of EC2/ELB scaling during DDoS attacks and provides access to the Incident Response Team (DRT).
- AWS WAF Configuration: As part of Shield Advanced, AWS WAF was configured with rules to protect against L7 attacks targeting the project's API.
- Architecture Optimization: An architecture review was conducted, more caching was implemented, and critical API endpoints were further protected at the application level.
Results:
Although the first incident led to significant unexpected costs, the investment in AWS Shield Advanced and WAF paid off in the long run. The project gained reliable protection and stopped worrying about "surprises" in bills. This case highlights the importance of not only technical readiness but also financial planning for DDoS protection.
Troubleshooting: Resolving DDoS Protection Issues
Diagram: Troubleshooting: Resolving DDoS Protection Issues
Even with robust protection, problems can arise. It's important to be able to quickly diagnose them and take action. Here are typical problems and approaches to solving them.
1. Typical Problems and Their Solutions
Problem: Server is unreachable, but monitoring shows no traffic spikes
- Possible Causes:
- False blocking of legitimate traffic by firewall/Fail2Ban (including your IP).
- DNS record issues (traffic misdirected).
- Provider's network equipment issues (not DDoS).
- Low-frequency L7 attack that does not cause high-volume traffic but overloads the application.
- Diagnosis:
- Try connecting to the server via SSH from a different IP address.
- Check firewall logs (
/var/log/syslog, /var/log/auth.log for Fail2Ban).
- Check domain DNS records using
dig or online tools.
- Check web server (Nginx/Apache) and application logs for anomalous requests or errors.
- Server resource monitoring (CPU, RAM, number of connections) may show overload without a traffic spike.
- Solution:
- Temporarily disable/reset the firewall (if SSH access is available). Add your IP to the whitelist.
- Correct DNS records.
- Contact your hosting provider to check network accessibility.
- Analyze application logs, optimize "heavy" queries, configure WAF.
Problem: Server is unreachable, monitoring shows traffic spikes, but cloud protection did not activate
- Possible Causes:
- The server's real IP address is compromised, and the attack is direct, bypassing cloud protection.
- The attack exceeds the capabilities of your cloud protection plan.
- Incorrect cloud protection configuration (e.g., WAF rules are too lenient).
- A new, unknown type of attack that automatic systems failed to recognize.
- Diagnosis:
- Check server access logs: where is the traffic coming from? If the IP addresses do not belong to your cloud protection provider, then the IP is compromised.
- Check the cloud protection control panel: has "Under Attack" mode been activated, are there any attack notifications?
- Compare the attack volume with the capabilities of your service plan.
- Solution:
- Immediately change the server's IP address (if possible with your hosting provider) and ensure the new IP is not exposed. Configure the firewall to accept traffic only from your cloud provider.
- Contact cloud provider support: Discuss upgrading your service plan or activating enhanced protection.
- Strengthen WAF rules: Activate more aggressive settings, enable CAPTCHA/JS challenges.
Problem: False positives in protection (legitimate users are blocked)
- Possible Causes:
- Overly aggressive firewall/WAF rules.
- Fail2Ban blocks legitimate users (e.g., due to incorrect configuration).
- Automatic cloud protection systems mistakenly classify "good" traffic as "bad".
- Diagnosis:
- Check firewall/Fail2Ban logs for legitimate IP blocks.
- Analyze WAF logs in the cloud provider's control panel: which rules are triggered and for what traffic?
- Gather user feedback: which IP addresses were blocked, when did it happen?
- Solution:
- Relax or refine firewall/WAF rules. Add IP addresses or ranges from which legitimate users originate to the whitelist.
- Review Fail2Ban settings (
maxretry, findtime, bantime).
- Contact cloud provider support for fine-tuning rules or exclusions.
2. Diagnostic Commands
These commands will help you quickly get information about the server and network status:
3. When to Contact Support
Don't hesitate to ask for help. It's not a sign of weakness, but a sensible approach to incident management.
- Hosting Provider:
- If the server is completely unreachable over the network, and you cannot access it via SSH.
- If you observe high-volume attacks exceeding your bandwidth capacity.
- If you suspect the attack is targeting the data center's infrastructure itself, and not just your server.
- Cloud DDoS Protection Provider (Cloudflare, Akamai, AWS Shield):
- If the attack continues despite active protection.
- If you observe false positives and cannot configure the rules yourself.
- When fine-tuning WAF for specific L7 attacks is required.
- If you require assistance in analyzing attack vectors and developing countermeasures.
- Application Developers:
- For L7 attacks that overload the application but not the network channel.
- If monitoring shows high load on the database, CPU, or other application components.
- For optimizing "heavy" queries or implementing caching.
Important: When contacting support, always provide the most complete information possible: the exact time the attack started, the type of attack (if known), monitoring screenshots, logs, attacker IP addresses (if available), and all actions you have taken.
Frequently Asked Questions (FAQ)
1. What is the difference between a VPS and a dedicated server in the context of DDoS protection?
The main difference lies in resources and isolation. A VPS shares hardware resources with other users on a physical server. A dedicated server provides you with exclusive access to all physical resources. In the context of DDoS, a dedicated server typically has a wider network channel and greater computing power, allowing it to withstand more powerful attacks without external assistance. However, if an attack exceeds the data center's channel capabilities, both types of servers can suffer. Protection from a hosting provider on a dedicated server might be more robust, but cloud protection is critically important for both types.
2. Is it possible to completely protect against all types of DDoS attacks?
It is impossible to completely protect against all types of DDoS attacks. The goal of protection is not to prevent an attack, but to minimize its impact and ensure service continuity. Modern attacks are constantly evolving, and the task is to have a multi-layered, adaptive system capable of quickly responding to new threats. Even the world's largest companies face DDoS attacks, but their systems allow them to repel them quickly.
3. What are L7 attacks, and why are they so dangerous?
L7 attacks (Application-Layer Attacks) target the application layer (HTTP, HTTPS, DNS, SMTP). They mimic legitimate requests but aim to exhaust the server's or application's computing resources. They are dangerous because they are harder to distinguish from normal traffic, and they can be very effective even with a small volume of traffic if they target "heavy" or vulnerable application endpoints. Combating them requires Web Application Firewalls (WAF) and advanced request analysis logic.
4. How long does a typical DDoS attack last?
The duration of DDoS attacks varies greatly. Some attacks may last only a few minutes or hours, representing "quick" bursts. Others can continue for days or even weeks, especially if it's a targeted campaign. The average attack duration, according to data for 2025-2026, ranges from 4 to 12 hours, but much longer incidents also occur.
5. What is a "real IP" and why should it be hidden?
A "real IP" is the direct IP address of your server that does not pass through an intermediary (e.g., cloud DDoS protection). If attackers discover this IP, they can direct an attack directly to it, completely bypassing your cloud protection. Hiding the real IP address means that all public DNS records (A, AAAA, MX, etc.) must point to the IP addresses of your DDoS protection provider, and your firewall must be configured to accept traffic only from that provider.
6. Can I use only free tools for protection?
For small projects with a limited budget, using free tools (iptables, Nginx, Fail2Ban, Cloudflare Free) is a good start. They provide a basic level of protection against common, not very powerful attacks. However, for serious threats and large-scale attacks, they will be insufficient. Free solutions do not provide SLA guarantees, advanced analytics, and specialized support, which is critical for business.
7. How often should I test my DDoS protection?
It is recommended to test DDoS protection at least once a quarter or after every significant change in infrastructure or protection configuration. This can be either internal stress testing or hiring external experts to simulate real attacks. Regular testing helps identify "blind spots" and ensure that your system is ready for a real threat.
8. What is a CDN, and does it help against DDoS?
A CDN (Content Delivery Network) is a network of servers distributed worldwide that cache and deliver static content (images, videos, CSS, JS) to users from the nearest point. A CDN indirectly helps against DDoS by reducing the load on your main server, as most of the traffic is handled by the CDN. Some CDNs (e.g., Cloudflare) also include DDoS protection features, filtering traffic before it reaches your server, making them a comprehensive solution.
9. My hosting provider claims "unlimited" DDoS protection. Is this true?
Claims of "unlimited" DDoS protection are often misleading. While a provider may have high bandwidth, "unlimited" protection usually means they will try to filter traffic up to a certain threshold (e.g., 10-50 Gbit/s) or until it starts affecting other clients. For very powerful attacks (hundreds of Gbit/s and above), their basic protection may be insufficient, and they may offer you to switch to paid, more powerful solutions or even disconnect your server. Always clarify SLA details and the maximum attack volumes they can actually filter.
10. What should I do if my server is already under attack and I haven't configured anything?
If your server is already under attack and you have no configured protection, act quickly:
- Contact your hosting provider: They may have basic tools for temporary mitigation or offer to migrate to a protected IP.
- Activate Cloudflare (or a similar service): Quickly change DNS records so that traffic goes through Cloudflare. This may take up to 30-60 minutes for DNS propagation, but it's the fastest way to get volumetric protection.
- Restrict access by IP: If you know the attackers' IP addresses, temporarily block them via a firewall (iptables). This is a temporary measure.
- Put the site into "maintenance mode": If possible, display a placeholder page to reduce the load on the application and allow time to configure protection.
The main thing is not to panic and act methodically. After the attack, be sure to conduct an analysis and implement permanent protection.
Conclusion
In the face of constantly growing complexity and scale of DDoS attacks, by 2026, protecting VPS and dedicated servers has ceased to be merely an option—it is an integral part of any responsible business continuity strategy. We have moved from basic principles of operating system hardening to complex hybrid solutions and economic aspects, demonstrating that effective protection requires a comprehensive, multi-layered approach.
The key takeaway from this guide: there is no "silver bullet" or universal solution. Success in countering DDoS attacks lies in a combination of technical measures (firewalls, WAF, cloud mitigators), proactive monitoring, a clear incident response plan, and regular testing. Investing in DDoS protection is not an expense but a strategic investment that pays off many times over by preventing reputational and financial losses.
For DevOps engineers and system administrators, this means continuous learning and adaptation to new threats, mastering advanced tools and techniques. For founders and CTOs, it means understanding risks, adequate budget planning, and fostering a culture of security within the team. Do not wait for the first attack to realize its importance. Preparedness is your main asset.
Next steps for the reader:
- Conduct an audit: Assess the current state of your infrastructure and DDoS protection level.
- Develop a strategy: Using the criteria and comparison table from this article, choose the optimal set of solutions for your project.
- Implement and configure: Apply practical tips for server hardening and integration with cloud services.
- Set up monitoring and alerts: Stay informed about your system's status 24/7.
- Create and practice a response plan: Prepare your team for action in case of an attack.
- Regularly test and update: The world of threats is constantly changing, and your protection must change with it.
Remember that security is a continuous process, not an endpoint. Be vigilant, educate yourself, and protect your services so they remain available to your users at all times.