CentOS 7.4 enables remote access with Iptables
CentOS 7 uses firewall as its firewall by default. Install iptables Firewall first.
1. Close firewall:
Systemctl stop firewalld.service
Systemctl disable firewalld.service
Systemctl mask firewalld.service
2. Install iptables firewall
Yum install iptables-services-y
3. Start the setup firewall
# systemctl enable iptables
# systemctl start iptables
4. View firewall status
Systemctl status iptables
5 Editing the firewall and adding ports
Vi / etc/sysconfig/iptables # Editing Firewall profile
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 22-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT
-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 3306-j ACCEPT
: wq! # Save exit
3. Restart the configuration, restart the system
Systemctl restart iptables.service # restart the firewall to make the configuration effective
Systemctl enable iptables.service # set the firewall to boot