linux查看防火墙状态的方法有哪些


本文摘自PHP中文网,作者coldplay.xixi,侵删。

linux查看防火墙状态的方法:1、iptables防火墙,查看防火墙状态,代码为【service iptables status】;2、firewall防火墙,代码为【firewall-cmd --state】。

本教程操作环境:linux7.3系统,DELL G3电脑。

linux查看防火墙状态的方法:

一、iptables防火墙

1、基本操作

# 查看防火墙状态

1

service iptables status

# 停止防火墙

1

service iptables stop

# 启动防火墙

1

service iptables start

# 重启防火墙

1

service iptables restart

# 永久关闭防火墙

1

chkconfig iptables off

# 永久关闭后重启

1

chkconfig iptables on  

2、开启80端口

1

vim /etc/sysconfig/iptables

# 加入如下代码

1

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

保存退出后重启防火墙

1

service iptables restart

二、firewall防火墙

1、查看firewall服务状态

1

systemctl status firewalld

出现Active: active (running)切高亮显示则表示是启动状态。

出现Active: inactive (dead)灰色表示停止,看单词也行。

2、查看firewall的状态

1

firewall-cmd --state

3、开启、重启、关闭、firewalld.service服务

# 开启

1

service firewalld start

# 重启

1

service firewalld restart

# 关闭

1

service firewalld stop

4、查看防火墙规则

1

firewall-cmd --list-all

5、查询、开放、关闭端口

# 查询端口是否开放

1

firewall-cmd --query-port=8080/tcp

# 开放80端口

1

firewall-cmd --permanent --add-port=80/tcp

# 移除端口

1

firewall-cmd --permanent --remove-port=8080/tcp

#重启防火墙(修改配置后要重启防火墙)

1

firewall-cmd --reload

参数解释

1、firwall-cmd:是Linux提供的操作firewall的一个工具;

2、permanent:表示设置为持久;

3、add-port:标识添加的端口;

相关学习推荐:linux视频教程

以上就是linux查看防火墙状态的方法有哪些的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

Linux 系统查看用户组

Linux 配置多个tomcat需要注意的地方

Linux如何查看显卡驱动是否安装

详解Linux下文件的切分与合并方法

Linux环境在vmware下快速克隆多个的方法详解

Linux中的挂载是什么

Linux快速查找文件

Linux中开机启动程序或脚本的详细介绍

Linux怎么以u盘启动

Linux中解压zip文件出现乱码的解决方法有哪些

更多相关阅读请进入《Linux》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    正在狠努力加载,请稍候...