linux防火墙查看状态firewall、iptable

1、iptables防火墙

查看防火墙状态

service iptables status

停止防火墙

service iptables stop

启动防火墙

service iptables start

重启防火墙

service iptables restart

永久关闭防火墙

chkconfig iptables off

永久关闭后重启

chkconfig iptables on

开启80端口

vim /etc/sysconfig/iptables

加入一下代码

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

保存后退出后重启防火墙

service iptalbes restart

2、firewall 防火墙

查看防火墙

systemctl status firewalld

出现Active:active(running)切高亮显示则标识是启动状态

出现Active:inactive(dead)灰色表示停止,看单词也行。

查看firewall的状态

firewall -cmd --state

开启、重启、关闭、firewalld.service 服务

service firewalld start

service firewalld resatart

service firewalld stop

查看防火墙规则

firewall-cmd --list-all

查询、开放、关闭端口

查询端口是否开放

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

开发80端口

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

移除端口

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

重启端口

firewall-cmd --reload

CentOS7默认使用firewalld防火墙,如果想换回iptables防火墙,可关闭firewalld,安装iptables

关闭firewall

停止firewall

systemctl stop firewalld.service

禁止firewall开机启动

systemctl disable firewalld.service

查询默认防火墙状态

firewall-cmd --state

按照iptables-services

yum install iptables-services

重启防火墙

systemctl restart iptables.service

设置防火墙开机启动

systemctl enable iptables.service

相关推荐
DLYSB_16 分钟前
《从零开始搭建机房轻量化“声光告警”系统:基于 HTTP API 与 TTS 的运维实践》
运维·网络协议·http·报警灯
阿成学长_Cain17 分钟前
Linux talk 命令详解:经典终端实时聊天工具,无需图形界面即可对话
linux·运维·前端
一拳一个娘娘腔44 分钟前
【后渗透-Linux篇】Linux 提权与逃逸:从 www-data到 root的蜕变
linux·运维·服务器
jieyucx1 小时前
零基础通关:Shell 编程核心语法全景详解
linux·运维·编程·shell
杨运交1 小时前
[045][Crypto模块]设计一个可扩展的加解密框架:策略模式与工厂模式实战
linux·运维·策略模式
shx_wei1 小时前
从函数调用到进程替换:使用 execl、CMake 与 PowerShell 构建一个多可执行程序
linux·c语言·windows·c
Dlrb12111 小时前
信息查询Web服务器-->电子商城信息查询项目
linux·服务器·数据库·html·嵌入式·epoll·数据查询
纳兰青华1 小时前
在 PVE 上通过 LXC 部署 Ubuntu 24.04:为 OpenClaw 打造轻量高效的 AI 环境
linux·ai编程
Auv开心2 小时前
Ubuntu 20.04 默认视频播放器(Totem)无法播放 MP4 文件,通常是因为缺少多媒体编解码器。以下是几种解决方法:
linux·ubuntu·音视频