Security – How to block UDP while still allowing outbound UDP connections with iptables

ddosiptablesopenvpnSecurityudp

I would like to drop all UDP traffic (everything else is allowed) while still allowing outbound UDP traffic. The outbound traffic is mainly from gaming and voip calls. The UDP traffic needs to be blocked as the ISP (ovh) does not filter UDP based ddos attacks. They only filter TCP based ddos attacks. This was confirmed with a short phone call to them. That being said I need a way to block UDP to avoid DDOS attacks utilizing the UDP protocol from becoming successful while still allowing the outbound traffic. This will be done on a VPS Server at OVH running a VPN Server (OpenVPN TCP Port 443). Is there a set of rules I could add into iptables to accomplish this?

Best Answer

While blocking all incoming UDP is pretty simple:

iptables -A INPUT -p udp -s 0.0.0.0/0 -d your_ip_range -m state --state NEW -j DROP

you may want to consider giving a look to the:

Service Name and Transport Protocol Port Number Registry

to see which UDP services you may need to allow through.