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

相关推荐
像风一样自由20204 小时前
52.Docker部署大模型应用从本地开发到服务化运行
运维·人工智能·docker·容器·大模型·智能体
sxgzzn4 小时前
如何利用电缆故障定位在线监测系统提升供电安全?
运维·重构·无人机·开关柜局放在线监测·gis局放在线监测
曦夜日长4 小时前
Git系统篇,Git本地使用(一):从“究极进化版“到三个区域的底层原理
大数据·linux·git·elasticsearch
mengchanmian5 小时前
VSFTP 服务器搭建(Centos)
运维·服务器·centos
shimly1234565 小时前
给断网无 sudo ubuntu22.04 机器安装 nodejs
linux
别动我齐刘海6 小时前
Linux 系统调试学习1
linux·运维·服务器·c++·学习·机器学习·机器人
Lsetea6 小时前
OpenSSL报certificate chain too long:error 22与verify_depth深度排查
linux·https·ssl证书·openssl·证书链
不像程序员的程序媛7 小时前
linux常见文本操作命令
linux·运维·服务器
wangbing11258 小时前
开发指南149-IotDB-常用命令
linux·运维·iotdb
Dovis(誓平步青云)8 小时前
常用命令藏得太深?怎么做一个快捷命令坞
运维·前端·自动化·音视频·prometheus