Answer the question
In order to leave comments, you need to log in
How to properly close everything and open only the necessary (incoming / outgoing) iptables and debian?
Hello.
Can you please tell me how to properly close all incoming and outgoing ports on Debian using iptables, except for the 5-6 necessary ones?
That is, we close everything (outgoing and incoming), except, for example, 21,22,25,80,81,443. Ports should also work both incoming and outgoing.
Answer the question
In order to leave comments, you need to log in
# Разрешит локалный траффик
iptables -A INPUT -i lo -j ACCEPT
# Разрешит пинг
iptables -A INPUT -p icmp -j ACCEPT
# разрешит порты 21,22,25,80,81,443
iptables -A INPUT -p tcp -m multiport --port 21,22,25,80,81,443 -j ACCEPT
# Разрешит сессии
iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# ну и запретит все остальное
iptables -A INPUT -j DROP
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question