Iptables is used in CentOS 7 and iptables is used in centos 7.
1. Disable firewall
Systemctl stop firewalld. service # stop firewallsystemctl disable firewalld. service # disable firewall startup
2. Install iptables Firewall
# Install yum install iptables-services
3. Edit the firewall configuration file
vim /etc/sysconfig/iptables
Display:
# sample configuration for iptables service# you can edit this manually or use system-config-firewall# please do not ask us to add additional ports/services to this default configuration*filter:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT-A INPUT -p icmp -j ACCEPT-A INPUT -i lo -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 20 -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-prohibitedCOMMIT
: Wq! # Save and exit
Systemctl restart iptables. service # restart the firewall to make the configuration take effect. systemctl enable iptables. service # Set the firewall to start upon startup.
4. Disable SELINUX.
vim /etc/selinux/config
# SELINUX = enforcing # comment out # SELINUXTYPE = targeted # comment out SELINUX = disabled # Add
: Wq! # Save and exit
Setenforce 0 # Make the configuration take effect immediately