Turn off firewall
CentOS 7
、RedHat 7
Firewall on and off in previous Linux distributions(iptables
):
Immediate effect, restartinvalid
#Open
service iptables start
#Shut down
service iptables stop
restart
take effect
#Open
chkconfig iptables on
#Shut down
chkconfig iptables off
CentOS 7
、RedHat 7
Firewall on and off for subsequent Linux distributions(firewall
):
systemctl stop firewalld.service
Open port
CentOS 7
、RedHat 7
Previous Linux distributions open ports
#Command mode open 5212 port command
#Open port 5212 to receive data
/sbin/iptables -I INPUT -p tcp --dport 5212 -j ACCEPT
#Open port 5212 to send data
/sbin/iptables -I OUTPUT -p tcp --dport 5212 -j ACCEPT
#Save configuration
/etc/rc.d/init.d/iptables save
#Restart firewall service
/etc/rc.d/init.d/iptables restart
#Check whether it is opened successfully
/etc/init.d/iptables status
CentOS 7
、RedHat 7
Subsequent Linux distributions open ports
firewall-cmd --zone=public --add-port=5121/tcp --permanent
#-- zone scope
#-- add port = 5121 / TCP add port, format: port / communication protocol
#-- permanent takes effect permanently. Without this parameter, it will become invalid after restart