我们经常会发现,在linux上部署服务器,或者tomcat、nexus这样的服务时,明明部署上去了,但是访问确访问不了,这其中有很多种原因,最常见的,就是防火墙的问题。接下里,我把防火墙主要操作命令,都云集了下,环境大家参考!!
# 查看防火墙状态
systemctl status firewalld
# 启动防火墙
systemctl start/restart firewalld
# 停止防火墙 临时停用,重启后失效
systemctl stop firewalld
# 永久停止防火墙
systemctl disable firewalld
# 开机启动
systemctl enable firewalld
# 查看防火请端口
firewall-cmd --list-ports --临时端口
firewall-cmd --list-ports --permanent --永久端口
# 新增端口(之后一定要重载端口,否则配置无效)
firewall-cmd --zone=public --add-port=8080/tcp --permanent
#命令含义:
--zone #作用域
--add-port=8080/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效
# 移除端口(之后一定要重载端口,否则配置无效)
firewall-cmd --remove-port=8080/tcp --临时关闭
firewll-cmd --remove-port=8080/tcp --permanent --永久关闭
# 重载端口 执行【新增端口或者移除端口】后一定要执行该步骤,否则防火墙不生效(重启除外)
firewall-cmd --reload
# 查看防火墙是否开机启动
systemctl is-enabled firewalld
# 查看端口
netstat -ntlp --查看当前所有tcp端口
netstat -ntulp |grep 8080 --查看所有8080 端口使用情况

本文详细介绍了在Linux上部署服务器时遇到访问问题,通常是由于防火墙设置。文章汇总了常用防火墙操作命令,如查看状态、启动/停止、调整端口等,以帮助读者解决相关问题。

被折叠的 条评论
为什么被折叠?



