欢迎光临散文网 会员登陆 & 注册

Linux | Linux防火墙指令

2022-06-10 15:21 作者:信盈达  | 我要投稿

下面是red hat/CentOs7关闭防火墙的命令:

1:查看防火状态

systemctl status firewalld

service iptables status

2:暂时关闭防火墙

systemctl stop firewalld

service iptables stop

3:永久关闭防火墙

systemctl disable firewalld

chkconfig iptables off

4:重启防火墙

systemctl enable firewalld

service iptables restart

5:永久关闭后重启

//暂时还没有试过

chkconfig iptables on


1、开放和关闭端口

firewall-cmd --zone=public --add-port=9200/tcp --permanent # 开放端口

firewall-cmd --zone=public --remove-port=9200/tcp --permanent # 关闭端口

firewall-cmd --reload # 重新载入配置,让开放或关闭的端口配置生效


–zone=public:表示作用域为公共

–permanent:表示永久生效


2、查看端口开放情况

firewall-cmd --zone=public --list-ports # 查询端口开放列表

firewall-cmd --zone=public --query-port=9200/tcp # 查询具体端口是否开放


firewall-cmd --version # 查看版本

firewall-cmd --help # 查看帮助

firewall-cmd --state # 查看运行状态


下面是centos6关闭防火墙的命令:

1、开放端口命令:iptables -A INPUT -p tcp -m tcp --dport 端口 -j ACCEPT

2、指定ip开放端口:iptables -I INPUT -s 地址 -p tcp --dport 端口 -j ACCEPT

3、禁止指定ip访问:iptables -A INPUT -p tcp -s 地址 -j DROP

4、临时关闭防火墙:service iptables stop

5、重启防火墙:service iptables restart

6、永久关闭:chkconfig iptables off

7、开机自启:chkconfig iptables on

8、禁ping:iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP

9、解除禁ping:iptables -D INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP


版权声明:版权归原作者所有,如有侵权,请联系删除。

原文链接:Linux防火墙指令_京天不下雨的博客-CSDN博客

原文链接:Linux防火墙命令_抓不住风的博客-CSDN博客_linux防火墙命令

Linux | Linux防火墙指令的评论 (共 条)

分享到微博请遵守国家法律