#! /Bin/bash # Clear the firewall iptables-Fiptables-X # disable the INPUT and FPRWARD chains, allow OUTPUT chain iptables-p input DROPiptables-p output ACCEPTiptables-p forward accept # enable 22 ssh port iptables-a input-p tcp -- dport 22-j ACCEPT # enable 80 web port iptables -a input-p tcp -- dport 80-j ACCEPT # enable 3306 mysql port iptables-a input-p tcp -- dport 3306-j ACCEPT # enable 9000 php-fpm port iptables- INPUT-p tcp -- dport 9000-j ACCEPT # enable port 111 and port 25 iptables-a input-p tcp -- dport 110-j ACCEPTiptables-a input-p tcp -- dport 25- j ACCEPT # enable the 11211 memcached port iptables-a input-p tcp -- dport 11211-j ACCEPT # enable the 161 and 162 SNMP ports iptables-a input-p tcp -- dport 161-j ACCEPTiptables -a input-p tcp -- dport 162-j ACCEPT # enable the 873 rsync port iptables-a input-p tcp -- dport 873-j ACCEPT # enable the ping port iptables-a input-p icmp-j ACCEPT # Allow the ESTABLISHED link iptables-a input-m state -- state ESTABLISHED, RELATED-j ACCEPT # Allow the return port iptables-a input-I lo-j ACCEPTiptables-A OUTPUT-o lo-j ACCEPT