Enable iptables firewall in CentOS 7.0
In order to configure the firewall, the author cannot find the iptables service until a certain moment! I found that I use CentOS 7.0, and this version of firewall uses firewall by default, which is different from the previous version using iptables. This is very important!
Therefore, to configure the firewall and enable the port, you can use the following method:
1. Disable firewall:
Systemctl stop firewalld. service # stop firewall
Systemctl disable firewalld. service # disable firewall startup
2. Install iptables Firewall
Yum install iptables-services # Installation
The next step is the same as using iptables. If you want to enable a port, (port 80, for example, red indicates the added rule ):
Vi/etc/sysconfig/iptables
-A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT # Allow port 80 to pass the Firewall
############################ The following figure shows the added firewall rules #### ##########################
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [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-j REJECT -- reject-with icmp-host-prohibited
-A forward-j REJECT -- reject-with icmp-host-prohibited
COMMIT
-------------------------------------- Split line --------------------------------------
Iptables examples
Iptables-packet filtering (Network Layer) Firewall
Linux Firewall iptables
Iptables + L7 + Squid implements a complete software firewall
Basic use of iptables backup, recovery, and firewall scripts
Detailed description of firewall iptables usage rules in Linux
-------------------------------------- Split line --------------------------------------