Centos7防火墙基本操作:开启/关闭/重启防火墙
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