当前位置: 首页 > news >正文

linux防火墙和开放端口命令

一、firewalld防火墙:

1.firewalld的基本使用
启动: systemctl start firewalld

查状态: systemctl status firewalld

停止: systemctl stop firewall

禁用: systemctl disable firewalld

在开机时启用一个服务:systemctl enable firewalld.service

在开机时禁用一个服务:systemctl disable firewalld.service

查看服务是否开机启动:systemctl is-enabled firewalld.servic

查看已启动的服务列表:systemctl list-unit-files|grep enabled

查看启动失败的服务列表:systemctl --failed

2.查询端口是否开放: firewall-cmd --query-port=80/tcp

开放80端口: firewall-cmd --permanent --add-port=80/tcp

移除端口:firewall-cmd --permanent --remove-port=8080/tcp

查看开放了那些端口: firewall-cmd --list-ports

重启防火墙(修改配置后要重启防火墙): firewall-cmd --reload

二、iptables防火墙

1、基本操作

查看防火墙状态: service iptables status

停止防火墙: service iptables stop

启动防火墙 :service iptables start

重启防火墙 : service iptables restart

永久关闭防火墙: chkconfig iptables off

永久关闭后重启: chkconfig iptables on

2、开启80端口

vim /etc/sysconfig/iptables

加入如下代码

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

保存退出后重启防火墙

service iptables restart

相关文章:

  • MySQL--MHA高可用方案
  • 宏auto关键字(C++基础)
  • GPT-4技术解析:与Claude3、Gemini、Sora的技术差异与优势对比
  • linux循环之until循环
  • 2023年度总结报告
  • 【并查集】一种简单而强大高效的数据结构
  • Spring Boot 生成与解析Jwt
  • Qt区分左右Shift按键
  • Python爬虫——Urllib库-3
  • 基于chatgpt的聊天机器人
  • 如何保证 HTTPS 证书的有效性?
  • SpringCloud2023最新版本该如何进行组件选型?
  • 飞桨(PaddlePaddle)Tensor使用教程
  • TensorFlow
  • 总结虚拟机的安装步骤:
  • Swift SwiftUI 学习笔记 2024
  • 【AI绘画】免费GPU Tesla A100 32G算力部署Stable Diffusion
  • 认识事物的几个阶段 GPU学习
  • HarmonyOS—配置编译构建信息
  • 利用Python爬取高德地图全国地铁站点信息
  • 2024年上市公司合计实现营业收入71.98万亿元
  • 美联储宣布维持基准利率不变
  • 李干杰走访各民主党派中央和全国工商联机关
  • 川大全职引进考古学家宫本一夫,他曾任日本九州大学副校长
  • “五一”假期银联、网联共处理支付交易234.39亿笔
  • “五一”假期预计全社会跨区域人员流动量累计14.67亿人次