Tag: web server

Basic iptables rules for linux web server

# Reset rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -j ACCEPT
# Allow ssh remote login
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Allow https
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Allow http
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow ping
iptables -A INPUT -p icmp -j ACCEPT
iptables -A INPUT -j REJECT
iptables -A FORWARD -j REJECT