Blog | G5 Cyber Security

Block Low Port Traffic to Stop DNS Attacks

TL;DR

DNS amplification attacks use your server to flood targets with unwanted traffic. Blocking incoming connections on privileged ports (below 1024) significantly reduces your risk, as attackers often spoof source ports in this range. This guide shows you how to do it using common firewall tools.

Steps

  1. Understand the Risk
  • Check Your Current Firewall Rules
  • Before making changes, see what rules you already have. The commands vary depending on your firewall.

  • Block Incoming Traffic on Privileged Ports (iptables)
  • This example blocks all incoming TCP traffic on ports 1-1023.

    sudo iptables -A INPUT -p tcp --sport 1:1023 -j DROP

    To block UDP as well:

    sudo iptables -A INPUT -p udp --sport 1:1023 -j DROP

    Important: These rules are not persistent by default. Save them so they survive a reboot.

  • Block Incoming Traffic on Privileged Ports (firewalld)
  • This example blocks all incoming traffic on ports 1-1023.

    sudo firewall-cmd --permanent --add-port=1:1023/tcp
    sudo firewall-cmd --permanent --add-port=1:1023/udp
    sudo firewall-cmd --reload
  • Block Incoming Traffic on Privileged Ports (ufw)
  • This example blocks all incoming traffic on ports 1-1023.

    sudo ufw deny from any to any port 1:1023 proto tcp
    sudo ufw deny from any to any port 1:1023 proto udp
    sudo ufw reload
  • Block Incoming Traffic on Privileged Ports (Windows Defender Firewall)
  • Test Your Rules
  • Use an online port scanner (e.g., YouGetSignal) to verify that ports 1-1023 are closed on your server.

  • Monitor Your cyber security
  • Regularly review firewall logs for any unexpected activity and adjust rules as needed. Consider using intrusion detection systems (IDS) for more advanced monitoring.

    Exit mobile version