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

相关推荐
En^_^Joy31 分钟前
Nginx 从入门到精通:配置、原理与实战详解
运维·nginx
玖石书1 小时前
WSL2 手动安装 Ubuntu 24.04 到指定磁盘位置
linux·运维·ubuntu·wsl
库玛西2 小时前
深入浅出传输层:UDP 与 TCP 协议全景指南
linux·服务器·网络·c++·笔记·tcp/ip·udp
随便做点啥2 小时前
32卡-64G-910B4-16后端-(Qwen3.8-27B-W8A8)集群部署报告
运维·服务器·经验分享·docker·vllm
薛定谔的悦5 小时前
储能 EMS 的功率策略:从一块电表到一次逆流的 200 毫秒
大数据·linux·能源·储能·bms
2601_962218478 小时前
万象生鲜系统区块链溯源技术帮助生鲜企业搭建食品安全数字化体系
大数据·运维·微服务·云原生·架构
智塑未来8 小时前
中小公司在线文档选型:从协作入口到安全边界
运维·安全
新时代牛马8 小时前
Linux 内核入门地图:架构、源码目录与五大子系统
linux·运维·架构
智购科技无人售货机厂家8 小时前
2026自动售货机制冷系统维护指南:从散热器清洁到压缩机换油的工程实践~YH
运维·redis·物联网·缓存·架构
剑客的茶馆9 小时前
开发者,运维怎样转行FDE?
运维·ai·开发·fde