I have a peculiar situation.

I need to block all outbound connections to subnet but allow connections to subnet.

How can I do this using iptables on Ubuntu 20.04?


1 Answer 1


iptables executes rules from top to bottom, so first you add the rule to allow outbound connections to, and then you add the rule to deny the outbound connections to

I think something like this will work:

iptables -A OUTPUT -d -j ACCEPT
iptables -A OUTPUT -d -j DROP

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .