Skip to content
Back to Series Network Security from Scratch
Security

DoS and DDoS Attacks: How They Work, Types, and Mitigation

Learn how denial-of-service attacks work, from SYN floods and UDP amplification to botnets, plus practical mitigation for small servers and homelabs.

A
Alif Afriza Author
· · 4 min read
DoS and DDoS Attacks: How They Work, Types, and Mitigation

Denial of Service (DoS) is an attack that aims to make a service inaccessible. Its distributed version, DDoS, does it from many devices at once. This is the attack most frequently faced by website owners, including internet-exposed homelabs.

What Is the Difference Between DoS and DDoS?

  • DoS: one source attacks one target.
  • DDoS: many devices (often called a botnet) attack one target simultaneously.

DDoS is far harder to block because its sources are spread around the world. If you only block one IP, thousands of others remain.

Types of DDoS Attacks

1. Volume-Based (Exhausting Bandwidth)

Flooding the connection until the internet link is full. Example: a UDP flood attack that sends many UDP packets nonstop.

2. Protocol-Based (Exhausting Server Resources)

Attacks how protocols work. The most famous example: SYN flood.

The attacker sends many SYN packets (connection requests),
but never completes the handshake.
The server is busy waiting for half-finished connections until it runs out of resources.

Other attacks in this category: ping of death (an oversized ping packet), and attacks that abuse protocols such as DNS and NTP for amplification (reflecting a small amount of traffic into a very large one).

3. Application-Layer (Exhausting the Application)

It targets the application directly, not the network. Example: an HTTP flood that keeps requesting website pages until the server is overwhelmed, imitating normal user behavior so it is hard to distinguish from normal traffic.

How Amplification Works: Why DDoS Can Be So Large

Certain protocols (for example, older DNS, NTP, memcached) respond to a small request with a much larger response. The attacker spoofs the source address to the victim’s IP, then sends small queries to many public servers. All the servers reply to the victim at once, producing a massive flood.

This is why most internet providers have already closed vulnerable ports (such as NTP port 123 and memcached 11211) to break this chain, and why smaller DDoS attacks are less likely to reach the core layer when following the best practice of a reverse proxy.

How to Detect

Typical signs of a DDoS attack on a server:

  • Half-open connections surge (check with ss -tan state syn-recv).
  • Traffic rises sharply but no requests complete.
  • Server CPU / RAM approaches 100 percent without a reasonable application load.
  • Connection errors, timeouts, or a load balancer that keeps dropping connections.

Practical Mitigation for Homelab / Small Servers

1. Cloudflare Tunnel (which you already use)

Services such as Cloudflare sit between the server and the internet. DDoS attacks flood Cloudflare’s network, not your server. This is the best protection for a homelab at zero cost, and that is exactly why this website is set up through Cloudflare Tunnel.

2. Connection Limiting

Limit the number of new connections per minute per IP in the firewall:

# iptables: limit new SYN per second from a single IP (example values, adjust as needed)
iptables -A INPUT -p tcp --syn -m limit --limit 10/s -j ACCEPT
iptables -A INPUT -p tcp --syn -m limit --limit 30/m -j DROP

Note: this limiter protects against small SYN floods; it will not withstand a large-volume DDoS. Do not set unrealistic expectations.

3. Use a Proxy / CDN

If your pages are static, CDN services (Cloudflare, and so on) store a copy of the content, so the origin server does not need to be hit directly. Make sure the real IP address does not leak through DNS.

4. Monitoring

Set up simple alerts when traffic rises beyond normal limits (combined with uptime monitoring). With a small-volume attack, you have time to react before the server goes down.

What You Cannot Do on Your Own

For large DDoS attacks (hundreds of Gbps), mitigation is only effective at the network level of the provider or an anti-DDoS provider. A homelab will never win against that on its own. This is not a configuration failure, but a physical bandwidth fact. The solution is always in front of the server (Cloudflare, or a similar service), not inside the server.

Next in the curriculum: the most fundamental defense against attacks is the firewall: concepts, types, and basic configuration.

References

  • RFC 4732, Internet Denial of Service: Considerations and New Directions, rfc-editor.org/rfc/rfc4732 (structured analysis of DoS types).
  • RFC 4987, TCP SYN Flooding Attacks and Common Mitigations, rfc-editor.org/rfc/rfc4987 (explanation of SYN flood and mitigations).
  • NIST SP 800-61 Rev 2, Computer Security Incident Handling Guide, csrc.nist.gov/pubs/sp/800/61/r2/final (incident handling roadmap).
  • Cloudflare Learning Center, cloudflare.com/learning (up-to-date documentation on DDoS types).
Open for Contributors

Your ideas deserve to be read by thousands of people.

ByteNesia is built for everyone. If you have experience, tutorials, or opinions about technology, write and share them here. Your name will be credited as a contributor.

Write anything: tool reviews, homelab tutorials, security tips, or your tech stories.

Discussion & Comments