博客
关于我
CentOS 7-firewall-cmd基本命令
阅读量:610 次
发布时间:2019-03-13

本文共 2425 字,大约阅读时间需要 8 分钟。

一、firewall-cmd基本命令
1. 系统ctl相关
# 查看防火墙状态systemctl status firewalld# 开启防火墙systemctl start firewalld# 停止防火墙systemctl stop firewalld#禁用防火墙systemctl disable firewalld# 设置开机自启systemctl enable firewalld# 检查服务状态systemctl is-enabled firewalld.service
2. firewall-cmd信息查询
# 查看当前防火墙配置firewall-cmd --list-all# 查看防火墙版本firewall-cmd --version# 查看帮助文档firewall-cmd --help# 查询防火墙状态firewall-cmd --state# 查询当前默认区域firewall-cmd --get-default-zone# 列出所有区域firewall-cmd --get-zones# 修改默认区域firewall-cmd --set-default-zone=区域名称# 查看开放的端口firewall-cmd --zone=公网区域 --list-ports# 查询特定端口状态firewall-cmd --zone=公网区域 --query-port=80/tcp# 查看可用的服务firewall-cmd --list-services# 查询支持的服务类型firewall-cmd --get-service# 查看是否启用了伪装IP功能firewall-cmd --query-masquerade# 启用伪装IP功能firewall-cmd --add-masquerade# 禁用伪装IP功能firewall-cmd --remove-masquerade# 查看活动区域firewall-cmd --get-active-zones# 查看特定接口所属区域firewall-cmd --get-zone-of-interface=eth0# 拒绝所有数据包firewall-cmd --panic-on# 停止拒绝状态firewall-cmd --panic-off# 查询防火墙是否处于拒绝状态firewall-cmd --query-panic# 查看公网区域中的规则firewall-cmd --zone=公网区域 --list-rich-rules
3. firewall-cmd基本配置
# permanent Fluxclild Firewall规则以配置文件形式存储在 /etc/firewalld/zones/区域名称.xml
# 添加端口
firewall-cmd --zone=公网区域 --add-port=80/tcp --permanent
firewall-cmd --zone=公网区域 --add-port=100-500/tcp --permanent
firewall-cmd --zone=公网区域 --remove-port=80/tcp --permanent
firewall-cmd --zone=公网区域 --remove-port=100-500/tcp --permanent
# 添加服务
firewall-cmd --zone=公网区域 --add-service=http --permanent
firewall-cmd --zone=公网区域 --remove-service=http --permanent
# 转发流量
firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080
firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.1.0.1
firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.1.0.1:toport=8080
#限制访问规则
firewall-cmd --permanent --zone=公网区域 --add-rich-rule='rule family="ipv4" source address="192.168.0.4/24" service name="http" accept'
firewall-cmd --permanent --zone=公网区域 --remove-rich-rule='rule family="ipv4" source address="192.168.0.4/24" service name="http" accept'
firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=192.168.0.1/2 port port=80 protocol=tcp accept'
firewall-cmd --permanent --remove-rich-rule 'rule family=ipv4 source address=192.168.0.1/2 port port=80 protocol=tcp accept'
firewall-cmd --permanent --add-source=172.25.254.102 --zone=信任区域
# 重新加载防火墙规则
firewall-cmd --reload
firewall-cmd --complete-reload
firewall-cmd --runtime-to-permanent

转载地址:http://ohbaz.baihongyu.com/

你可能感兴趣的文章
Python:将列表列表初始化为一定大小,
查看>>
Python:带有生成器的给定集合的幂集
查看>>
Python:按字符的位置拆分字符串
查看>>
Python:替换嵌套字典中的值
查看>>
Python:爬取数据出现response.status_code为403解决方法
查看>>
Python:爬取数据出现response.status_code为418解决方法
查看>>
Python:生成“元组集“;来自“元组列表“;不考虑顺序
查看>>
Python:生成具有趋势的随机时间序列数据(例如周期性、指数衰减等)
查看>>
Python:用渐进式数字重命名列表中的重复项而不对列表进行排序
查看>>
Python:矩形参数无效
查看>>
Python:语法进阶
查看>>
Python:调用复制函数时调用 Python 对象时超出了最大递归深度
查看>>
Python:这两个 import 语句有什么区别?
查看>>
Python:通过串口从 Velleman k8090 读取数据
查看>>
python:遍历具有列表值的字典
查看>>
Python:降低精度 pandas 时间戳数据帧
查看>>
python:非阻塞子进程,检查标准输出
查看>>
PythonABC多重继承
查看>>
Pythonargparse中的多个参数
查看>>
Python关于 *args 和 **kwargs 参数的详解(全)
查看>>