Linux firewall防火墙 换成 iptables 防火墙

一、firewalld 增加开放端口

firewall-cmd --zone=public --add-port=16010/tcp --permanent

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

重启防火墙

systemctl restart firewalld.service

二、iptables 增加开放端口

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables 

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效

 systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。

三、将firewalld防火墙换成iptables

1、直接关闭防火墙

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables 

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

 systemctl restart iptables.service #重启防火墙使配置生效

 systemctl enable iptables.service #设置防火墙开机启动

最后重启系统使设置生效即可。

文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/9489

(0)
郭靖的头像郭靖
上一篇 2023年8月9日 下午3:51
下一篇 2023年8月10日 下午4:45

相关推荐

  • CentOS 7下安装配置Tomcat

    CentOS 7下安装配置Tomcat 环境:CentOS 7.9 Tomcat下载地址:http://down.cnaaa.net/static/upload/other/20220802/1659432295529455.rar 安装rz工具 创建Tomcat目录 通用rz工具,将安装包上传 解压文件 修改目录名Tomcat8 没有JDK安装JDK 目录…

    2022年8月2日
    1.3K00
  • Docker常用命令

    列出所有容器ID 查看所有运行或者不运行容器 停止所有的container(容器),这样才能够删除其中的images: 如果想要删除所有container(容器)的话再加一个指令: 查看当前有些什么images 删除images(镜像),通过image的id来指定删除谁 想要删除untagged images,也就是那些id为的image的话可以用 要删除全…

    2022年11月19日
    1.1K00
  • Centos7 使用nvm配置 多Node.js环境

    背景 新项目 使用Node.js-v16.17.1 旧项目 使用Node.js- v14.18.0 【且依赖于node-saas模块,根据 node-sass 的官方文档,目前最新版本的 node-sass(即 v5.0.0)支持的 Node.js 版本范围是 Node.js 10.x、Node.js 12.x、Node.js 14.x。并没有明确支持 No…

    2023年5月10日
    1.4K00
  • 安装linux/Centos系统出现An Unknown Error Has Occurred报错原因和解决方法

    今天在给一个客户重装系统的时候出现: An Unknown Error Has OccurredThis program has encountered an unknown error. You may report the buy below or quit the program. This program has encountered an unk…

    2024年3月25日
    1.6K00
  • smokeping修改Ping间隔和Ping包数量

    1、复制 所有带*.dist 2、修改httpd.conf 配置文件 3、修改 /usr/local/smokeping/etc/config

    2022年11月26日
    1.4K00

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

在线咨询: QQ交谈

邮件:712342017@qq.com

工作时间:周一至周五,8:30-17:30,节假日休息

关注微信