Centos7防火墙操作
侧边栏壁纸
博主昵称
yuc

  • 累计撰写 291 篇文章
  • 累计收到 0 条评论

Centos7防火墙操作

yuc
yuc
2022-01-11 / 最后修改: 2023-06-01 08:55 / 0 评论 / 866 阅读 / 正在检测是否收录...
firewall常用操作
服务启停
service firewalld stop && chkconfig firewalld off
service firewalld start
开放端口&重载配置
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --reload

参数解析

--zone=public
--permanent  配置持久化但不会立即生效
--add-port  配置端口和协议
--reload  重载配置
根据ip开放或者限制
方式1: firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.1.100" port port=8080 protocol=tcp accept'
方式2: firewall-cmd --permanent --zone=public --add-rich-rule='rule family=ipv4 source address=192.168.1.100 port port=8080 protocol=tcp accept'

参数解析

--add-rich-rule 添加规则,具体ip,协议,端口等
--remove-rich-rule 删除规则
动作:
  accept 允许
  drop 丢弃
  reject 拒绝
使用iptables

Centos7默认使用firewalld,如果使用多了Centos6可能对命令不是很习惯,那么可以安装iptables使用

yum -y install iptables-services
service iptables save
0

评论

博主关闭了当前页面的评论