Tuesday, July 23, 2024

Debian/AlmaLinux/Rocky Linux开放防火墙端口

换用Debian/AlmaLinux/Rocky Linux系统后,无法通过SSH连接服务器,发现在启动firewalld后SSH端口默认是关闭的,所以需要开放相应的SSH端口。

添加需要开放的端口(以8001端口为例)

firewall-cmd --zone=public --add-port=8001/tcp --permanent

命令含义:
–zone #作用域
–add-port=8001/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效

重启防火墙

firewall-cmd --reload

查看防火墙端口是否开放

firewall-cmd --list-ports

查看防火墙端口是否开放(适用于所有Linux系统)

netstat -tuln

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.