This question already has an answer here:

I'm getting swamped with outbound udp requests and it's blocking my internet connection. While I figure out what's going on I'd like to block all outbound and inbound udp. I'm connecting via pppoe dial up but want to block on all ports and all connections. Is there a way to do this that won't interrupt my pppoe connection? I've tried updating iptables but this seems to only block one port at a time if I understand correctly. Though I have rules in my firewall to block the ports it seems to be too late.

For newbies like me it is difficult to get the pieces together and I couldn't find the answer on searching because didn't know to search for iptables and that doesn't cover the udp component. I have my question answered by think this should remain open for others as I believe it might be helpful.

marked as duplicate by muru, Zanna, Charles Green, Eric Carvalho, Eliah Kagan Jan 6 '17 at 18:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • iptables -A OUTPUT -p udp -j DROP? – muru Jan 6 '17 at 5:23
  • thanks so much, that seems to have worked - at least I didn't get an error. I appreciate that. I'm going to reboot and monitor. – user637251 Jan 6 '17 at 5:39
  • If you reboot, the rule will be lost - you'll have to add it again. – muru Jan 6 '17 at 5:42
  • This will also block DNS @muru Port 53 needs to remain open. – Fabby Jan 6 '17 at 8:30
  • @Fabby DNS can be TCP as well - it doesn't have to UDP: serverfault.com/q/181956/229499 – muru Jan 6 '17 at 8:32

To just block outgoing UDP connections irrespective of port, don't specify a port. Just specify the protocol:

iptables -A OUTPUT -p udp -j DROP

The same applies for TCP (-p tcp).

  • Thanks @muru you saved me a lot of time trying to find various tips! – user637251 Jan 6 '17 at 15:09

Not the answer you're looking for? Browse other questions tagged or ask your own question.