DNS Server Fundamentals Series

🛑 The Top 1% Hands-On for Seeing DNS Amplification Firsthand and Defending With Response Rate Limiting (RRL)

Introduction

This article is part of the Top 1% Series Complete Article Guide.

Prerequisite Knowledge

The Big Picture

graph LR
    Step1["Step1<br/>Prepare a query<br/>that returns a big response"]
    Step2["Step2<br/>Actually measure<br/>the amplification factor"]
    Step3["Step3<br/>Enable RRL"]
    Step4["Step4<br/>Confirm responses get throttled<br/>under a flood of queries"]
    Step1 --> Step2 --> Step3 --> Step4

This hands-on never covers the actual attack technique of spoofing a source IP address. You’ll safely experience only the raw scale of DNS amplification itself, and the effect of the defense against it (RRL).

Hands-On Steps

Step 1: Prepare a Query That Returns a Large Response

On the lab.example.test zone from The Top 1% Hands-On Lab for Building a DNS Server With BIND, deliberately add a large-sized TXT record.

big  IN  TXT  "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...(repeat to around 400 characters)"
sudo named-checkzone lab.example.test /etc/bind/db.lab.example.test
sudo systemctl restart bind9

Step 2: Compare the Query and Response Sizes and Measure the Amplification Factor

Run dig with +stats and compare the size of the query you actually sent against the response you received.

dig @<server's IP> big.lab.example.test TXT +stats

Compare the MSG SIZE rcvd at the end of the output against the query’s rough size (a few dozen bytes or so). The query itself is a small UDP packet, a few dozen bytes, yet the response should reach several hundred bytes. That’s the amplification factor — only a few times in this example, but a real-world attack, abusing a record type with an even larger response (a DNSKEY record carrying a DNSSEC signature, say), can reach an amplification factor of dozens of times.

Send this small query in bulk, with the source IP address spoofed to the target’s IP address, and you can direct traffic many times the size of what you sent at the target — that’s the real substance of a DNS amplification attack. This hands-on never performs that spoofing itself.

Step 3: Enable Response Rate Limiting (RRL)

Add the RRL configuration to named.conf.options.

options {
    rate-limit {
        responses-per-second 5;
        window 5;
    };
};

responses-per-second 5 means responding to the same source, for the same query pattern, no more than 5 times per second. Anything beyond that gets deliberately throttled.

sudo named-checkconf
sudo systemctl restart bind9

Step 4: Send a Flood of Queries and Confirm Responses Get Throttled

From your own machine (with no source spoofing), send the same query repeatedly in quick succession.

for i in $(seq 1 20); do dig @<server's IP> big.lab.example.test TXT +noall +stats; done

Check RRL’s behavior in the logs, via journalctl or rndc stats.

sudo rndc stats
sudo tail -n 20 /var/cache/bind/named.stats

You’ll see a record of responses being processed as Dropped (discarded) or Slipped (a partially truncated response) once queries exceed the configured threshold (5 per second). Even querying yourself, RRL mechanically throttles the rate purely by looking at the combination of source address and query content.

What a Pro Sees Here (Top 1% Understanding)

RRL Suppresses Harm by Reducing “Responses to the Attacker”

RRL’s fundamental goal isn’t reducing the load on your own DNS server — it’s reducing the actual volume of traffic your server ends up sending toward a third party (the spoofed target), as a launchpad for a DNS amplification attack. Rather than blocking the attacker’s queries outright, capping the response frequency for the same query pattern to a fixed threshold significantly suppresses the total amplified traffic volume the target receives, even if your server does end up abused as a launchpad.

”Slip,” a Mechanism Minimizing Impact on Legitimate Users

RRL offers a setting to fully Drop (discard) a response, and a setting to return only a partial response as a Slip (a truncated response nudging toward TCP). If a legitimate user happens to send queries at a rate exceeding the threshold, fully discarding the response would break legitimate name resolution too. Slip deliberately corrupts the UDP response, nudging the client toward “the UDP response wasn’t valid, so retry over the more reliable TCP.” Since retrying over TCP (which requires a three-way handshake) is effectively impossible for an attacker spoofing their source, this design effectively suppresses attack traffic alone while minimizing the impact on legitimate users.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. A legitimate user reports unstable name resolution: Check whether RRL’s threshold (responses-per-second) is too strict for legitimate usage patterns.
  2. RRL is enabled, but nothing shows up in the logs: Check whether the rate-limit block in named.conf.options is loaded correctly, and check for syntax errors with named-checkconf.
  3. Wanting to investigate whether your own server has been abused as an amplification launchpad: Check whether recursion or a record with a large response is unnecessarily exposed while reachable from outside.

Summary

Takeaways to Apply Today

  1. For any DNS server exposed externally, consider enabling RRL.
  2. Periodically check whether you’re unnecessarily exposing recursion or large-response records externally.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).