Skip to content
Menu
vernon.wenberg.net
vernon.wenberg.net
June 9, 2023July 20, 2023

Rate limit connections in Linux

Use the following iptables command to rate limit connections per IP. This is useful for preventing a DDoS attack on DNS servers. However, for DDoS protection for your DNS servers, you should be hosting DNS with the big cloud providers like Cloudflare, or running dnsdist in front of your authoritive servers.

iptables -A INPUT -p udp -s 0.0.0.0/0 --dport 53 -m limit --limit 50/minute --limit-burst 250 -j ACCEPT
  • -s 0.0.0.0/0 – This denotes traffic coming from ALL IPs in CIDR notation.
  • –limit 50/minute – limits the number of connections per IP to 50 a minute.
  • –limit-burst 250 – limit/minute will be enforced after total connections reach this limit.
  • –dport 53 – Port. In this case, UDP port 53 (DNS)
  • –p udp – Protocol. In this case, UDP.

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to print (Opens in new window) Print
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn

Like this:

Like Loading...

Related

Disclaimer

These posts are notes for me. These are not guides and you should not use these instructions as step-by-step instructions without knowing what they do.

Recent Posts

  • Docker Reference
  • Useful Commands for Windows Subsystem for Linux
  • FortiManager Local-In Policy
  • Mount Google Drive in Linux using rclone
  • Restore original Explorer context menus in Windows 11

Mastodon

  1. Loading Mastodon feed...

©2025 vernon.wenberg.net | Powered by WordPress and Superb Themes!
%d