Centos-防火墙操作

Centos6

关闭防火墙

server iptablesd stop

开启防火墙

server iptablesd start

保存防火墙配置

server iptablesd save

关闭开机启动

chkconfig iptables off

开启开机启动

chkconfig iptables on

开启谋个端口(2231)

iptables -I INPUT -p tcp –dport 2231 -j ACCEPT

iptables -I OUTPUT -p tcp –dport 2231 -j ACCEPT

Centos7

关闭防火墙

systemctl stop firewalld

开启防火墙

systemctl start firewalld

关闭开机启动

systemctl disable firewalld

开启开机启动

systemctl enable firewalld

开启某个端口(2231)

firewall-cmd –zone=public –add-port=2231/tcp –permanent

firewall-cmd –reload

查询端口号2231 是否开启:

firewall-cmd –query-port=2231/tcp

查询有哪些端口是开启的:

firewall-cmd –list-port

原创文章,作者:Safeidc,如若转载,请注明出处:https://www.safeidc.cn/2020/12/centos-firewall.html

发表评论

邮箱地址不会被公开。