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

相关推荐
HalvmånEver3 小时前
Linux:命名管道实现IPC(进程间通信七)
linux·运维·服务器·ipc·命名管道·管道pipe
正在学习前端的---小方同学9 小时前
Harbor部署教程
linux·运维
牛奔9 小时前
Docker Compose 两种安装与使用方式详解(适用于 Docker 19.03 版本)
运维·docker·云原生·容器·eureka
翼龙云_cloud10 小时前
阿里云渠道商:如何手动一键扩缩容ECS实例?
运维·服务器·阿里云·云计算
Sean X10 小时前
Ubuntu24.04安装向日葵
linux·ubuntu
墨风如雪10 小时前
拒绝被找回!MJJ必修课:Outlook邮箱交易后的“防回手”安全设置全攻略
服务器
DX_水位流量监测11 小时前
大坝安全监测之渗流渗压位移监测设备技术解析
大数据·运维·服务器·网络·人工智能·安全
电商API&Tina11 小时前
京东 API 数据采集接口接入与行业分析
运维·服务器·网络·数据库·django·php
IT 乔峰11 小时前
脚本部署MHA集群
linux·shell
dz小伟11 小时前
execve() 系统调用深度解析:从用户空间到内核的完整加载过程
linux