博客
关于我
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/

    你可能感兴趣的文章
    mysql problems
    查看>>
    MySQL replace函数替换字符串语句的用法(mysql字符串替换)
    查看>>
    mysql workbench6.3.5_MySQL Workbench
    查看>>
    MySQL Workbench安装教程以及菜单汉化
    查看>>
    MySQL Xtrabackup 安装、备份、恢复
    查看>>
    mysql [Err] 1436 - Thread stack overrun: 129464 bytes used of a 286720 byte stack, and 160000 bytes
    查看>>
    MySQL _ MySQL常用操作
    查看>>
    MySQL – 导出数据成csv
    查看>>
    MySQL —— 在CentOS9下安装MySQL
    查看>>
    mysql 不区分大小写
    查看>>
    mysql 两列互转
    查看>>
    MySQL 中开启二进制日志(Binlog)
    查看>>
    MySQL 中文问题
    查看>>
    MySQL 中日志的面试题总结
    查看>>
    MySQL 中随机抽样:order by rand limit 的替代方案
    查看>>
    MySQL 为什么需要两阶段提交?
    查看>>
    mysql 为某个字段的值加前缀、去掉前缀
    查看>>
    mysql 主从 lock_mysql 主从同步权限mysql 行锁的实现
    查看>>
    mysql 主从互备份_mysql互为主从实战设置详解及自动化备份(Centos7.2)
    查看>>
    mysql 主键重复则覆盖_数据库主键不能重复
    查看>>