Suresh Kumar Suresh Kumar - 3 months ago 13
Linux Question

How to block udp ports range in linux RHEL7

need to test an application which uses the UDP port range from 5000 to 60,000 in. i want to test the boundary value condition for ports. so i want to block UDP ports range from 5000 to 59999.

Answer

Using iptables:

iptables -A INPUT -p udp --dport 5000:59999 -j DROP

or, better,

iptables -A INPUT -p udp --dport 5000:59999 -j REJECT --reject-with icmp-port-unreachable