CentOS:
首先查看防火墙状态:
service iptables status
永久性生效,重启后不会复原
开启:
chkconfig iptables on
关闭:
chkconfig iptables off
即时生效,重启后复原
开启:
service iptables start
关闭:
service iptables stop
设置后重启:reboot
临时关闭防火墙
systemctl stop firewalld
永久关闭防火墙的开机自启动
systemctl disable firewalld
临时打开防火墙
systemctl start firewalld
防火墙开机启动
systemctl enable firewalld
查看防火墙状态
CentOS7开启和关闭端口
开启2333端口
firewall-cmd –zone=public –add-port=2333/tcp –permanent
更新防火墙规则使刚刚添加的2333端口生效
firewall-cmd –reload
查看开放的端口列表
firewall-cmd –list-ports
关闭2333端口
firewall-cmd –zone=public –remove-port=2333/tcp –permanent
更新防火墙规则使用刚刚删除的端口关闭
firewall-cmd –reload