Linux 服务器开启 firewalld 后,无法访问公网网站
Linux OS:CentOS 7
没有启动 iptables 服务,仅仅启动 firewalld 服务,启动后一开始能访问公网网站,大约 5 分钟后,无法访问公网网站。
能 ping 通公网网站域名
# firewall-cmd --list-all
public (default, active)
interfaces: eno1
sources:
services:
ports: 58426/tcp 80/tcp
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
# iptables -L -n
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
INPUT_direct all -- 0.0.0.0/0 0.0.0.0/0
INPUT_ZONES_SOURCE all -- 0.0.0.0/0 0.0.0.0/0
INPUT_ZONES all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED
ACCEPT all -- 0.0.0.0/0 0.0.0.0/0
FORWARD_direct all -- 0.0.0.0/0 0.0.0.0/0
FORWARD_IN_ZONES_SOURCE all -- 0.0.0.0/0 0.0.0.0/0
FORWARD_IN_ZONES all -- 0.0.0.0/0 0.0.0.0/0
FORWARD_OUT_ZONES_SOURCE all -- 0.0.0.0/0 0.0.0.0/0
FORWARD_OUT_ZONES all -- 0.0.0.0/0 0.0.0.0/0
ACCEPT icmp -- 0.0.0.0/0 0.0.0.0/0
REJECT all -- 0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
OUTPUT_direct all -- 0.0.0.0/0 0.0.0.0/0
Chain FORWARD_IN_ZONES (1 references)
target prot opt source destination
FWDI_public all -- 0.0.0.0/0 0.0.0.0/0 [goto]
FWDI_public all -- 0.0.0.0/0 0.0.0.0/0 [goto]
Chain FORWARD_IN_ZONES_SOURCE (1 references)
target prot opt source destination
Chain FORWARD_OUT_ZONES (1 references)
target prot opt source destination
FWDO_public all -- 0.0.0.0/0 0.0.0.0/0 [goto]
FWDO_public all -- 0.0.0.0/0 0.0.0.0/0 [goto]
Chain FORWARD_OUT_ZONES_SOURCE (1 references)
target prot opt source destination
Chain FORWARD_direct (1 references)
target prot opt source destination
Chain FWDI_public (2 references)
target prot opt source destination
FWDI_public_log all -- 0.0.0.0/0 0.0.0.0/0
FWDI_public_deny all -- 0.0.0.0/0 0.0.0.0/0
FWDI_public_allow all -- 0.0.0.0/0 0.0.0.0/0
Chain FWDI_public_allow (1 references)
target prot opt source destination
Chain FWDI_public_deny (1 references)
target prot opt source destination
Chain FWDI_public_log (1 references)
target prot opt source destination
Chain FWDO_public (2 references)
target prot opt source destination
FWDO_public_log all -- 0.0.0.0/0 0.0.0.0/0
FWDO_public_deny all -- 0.0.0.0/0 0.0.0.0/0
FWDO_public_allow all -- 0.0.0.0/0 0.0.0.0/0
Chain FWDO_public_allow (1 references)
target prot opt source destination
Chain FWDO_public_deny (1 references)
target prot opt source destination
Chain FWDO_public_log (1 references)
target prot opt source destination
Chain INPUT_ZONES (1 references)
target prot opt source destination
IN_public all -- 0.0.0.0/0 0.0.0.0/0 [goto]
IN_public all -- 0.0.0.0/0 0.0.0.0/0 [goto]
Chain INPUT_ZONES_SOURCE (1 references)
target prot opt source destination
Chain INPUT_direct (1 references)
target prot opt source destination
Chain IN_public (2 references)
target prot opt source destination
IN_public_log all -- 0.0.0.0/0 0.0.0.0/0
IN_public_deny all -- 0.0.0.0/0 0.0.0.0/0
IN_public_allow all -- 0.0.0.0/0 0.0.0.0/0
Chain IN_public_allow (1 references)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:58426 ctstate NEW
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 ctstate NEW
Chain IN_public_deny (1 references)
target prot opt source destination
Chain IN_public_log (1 references)
target prot opt source destination
Chain OUTPUT_direct (1 references)
target prot opt source destination
firewalld 的配置非常简单,仅仅打开 ports: 58426/tcp 80/tcp
大家给看看要如何排查
1
dode 2023-08-08 09:03:59 +08:00
防火墙启动后只会阻止新建连接,所以开始可能能打开,你关掉浏览器程序,重新试试,
你的电脑有几个网口? 把对外服务的网口更改为 public 区域 firewall-cmd --zone=public --change-interface=xxx --permanent |
2
LPLaser 2023-08-08 09:09:24 +08:00
可能是 outpu 指向的 chain 里没有规则然后就默认 drop 掉了?
可以试试先把 OUPUT 的策略清空试试 |
3
hutoer OP @dode 没用浏览器,使用的是 curl 命令行
服务器 2 个网口 访问公网的网口是在 public 区域的 firewall-cmd --get-active-zones public interfaces: eno1 |
5
dode 2023-08-08 09:33:41 +08:00
还有就是网站 80 等端口备案问题,你换 8000 ,81 比较一下
|
6
6bsLo69Qdu3RPY4c 2023-08-08 09:36:49 +08:00
发网址出来,让大家搜一下
|
7
gvdlmjwje 2023-08-08 09:38:47 +08:00 1
我就吐槽下 firewalld 的命令真是繁琐的一逼
|
9
ysc3839 2023-08-08 19:18:52 +08:00 via Android
|
10
ShallowAi 2023-08-08 20:45:05 +08:00
是无法入网(被访问)还是无法出网(向外 ping )?如果是无法入网需要检查是否备案,tcpping 指定 80 端口,不行再换个其他端口试试看。
一些其他说明:其实 firewalld 是个防火墙前端,底层调用 iptables (现在的实现是 nftables )。 |