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

相关推荐

  • mysql5.7忘记密码时,修改root密码

    推荐方法二 方法一: 1、修改mysql 配置文件,添加 skip-grant-tables vim /etc/my.cnf [myslqd] ……………….skip-grant-tables……………….…

    2023年3月7日
    1.2K00
  • CentOS 7 安装 JDK 11

    现在很多编译器和软件都开始要求使用 JDK 11 了。 因此我们希望在 CentOS 上安装 JDK 11。 运行下面的命令: 如果你的系统中还装有不同版本的 JDK 的话。你需要运行: 来选择默认的 JDK。 随后你就可以验证安装的 JDK 了。

    2023年3月11日
    1.1K00
  • MySQL数据库数据对比工具——Mysqldbcompare

    MySQL Utilities介绍 MySQL Utilities 提供一组命令行工具用于维护和管理 MySQL 服务器,包括: 管理工具 (克隆、复制、比较、差异、导出、导入) 复制工具 (安装、配置) 一般工具 (磁盘使用情况、冗余索引、搜索元数据) MySQL Utilities是一系列的命令行工具以及python库更容易完成管理的任务。库是用Pyth…

    2023年5月4日
    1.7K00
  • Zabbix 监控SSL证书到期时间

    监控脚本: [root@fxkj devops]# vim /home/zabbix/etc/zabbix_agentd.conf.d/check_ssl.sh #!/bin/bash #获取证书的有效时间 time=$(echo | openssl s_client -connect $1:443 2>/dev/null | openssl x509…

    2023年3月6日
    1.6K00
  • find命令排除某些目录或文件

    使用-prune开关。例如,如果要排除misc目录,只需将a添加-path ./misc -prune -o到您的find命令中: find . -path ./misc -prune -false -o -name ‘*.txt’ 这是带有多个目录的示例: find . -type d \( -path dir1 -o -path dir2 -o -pat…

    2023年6月16日
    1.5K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信