Quote:
Originally Posted by ysar68
I need to close all incoming ports from any ip and allow input packets in some port numbers ;
How i can make it this if make a chain with reject all i can put chain with accept for the ports i need ?
|
yeah, first set your policy to DROP, then make some ACCEPT rules for the stuff you need... packets that don't get sent to ACCEPT by any of your rules will get sent to DROP when they reach the end of the chain... for example:
Code:
# Set the INPUT policy to DROP:
iptables -P INPUT DROP
# Allow packets from connections related to established ones, packets
# from established ones, and packets from localhost:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
# Allow new connections to TCP ports 80 and 443:
iptables -A INPUT -p TCP -m multiport --dports 80,443 \
-m state --state NEW -j ACCEPT