article/centos_防火墙.md
2022-08-28 09:57:48 +08:00

29 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

• 查看防火墙状态命令执行后响应结果包含active (running) 表示防火墙是开启状态。如果防火墙没有开启,可以使用后文中的命令开启防火墙。
\>systemctl status firewalld
• 查看已开放端口:该命令会列出防火墙所有对外开放访问的端口的信息
\>firewall-cmd --list-all
• 防火墙开放某个端口kafka服务端口为9092
\>firewall-cmd --zone=public --add-port=9092/tcp --permanent
success
命令含义:
zone: 作用域
add-port=9092/tcp: 添加端口,格式为:端口/通讯协议
permanent: 永久生效,没有此参数重启后失效
• 开放端口后需重载防火墙配置,这样新开放的端口才能生效
\>firewall-cmd --reload
Success
• 如果决定收回某些端口的开放权限,执行下列命令
firewall-cmd --zone=public --remove-port=10050/tcp;firewall-cmd --runtime-to-permanent;firewall-cmd --reload;
• firewalld的linux其他基本操作
• 启动防火墙: systemctl start firewalld
• 关闭防火墙: systemctl stop firewalld
• 查看防火墙状态: systemctl status firewalld
• 开机禁用 systemctl disable firewalld
• 开机启用 systemctl enable firewalld