Centos7防火墙基本操作:开启/关闭/重启防火墙

admin3年前主机评测148

centos7防火墙如何操作?

centos7防火墙么查看状态,以及开启、关闭、重启防火墙乖行。firewall-cmd 是 firewalld 的主要命令行工具。它可用于获取有关 firewalld 的状态信息,获取运行时和永久环境的防火墙配置以及更改这些配置。

查看防火墙

1.查看防火墙此时运行状态。方式有两种具体如下:

[root@localhoststudent]#firewall-cmd--state[root@localhoststudent]#systemctlstatusfirewalld

2.查看防火墙是否开机自启。

[root@localhoststudent]#systemctlis-enabled

3.查看接口区域,这里以ens33为例。

[root@localhoststudent]#firewall-cmd--get-zone-of-interface=ens33public

4.查看绑定区域的接口。

[root@localhoststudent]#firewall-cmd--get-active-zonesdockerinterfaces:docker0publicinterfaces:ens33

5.查看所有开放端口。

root@zq-virtual-machine:/home/zq#netstat-aptn

1.执行

systemctl start firewalld.service

命令开启防火墙,默认是开启的。

[root@localhoststudent]#systemctlstartfirewalld.service

1.执行

systemctl stop firewalld.service

命令关闭防火墙。

[root@localhoststudent]#systemctlstopfirewalld.service

1.执行

systemctl restart firewalld.service

命令重启防火墙。

[root@localhoststudent]#systemctlrestartfirewalld.service

1.执行

systemctl enable firewalld.service

命令设置防火墙开机自启。

[root@localhoststudent]#systemctlenablefirewalld.service

临时打开端口

1.执行

firewall-cmd –zone=public –add-port=80/tcp

命令打开80/tcp。这里需要注意,这是临时的打开端口,重启后无效。

[root@localhoststudent]#firewall-cmd--zone=public--add-port=80/tcp

2.执行

systemctl restart firewalld.service

命令重启防火墙。

[root@localhoststudent]#systemctlrestartfirewalld.service

注意:当开放端口设置完成后必须要重启,否则不生效!!!

永久打开端口

1.执行

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

命令永久打开80/tcp。

[root@localhoststudent]#firewall-cmd--permanent--zone=public--add-port=80/tcp

2.执行

systemctl restart firewalld.service

命令重启防火墙。

[root@localhoststudent]#systemctlrestartfirewalld.service

注意:当开放端口设置完成后必须要重启,否则不生效!!!

临时打开服务

1.执行

firewall-cmd –zone=public –add-service=http

命令公共区域中临时打开服务HTTP。

[root@localhoststudent]#firewall-cmd--zone=public--add-service=http

永久打开服务

1.执行

firewall-cmd –permanent –zone=public –add-service=http

命令公共区域中临时打开服务HTTP。

[root@localhoststudent]#firewall-cmd--permanent--zone=public--add-service=http

免责声明:本文内容来自用户上传并发布,站点仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。请核实广告和内容真实性,谨慎使用。

相关文章

centos7中如何使用关机命令、重启命令

centos7中如何使用关机命令、重启命令?CentOS 7.0中可以使用命令对服务器进行重启、关机等操作。今天,小编给大家介绍关于centos7如何使用命令重启或关机,希望对需要的朋友有所帮助!关机...

CentOS7安装iptables防火墙(禁用/停止自带的firewalld服务)

centos7如何安装iptables防火墙?本篇文章主要介绍了centos7安装iptables防火墙的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。不仅有安装iptables防火墙的命...

centos7云服务器如何使用firewalld防火墙

centos7云服务器使用firewalld防火墙的方法:1、打开centos7云服务器终端控制台;2、输入“systemctl status firewalld”命令查看firewalld状态来检查...

centos7防火墙firewalld的安装与使用_技术文档

centos7防火墙firewalld如何安装?防火墙能有效的过滤掉非授权端口的请求,是保障服务器的第一步。在centos里可以安装诸多防火墙软件,诸如firewalld、iptables、ufw等,...

centos7如何查看firewall防火墙状态:开启/关闭/重启防火墙_技术文档

centos7如何查看firewall防火墙状态?systemctl status firewalld.service 运行上述命令后,如果看到有绿色字样标注的“active(running)”,说明...

linux系统之centos7系统重启/查看/自动启动SSH等操作命令

Linux系统作为一个开源的操作系统,服务于大中小企业。那么,作为一个服务器系统它的稳定性是要求非常高的,但是在使用中出现无法远程但系统是正常服务的情况,下面介绍CentOS系统的云服务器中如何重启、...