侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

CentOS 防火墙

2023-11-24 星期五 / 0 评论 / 0 点赞 / 43 阅读 / 2822 字

最近公工作需要使用新的服务器系统是CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用firewalld代替了原来的iptable

   最近公工作需要使用新的服务器系统是CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用firewalld代替了原来的iptables。

>>> 关闭防火墙

systemctl enable firewalld.service         #开机自动启动systemctl stop firewalld.service             #停止firewallsystemctl disable firewalld.service        #禁止firewall开机启动

>>> 开启端口

firewall-cmd --zone=public --add-port=80/tcp --permanent 命令含义:--zone #作用域--add-port=80/tcp #添加端口,格式为:端口/通讯协议--permanent #永久生效,没有此参数重启后失效


>>> 重启防火墙

firewall-cmd --reload

>>> 常用命令

firewall-cmd --list-ports                      ##已开端口列表    firewall-cmd --state                           ##查看防火墙状态,是否是runningfirewall-cmd --reload                          ##重新载入配置,比如添加规则之后,需要执行此命令firewall-cmd --get-zones                       ##列出支持的zonefirewall-cmd --get-services                    ##列出支持的服务,在列表中的服务是放行的#####################如果linux 使用ftp这里一定要配置######################################firewall-cmd --query-service ftp               ##查看ftp服务是否支持,返回yes或者nofirewall-cmd --add-service=ftp                 ##临时开放ftp服务firewall-cmd --add-service=ftp --permanent     ##永久开放ftp服务#####################如果linux 使用ftp这里一定要配置######################################firewall-cmd --remove-service=ftp --permanent  ##永久移除ftp服务firewall-cmd --add-port=80/tcp --permanent     ##永久添加80端口 iptables -L -n                                 ##查看规则,这个命令是和iptables的相同的

在centos 7中使用iptables防火墙配置后执行service iptables save 出现”Failed to restart iptables.service: Unit iptables.service failed to load: No such file or directory.”错误,在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,当然你可以还原传统的管理方式。或则使用新的命令进行管理。

systemctl stop firewalldsystemctl mask firewalld安装iptables-services:yum install iptables-services设置开机启动systemctl enable iptablessystemctl [stop|start|restart] iptables#orservice iptables [stop|start|restart]service iptables save


 

广告 广告

评论区