Your server suddenly slows down, players drop off your game server, your website stops loading – and network traffic in your monitoring shoots up. The first thought: DDoS attack. The second: What can I do about it myself?
Before you start building firewall rules in a hurry, you need one thing above all: evidence. With a network dump – a capture of your network traffic made with tcpdump – you can see what is actually arriving, from which IP addresses and on which port. That is exactly what lets you filter out attacker IPs, set a firewall rule, configure Fail2ban or show our support team what is going on.
In this guide we show you step by step how to create a network dump, how to analyse it and which countermeasures you can apply yourself. And we tell you honestly why these dumps eat up a lot of disk space very quickly.
What is a network dump?
A network dump (also called a packet capture, traffic dump or pcap file) is a recording of the network packets that reach or leave your server. The standard Linux tool for this is tcpdump. It either prints packets live to the terminal or writes them to files in pcap format, which you can open later with tcpdump itself or graphically with Wireshark.
For DDoS analysis a dump is invaluable:
- Source IP addresses: Who is sending the traffic? A few IPs with lots of packets, or thousands of different ones?
- Destination port and protocol: Is your web server (80/443), SSH (22) or the game server port being hit? TCP or UDP?
- Pattern: Only SYN packets without a reply (SYN flood), huge UDP packets (amplification) or real HTTP requests (layer 7 flood)?
- Time and duration: When did it start, how long did it last – important for any later analysis and for support.
Check first: is it really a DDoS attack?
Not every load spike is an attack. An update, a backup job or a bot crawling your site can look similar. These commands give you a first impression in seconds:
# Overview of all sockets – unusually many "synrecv" or "estab"?
ss -s
# How many half-open TCP connections (SYN flood indicator) are there right now?
ss -Hnt state syn-recv | wc -l
# Which IPs are behind the half-open connections?
ss -Hnt state syn-recv | awk '{print $4}' | rev | cut -d: -f2- | rev | sort | uniq -c | sort -rn | head -20
# Packet and byte counters of the network interface
ip -s linkHundreds or thousands of connections in the SYN-RECV state are a typical sign of a SYN flood: the attacker sends masses of connection requests (SYN) but never answers your server's reply. The server holds every half-open connection for a while – until the queue is full and real visitors can no longer get through.
Preparation: install tcpdump and screen
On Debian and Ubuntu you install both tools with one command:
sudo apt update && sudo apt install -y tcpdump screenscreen keeps the capture running even if you close your SSH connection or it drops during the attack. Under load that happens quickly.
The command: capture a SYN flood (create a network dump)
This command starts a screen session syn-ddos with two windows:
- Window 0 "pcap" writes all incoming SYN packets to files under
/var/log/tcpdump– a new file every minute. - Window 1 "live" shows the same packets live and in detail in the terminal so you can see right away what is happening.
sudo mkdir -p /var/log/tcpdump && \
sudo screen -dmS syn-ddos -t pcap bash -c "tcpdump -ni any -s 96 -w '/var/log/tcpdump/syn-%Y%m%d-%H%M%S.pcap' -G 60 -W 180 'tcp and (tcp[tcpflags] & (tcp-syn|tcp-ack) == tcp-syn)'" && \
sudo screen -S syn-ddos -X screen -t live bash -c "tcpdump -i any -nn -tttt -vvv -e -S 'tcp and (tcp[tcpflags] & (tcp-syn|tcp-ack) == tcp-syn)'" && \
echo "running. reattach with: sudo screen -r syn-ddos"What the options mean
| Option | Meaning |
|---|---|
| -i any | Capture on all network interfaces |
| -n / -nn | Don't resolve IP addresses and ports – saves time and DNS lookups under load |
| -s 96 | Store only the first 96 bytes of each packet (headers are enough for analysis) |
| -w …%Y%m%d-%H%M%S.pcap | Write to files with date and time in the name |
| -G 60 | Start a new file every minute |
| -W 180 | At most 180 files – i.e. 3 hours, then the capture stops |
| -tttt | Timestamps with date in the live view |
| -vvv -e -S | Very verbose output incl. link layer and absolute sequence numbers |
| tcp[tcpflags] & (tcp-syn|tcp-ack) == tcp-syn | Only packets with the SYN flag without ACK – i.e. new connection attempts |
Using screen
# Reopen the session (started as root, so use sudo)
sudo screen -r syn-ddos
# Inside screen:
# Ctrl+A, then 0 → window "pcap" (file capture)
# Ctrl+A, then 1 → window "live" (live view)
# Ctrl+A, then D → detach, the capture keeps running
# Stop the capture completely
sudo screen -S syn-ddos -X quitWatch your disk space: network dumps grow fast
This is the point most people underestimate: a dump taken during an attack can take up tens or hundreds of gigabytes in a short time. If the disk fills up, databases, game servers and web servers crash – and the attack has achieved its goal twice over.
With -s 96 tcpdump only stores around 100 bytes per SYN packet (headers plus bookkeeping). It still adds up:
| Packets per second | per minute (1 file) | 3 hours (180 files) |
|---|---|---|
| 10,000 | approx. 60 MB | approx. 10 GB |
| 100,000 | approx. 600 MB | approx. 100 GB |
| 1,000,000 | approx. 6 GB | approx. 1 TB |
Without -s 96 tcpdump stores the entire packet – with UDP floods using large packets the dump becomes many times larger again.
This is how you keep storage under control:
# Check free space
df -h /var/log
# How big are the dumps so far?
du -sh /var/log/tcpdump
# Delete dumps older than 3 hours
sudo find /var/log/tcpdump -name 'syn-*.pcap' -mmin +180 -delete
# Compress important dumps (pcap usually compresses very well)
sudo gzip /var/log/tcpdump/syn-20261124-*.pcapAnalyse the dump: filter out attacker IPs
Now the capture becomes useful. This command counts which source IPs sent the most SYN packets:
tcpdump -nn -r /var/log/tcpdump/syn-20261124-180000.pcap 2>/dev/null \
| awk '{for(i=1;i<=NF;i++) if($i=="IP"){split($(i+1),a,"."); print a[1]"."a[2]"."a[3]"."a[4]; break}}' \
| sort | uniq -c | sort -rn | head -20For all files at once:
for f in /var/log/tcpdump/syn-*.pcap; do tcpdump -nn -r "$f" 2>/dev/null; done \
| awk '{for(i=1;i<=NF;i++) if($i=="IP"){split($(i+1),a,"."); print a[1]"."a[2]"."a[3]"."a[4]; break}}' \
| sort | uniq -c | sort -rn | head -20And which port is being hit:
tcpdump -nn -r /var/log/tcpdump/syn-20261124-180000.pcap 2>/dev/null \
| awk '{for(i=1;i<=NF;i++) if($i==">"){n=split($(i+1),a,"."); sub(":","",a[n]); print a[n]; break}}' \
| sort | uniq -c | sort -rn | headHow to read the result:
- A few IPs with very many packets: The classic case – you can block these IPs specifically (see below).
- Thousands of different IPs with a few packets each: A distributed attack (botnet) or spoofed source IPs. Blocking single IPs hardly helps here – SYN cookies, rate limits and above all upstream DDoS protection are what you need.
- Only one destination port: The attack targets a specific service. Check whether this port needs to be publicly reachable at all.
Countermeasures you can apply yourself
1. SYN cookies and kernel settings
SYN cookies mean your server no longer needs a queue for half-open connections during a SYN flood. Most distributions already enable them – check and harden it anyway:
cat <<'EOF' | sudo tee /etc/sysctl.d/99-synflood.conf
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.tcp_synack_retries = 2
EOF
sudo sysctl --system2. Block conspicuous IP addresses with nftables
If you found individual IPs in the dump, block them with nftables. Here the block expires by itself after one hour – so you don't lock yourself out permanently if you make a typo:
sudo nft add table inet ddos
sudo nft add set inet ddos blocklist '{ type ipv4_addr; flags timeout; }'
sudo nft add chain inet ddos input '{ type filter hook input priority -10; policy accept; }'
sudo nft add rule inet ddos input ip saddr @blocklist drop
# Block an IP for 1 hour (replace the example IP)
sudo nft add element inet ddos blocklist '{ 203.0.113.45 timeout 1h }'
# Show current blocks
sudo nft list set inet ddos blocklist3. Limit the SYN rate per IP
Instead of blocking every IP individually, you can limit the number of new connections per source IP. Anyone sending more than 30 connection attempts per second gets dropped:
sudo nft add set inet ddos synmeter '{ type ipv4_addr; flags dynamic, timeout; timeout 60s; }'
sudo nft 'add rule inet ddos input tcp flags & (syn | ack) == syn update @synmeter { ip saddr limit rate over 30/second burst 60 packets } drop'Adjust the limit to your service: a web server behind a reverse proxy or a large game server can legitimately see more connections from one IP.
4. Fail2ban for repeat offenders
Fail2ban reads log files and automatically bans IPs when they behave suspiciously – for example after several failed SSH logins or too many requests to your web server. It is very effective against brute-force attacks and smaller layer 7 floods (e.g. masses of HTTP requests). Our guide Setting up Fail2ban: protect SSH from brute-force attacks shows you how to set it up.
5. Reduce the attack surface
- Open only the ports you need: databases (3306), admin panels and query ports do not belong openly on the internet.
- Secure SSH: keys instead of passwords, root login disabled – see Secure your SSH server.
- Keep services up to date: a buggy mod or an outdated plugin is often more vulnerable than any network link.
- Know your baseline: if you know how much traffic and how many connections are normal day to day, you recognise an attack faster.
Where do-it-yourself defence reaches its limits
As useful as tcpdump, nftables and Fail2ban are: no rule on the server itself helps against a volumetric attack that fills your link. If more traffic arrives than the uplink can carry, the server is unreachable – no matter what the firewall drops afterwards. The same applies to attacks using thousands of spoofed source IPs.
That is why at MagicHosting a DDoS protection in front of your server filters attacks before they reach your link. We explain how the protection layers are built under DDoS protection. Background on game servers can be found in DDoS protection for game servers: what network filtering can do.
Checklist: DDoS attack on your server
- Stay calm and check whether it really is an attack (
ss -s, traffic graph) - Check there is enough free disk space (
df -h) - Start the tcpdump capture in screen
- Analyse the top IPs and the targeted port from the dump
- SYN cookies enabled, conspicuous IPs blocked via nftables, rate limit set
- Set up Fail2ban for SSH and the web server
- Close unnecessary ports
- Stop the capture and delete or compress old dumps
- If problems persist, open a support ticket with time window and excerpt
Frequently asked questions
How do I create a network dump on Linux?
Install tcpdump (sudo apt install tcpdump) and write the traffic to a file with tcpdump -ni any -w file.pcap. For attacks a filter pays off, for example only SYN packets, a limited packet size (-s 96) and splitting into one-minute files (-G 60). To keep the capture running, start it in a screen session.
How much disk space does a tcpdump capture need?
That depends on the packet rate. With -s 96 it is around 100 bytes per packet: at 100,000 packets per second that is about 600 MB per minute and roughly 100 GB in three hours. Without limiting the packet size it is many times more. So check free space with df -h beforehand and delete or compress old dumps.
What can I do if my server is hit by a DDoS attack?
First check whether it really is an attack and capture the traffic with tcpdump. Then analyse the most frequent source IPs and destination ports, enable SYN cookies, block conspicuous IPs with nftables and set a rate limit per IP. Against attacks that fill your link, only upstream DDoS protection helps – at MagicHosting it is included. If something still gets through, open a support ticket with the time window and an excerpt from the dump.
Does Fail2ban help against DDoS attacks?
Partly. Fail2ban bans IPs based on log files and works very well against brute-force attacks on SSH and against smaller HTTP floods. Against SYN floods or volumetric attacks with spoofed source IPs it hardly helps, because they don't produce matching log lines.
Can I simply block the attacker IPs?
Yes, if there are only a few real IPs – for example with an nftables set and an expiry time. With thousands of changing or spoofed IPs it achieves little. Then SYN cookies, a rate limit per IP and the DDoS protection in front of the server are the better choice.
Does tcpdump keep running when I close the SSH connection?
Only if you start it in a screen or tmux session. With the command from this guide the capture keeps running in the background. Use sudo screen -r syn-ddos to return to it and sudo screen -S syn-ddos -X quit to stop it.
How do I open a pcap file in Wireshark?
Download the file via SFTP to your PC and open it in Wireshark via File › Open. Under Statistics › Endpoints you immediately see which IP addresses caused the most traffic.
Looking for a server with DDoS protection?
At MagicHosting DDoS protection is included with every server:
- KVM VPS with root access, NVMe and DDoS protection – Linux or Windows
- Dedicated servers for large projects with lots of traffic
- Free 24-hour test server before you decide
Questions about an attack or your firewall? Just open a support ticket or message us on Discord.
Was this post helpful?
MagicHosting – Hosting with real value
Hosting pays off with MagicHosting: fair pricing, current deals and operation in SkyLink RZ. Servers, domains and personal support – no hidden costs.
- Current limited offers from our server exchange
- Affordable domains with transparent pricing and great offers
- Powerful DDoS protection for maximum availability
- Personal support when you have questions or issues