美文网首页
CentOS 7 防火墙

CentOS 7 防火墙

作者: 星际大镖客 | 来源:发表于2018-09-26 23:16 被阅读0次

CentOS 7.0以上版本默认使用的是firewall作为防火墙。

#查看默认防火墙是否运行
[root@localhost ~]# firewall-cmd --state
not running 
  • 检查防火墙的状态:
[root@localhost ~]# systemctl status firewalld.service
firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; 
disabled; 
vendor preset: enabled)
Active: inactive (dead) 
  • 常用命令
[root@localhost ~]# systemctl stop firewalld.service 
# 关闭防火墙
[root@localhost ~]# systemctl disable firewalld.service
 #禁止开机启动
[root@localhost ~]# systemctl is-enabled firewalld.service;echo $? 
#查看服务是否开机启动
[root@localhost ~]# systemctl list-unit-files|grep enabled 
#查看已启动的服务列表
  • 师爷翻译翻译 什么TMD的叫惊喜,给各位老爷翻译翻译。
命令 中文翻译
systemctl start firewalld 别烦我
systemctl stop firewalld 快撩我
systemctl enable firewalld 开启高冷模式
systemctl disable firewalld 彻底放飞自我
systemctl restart firewalld 我胡汉三又回来啦
  • 查看已经开放的端口
firewall-cmd --list-ports
  • 开启端口
firewall-cmd --zone=public --add-port=22/tcp --permanent
  • 查询指定端口
firewall-cmd --permanent --query-port=22/tcp
  • 删除端口
 firewall-cmd --zone=public --remove-port=22/tcp --permanent 
  • 一顿操作猛如虎,可别忘记了 最重要的一步 让你的操作立刻生效哦。
firewall-cmd --reload或firewall-cmd --complete-reload

相关文章

网友评论

      本文标题:CentOS 7 防火墙

      本文链接:https://www.haomeiwen.com/subject/gxhsoftx.html