1. Centos6 closes the firewall
1. service command
Turn off the firewall: service iptables stop
Open the firewall: service iptables start
Restart the firewall: service iptables restart
View firewall status: service iptables status
2. Operate through: /etc/init.d/iptables
Turn off the firewall: /etc/init.d/iptables stop (this is a temporary shutdown, the current firewall is turned off, and the firewall will start again after restarting, because it is self-starting at boot, which is equivalent to /etc/init.d /iptables start)
View firewall status: /etc/init.d/iptables/status
3. It needs to be changed to not start after booting, use the chkconfig command
Permanently turn off the firewall: chkconfig iptables off
Permanently turn on the firewall: chkconfig iptables on
View status: chkconfig --list iptables
2. The CentOS7 firewall uses firewall by default, which is different from the previous use of iptables.
1. Turn off the firewall
Instruction: systemctl stop firewalld.service
2. Turn on the firewall
Instruction: systemctl start firewalld.servicee
3. Turn off the boot and start the firewall
Instruction: systemctl disable firewalld.service
4. Boot up and start the firewall
Instruction: systemctl enable firewalld.service
5. Common port release
Release port 8080
# Release port 8080
firewall-cmd --zone=public --add-port=8080/tcp --permanent
# restart the firewall
firewall-cmd --reload
- -zone, scope
- -add-port=8080/tcp , add port, the format is: port/communication protocol
- -permanent, take effect permanently, without this parameter, it will fail after reboot
3. Centos8 closes the firewall
ystemctl status firewalld.service (view firewall status)
active indicates that the current firewall is on and inactive indicates that it is off
systemctl stop firewalld.service (turn off the firewall)
systemctl start firewalld.service (open firewall)
systemctl disable firewalld.service (prohibit the firewall from starting)
systemctl enable firewalld.service (the firewall starts with the system)