This question already has an answer here:
I am trying to only allow port 22 TCP/UDP and port 80 TCP/UDP from anywhere using Fedora 15
iptables, and all the rest will be never accessible nor scannable from a public network.
But it never works for me, at the end I turned it off because I am scared it will block me to access even the port 22 myself.
So, my question is, how can I do this in Fedora 15? Block all except for 22, 80 TCP/UDP?
iptables -P INPUT ACCEPT # Fresh start iptables -F # Localhost/ethernet 0 / yum installation allow iptables -A INPUT -i lo -j ACCEPT iptables -A INPUT -i eth0 -j ACCEPT iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT # SSH iptables -A INPUT -p tcp –dport 22 -j ACCEPT #iptables -A INPUT -s aa.bb.aa.bb -d xx.yy.xx.yy -p tcp -m tcp –dport 22 -j ACCEPT iptables -A INPUT -d xx.yy.xx.yy -p tcp -m tcp –dport 22 -j ACCEPT # other iptables -P INPUT DROP iptables -P FORWARD DROP iptables -P OUTPUT ACCEPT # show iptables -L -v