centos 7 开启80,443端口,怎么弄?

一、查看系统防火墙状态(如果返回 running 代表防火墙启动正常)

复制代码
1 firewall-cmd --state

二、开启端口外网访问

1、添加端口 返回 success 代表成功(--permanent永久生效,没有此参数重启后失效)

复制代码
(1)firewall-cmd --zone=public --add-port=80/tcp --permanent
(2)firewall-cmd --zone=public --add-port=443/tcp --permanent
  
(3) 开放多个端口
  firewall-cmd --zone=public --add-port=80-85/tcp --permanent

2、重新载入 返回 success 代表成功

复制代码
(1)firewall-cmd --reload

3、查看 返回 yes 代表开启成功

复制代码
(1) firewall-cmd --zone=public --query-port=80/tcp

三、关闭端口

1、删除端口 返回 success 代表成功

复制代码
(1)firewall-cmd --zone=public --remove-port=80/tcp --permanent

2、重新载入 返回 success 代表成功

复制代码
(1) firewall-cmd --reload

四、基本操作

1、启动服务:systemctl start firewalld.service

2、关闭服务:systemctl stop firewalld.service

3、重启服务:systemctl restart firewalld.service

4、显示服务的状态:systemctl status firewalld.service

5、开机自动启动:systemctl enable firewalld.service

6、禁用开机自动启动:systemctl disable firewalld.service

7、查看版本: firewall-cmd --version

8、查看帮助: firewall-cmd --help

9、显示状态: firewall-cmd --state

10、查看所有打开的端口: firewall-cmd --zone=public --list-ports

11、更新防火墙规则: firewall-cmd --reload

12、查看区域信息: firewall-cmd --get-active-zones

13、查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

14、拒绝所有包:firewall-cmd --panic-on

15、取消拒绝状态: firewall-cmd --panic-off

16、查看是否拒绝: firewall-cmd --query-panic

相关推荐
chlk1231 天前
Linux文件权限完全图解:读懂 ls -l 和 chmod 755 背后的秘密
linux·操作系统
舒一笑1 天前
Ubuntu系统安装CodeX出现问题
linux·后端
改一下配置文件1 天前
Ubuntu24.04安装NVIDIA驱动完整指南(含Secure Boot解决方案)
linux
碳基沙盒1 天前
OpenClaw 多 Agent 配置实战指南
运维
xy123061 天前
OpenStack Train 部署实战(三)控制节点--keystone服务
centos·openstack
深紫色的三北六号2 天前
Linux 服务器磁盘扩容与目录迁移:rsync + bind mount 实现服务无感迁移(无需修改配置)
linux·扩容·服务迁移
SudosuBash2 天前
[CS:APP 3e] 关于对 第 12 章 读/写者的一点思考和题解 (作业 12.19,12.20,12.21)
linux·并发·操作系统(os)
哈基咪怎么可能是AI2 天前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
十日十行3 天前
Linux和window共享文件夹
linux
木心月转码ing3 天前
WSL+Cpp开发环境配置
linux