0

how do i block a port on all IP's except 1?

say I have IP's:

192.168.1 192.168.2

ex: how would i only allow port 21 on 192.168.1 through IP tables or similar?

1 Answer 1

2

iptables supports the -d parameter for this:

iptables -A INPUT -p tcp -d 192.168.0.2 --dport 21 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -j DROP

This will allow traffic from all sources to IP 192.168.0.2 on port 21. The second line blocks all traffic on port 21. iptables works on a "first match" principle.

You must log in to answer this question.

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