一、开启特定端口命令
1.检查防火墙是否开启(需要开启防火墙)
#查看防火墙状态命令: systemctl status firewalld #启动防火墙命令: systemctl start firewalld #关闭防火墙命令: systemctl stop firewalld
2.开放指定端口(开发端口后需要重启防火墙才生效)
firewall-cmd --add-port=443/tcp --zone=public --permanent #命令含义: #–add-port=1935/tcp #添加端口,格式为:端口/通讯协议 #–zone #作用域 #–permanent #永久生效,没有此参数重启后失效 #关闭指定端口 # firewall-cmd --remove-port=443/tcp --zone=public --permanent
3.更新防火墙规则
firewall-cmd --reload
4.查询端口是否开启
#查询端口命令(yes表示开启,no表示关闭): firewall-cmd --query-port=443/tcp #查看所有已开放端口: firewall-cmd --list-all
二、常用命令
firewalld的基本使用 二、常用操作命令 #启动: systemctl start firewalld #关闭: systemctl stop firewalld #查看状态: systemctl status firewalld #开机禁用 : systemctl disable firewalld #开机启用 : systemctl enable firewalld ※systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。 #启动一个服务: systemctl start firewalld.service #关闭一个服务: systemctl stop firewalld.service #重启一个服务: systemctl restart firewalld.service #显示一个服务的状态: systemctl status firewalld.service #在开机时启用一个服务: systemctl enable firewalld.service #在开机时禁用一个服务: systemctl disable firewalld.service #查看服务是否开机启动: systemctl is-enabled firewalld.service #查看已启动的服务列表: systemctl list-unit-files|grep enabled #查看启动失败的服务列表: systemctl --failed #配置 firewalld-cmd #查看版本: firewall-cmd --version #查看帮助: firewall-cmd --help #显示状态: firewall-cmd --state #查看所有打开的端口: firewall-cmd --zone=public --list-ports #查看区域信息: firewall-cmd --get-active-zones #查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0 #拒绝所有包: firewall-cmd --panic-on #取消拒绝状态: firewall-cmd --panic-off # 查看是否拒绝: firewall-cmd --query-panic
本文来自博客园,作者:东方飘雪,转载请注明原文链接:https://www.cnblogs.com/zdyang/p/17484160.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库