博客
关于我
linux 防火墙操作
阅读量:801 次
发布时间:2023-02-02

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

iptables防火墙 & firewall防火墙操作指南

1. iptables防火墙基本操作

查看防火墙状态

可以通过以下命令检查防火墙状态:

service iptables status

这将显示防火墙的运行状态和相关服务信息。

停止防火墙

要停止防火墙,可以使用以下命令:

service iptables stop

此时防火墙将停止响应新规则,现有连接将继续存在。

启动防火墙

重启防火墙服务:

service iptables start

如果防火墙处于已停止状态,启动后它将开始接收新连接。

重启防火墙

重启防火墙的方法有两种:

  • 使用service iptables restart命令直接重启
  • 使用chkconfig命令保存配置并重启:
  • chkconfig iptables offchkconfig iptables on

    永久关闭防火墙

    如果不再需要防火墙,可以永久关闭:

    chkconfig iptables off

    关闭后重新启动服务时,防火墙将不会再启动。

    2. 查看防火墙状态

    当防火墙处于开启状态时,仅开放22端口。系统管理员应定期检查防火墙状态,确保规则正确无误。

    3. 开启80端口

    要开启HTTP协议的80端口,可以编辑iptables配置文件:

    vim /etc/sysconfig/iptables

    在文件末尾添加以下规则:

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

    保存文件后,重启防火墙服务:

    service iptables restart

    firewall防火墙操作指南

    1. 查看firewall服务状态

    查看firewalld服务状态:

    systemctl status firewalld

    2. 查看防火墙状态

    使用以下命令查看防火墙实时状态:

    firewall-cmd --state

    3. 操作firewalld服务

    • 启用firewalld服务:
    service firewalld start
    • 重新启动firewalld服务:
    service firewalld restart
    • 停止firewalld服务:
    service firewalld stop

    4. 查看防火墙规则

    列出所有防火墙规则:

    firewall-cmd --list-all

    5. 端口管理

    查询端口状态

    检查特定端口状态:

    firewall-cmd --query-port=8080/tcp

    开放端口

    永久开放指定端口:

    firewall-cmd --permanent --add-port=80/tcp

    关闭端口

    移除已开放的端口:

    firewall-cmd --permanent --remove-port=8080/tcp

    重新加载防火墙

    修改配置后,重启防火墙:

    firewall-cmd --reload

    参数说明

    • firewall-cmd:Linux的火墙管理命令。
    • --permanent:表示更改将保存到服务里。
    • --add-port:用于添加端口规则,--remove-port用于移除。

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

    你可能感兴趣的文章
    mysql5.7 安装版 表不能输入汉字解决方案
    查看>>
    MySQL5.7.18主从复制搭建(一主一从)
    查看>>
    MySQL5.7.19-win64安装启动
    查看>>
    mysql5.7.19安装图解_mysql5.7.19 winx64解压缩版安装配置教程
    查看>>
    MySQL5.7.37windows解压版的安装使用
    查看>>
    mysql5.7免费下载地址
    查看>>
    mysql5.7命令总结
    查看>>
    mysql5.7安装
    查看>>
    mysql5.7性能调优my.ini
    查看>>
    MySQL5.7新增Performance Schema表
    查看>>
    Mysql5.7深入学习 1.MySQL 5.7 中的新增功能
    查看>>
    Webpack 之 basic chunk graph
    查看>>
    Mysql5.7版本单机版my.cnf配置文件
    查看>>
    mysql5.7的安装和Navicat的安装
    查看>>
    mysql5.7示例数据库_Linux MySQL5.7多实例数据库配置
    查看>>
    Mysql8 数据库安装及主从配置 | Spring Cloud 2
    查看>>
    mysql8 配置文件配置group 问题 sql语句group不能使用报错解决 mysql8.X版本的my.cnf配置文件 my.cnf文件 能够使用的my.cnf配置文件
    查看>>
    MySQL8.0.29启动报错Different lower_case_table_names settings for server (‘0‘) and data dictionary (‘1‘)
    查看>>
    MYSQL8.0以上忘记root密码
    查看>>
    Mysql8.0以上重置初始密码的方法
    查看>>