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

相关推荐
袁小皮皮不皮20 小时前
1.HCIP BFD 学习笔记(优化版)
服务器·网络·笔记·网络协议·学习·智能路由器·ip
vsropy21 小时前
Ubuntu网络图标消失问题/有网络问号
linux·运维·ubuntu
fofantasy21 小时前
NSK LH12AN 微型导轨技术手册
运维·网络·数据库·经验分享·规格说明书
coderwu21 小时前
Ubuntu 24.04 终端输入 openclaw config 提示未找到命令解决办法
linux·运维·ubuntu
dxxt_yy21 小时前
千兆光/电口+OTDR一体——成都鼎讯 SZT-1000A 千兆以太网测试仪助力风电能源光缆管理
运维·服务器·能源
tedcloud1231 天前
taste-skill部署教程:打造个性化AI推荐工作流
服务器·前端·人工智能·系统架构·edge
凡人叶枫1 天前
Effective C++ 条款28:避免使用 handles 指向对象内部
linux·服务器·开发语言·c++·嵌入式开发
AI帮小忙1 天前
Debian系linux操作系统里安装OpenClaw
linux·运维·debian
极创信息1 天前
Linux挖矿病毒深度清理实战教程,从进程隐藏、Rootkit驻留到彻底根除
java·大数据·linux·运维·安全·tomcat·健康医疗
志栋智能1 天前
超自动化巡检剧本(Playbook):运维经验的数字化封装
运维·自动化