Note: Ubuntu/debian cannot use this method
1. Open Iptables
Vi/etc/sysconfig/iptables
2. Add firewall rules
Rule reference: http://www.cnblogs.com/EasonJim/p/6847874.html
#Firewall configuration written by System-config-firewall# Manual Customization of this file is notRecommended.*filter: INPUTACCEPT [0:0] : FORWARDACCEPT [0:0] : OUTPUTACCEPT [0:0]-A input-m State–state established,related-j accept-a input-p icmp-j accept-a input-i lo-j ACCEPT -A input-m state–state new-m tcp-p tcp– Dport 22-j accept-a input-m state–state new-m tcp-p tcp–dport 80-j accept-a input-m state–state new-m tcp-p TCP –dport 3306 -j ACCEPT -A input-j reject–reject-with icmp-host-prohibited-a forward-j reject–reject-with icmp-host-p rohibited COMMIT
3. Firewall is in effect
Service Iptables Restart
Linux configuration Firewall Add port (Ubuntu/debian cannot use this method)