#! /Bin/bash # Clear the original firewall rules iptables-F # Save the firewall configuration service iptables save # Stop the Firewall Service iptables stop # Open the SSH firewall iptables-A input-p tcp -- dport 22- j accept # Open Database firewall rules iptables-A input-s 192.168.3.0/24-p tcp -- dport 3306-J accept # Open firewall rules iptables-A input-M state -- state related, established-J accept # Open Ping firewall rule iptables-A input-p icmp-J accept # the default rule for firewall incoming is dropiptables-P input drop # the default rule for firewall outgoing traffic is dropiptables-P ouput. accept # Save the firewall configuration service iptables save # restart the Firewall Service iptables restart
Note: The port to be opened to the local machine can be added to the script content in the open port 22 format. After the script is successfully added, execute the script.
This article from the "Chengdu @ A like" blog, please be sure to keep this source http://azhuang.blog.51cto.com/9176790/1440167
Common iptables template Configuration