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

admin3年前主机评测123

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(linux)如何查看时区和修改设置时区时间方法

centos7如何查看时区和修改设置时区方法?centos7中查看时区的方法有二种:方法一:1、打开centos7终端;2、在centos7终端命令行中输入“timedatectl | grep “T...

详解linux为阿里云ECS(CentOS7)配置IPv6地址

环境为:ecs“经典网络”类型步骤:1. 编辑 /etc/sysctl.conf 文件,将其中三条禁用ipv6的设置更改为:?123net.ipv6.conf.all.disable_ipv6 = 0...

CentOS 7如何修改SSH端口号的图文教程

CentOS 7如何修改ssh端口号?我们都知道Linux服务器一般SSH默认端口是22,但从安全方面考虑,建议修改默认端口号。那么,怎么修改ssh端口号呢?本文主要为大家分享在CentOS 7修改S...

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

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

Centos7关闭默认防火墙firewall和启用iptables操作

centos7如何关闭默认防火墙firewall?关闭了默认防火墙后,我们如何启用iptables防火墙呢?在使用Docker时,启用centos7默认的firewall,启动端口映射时,防火墙规则不...

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

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