0

I have a peculiar situation.

I need to block all outbound connections to 10.0.0.0/8 subnet but allow connections to 10.20.20.0/24 subnet.

How can I do this using iptables on Ubuntu 20.04?

0

1 Answer 1

3

iptables executes rules from top to bottom, so first you add the rule to allow outbound connections to 10.20.20.0/24, and then you add the rule to deny the outbound connections to 10.0.0.0/8.

I think something like this will work:

iptables -A OUTPUT -d 10.20.20.0/24 -j ACCEPT
iptables -A OUTPUT -d 10.0.0.0/8 -j DROP

You must log in to answer this question.

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