一些数据包在到达防火墙之前被阻止

一些数据包在到达防火墙之前被阻止

我有一个应用程序正在监听端口 20514:

$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 192.168.100.213:20514   0.0.0.0:*                           3629/python3

我可以使用 tcpdump 查看进入我计算机的数据包

$ sudo tcpdump -i enp0s25 -n -N udp port 20514
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s25, link-type EN10MB (Ethernet), capture size 262144 bytes
15:54:56.832307 IP 172.18.248.3.514 > 192.168.100.213.20514: SYSLOG user.critical, length: 111

iptables(此时)允许一切。请注意,它不会报告任何与来自 172.18.248.0/28 的规则匹配的数据包,尽管我们在上面看到了一个。在任何转换中,-P INPUT 都是 ACCEPT

$ sudo iptables -L -v
Chain INPUT (policy ACCEPT 134 packets, 79373 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     tcp  --  any    any     192.168.100.0/24     anywhere             tcp dpt:ssh
 4745  282K ACCEPT     tcp  --  any    any     10.8.0.0/24          anywhere             tcp dpt:ssh
    0     0 ACCEPT     all  --  any    any     172.18.248.0/28      anywhere

Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 533 packets, 89933 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain DOCKER (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain DOCKER-ISOLATION-STAGE-1 (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain DOCKER-ISOLATION-STAGE-2 (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain DOCKER-USER (0 references)
 pkts bytes target     prot opt in     out     source               destination

Chain LOGACCEPT (0 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 LOG        all  --  any    any     anywhere             anywhere             LOG level info prefix "INPUT:ACCEPT:"
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere

因此看起来,数据包在进入接口之后但在到达防火墙之前就被阻止了。

我还能在哪里查看为什么进入我的机器的数据包没有到达应用程序?

答案1

问题原来是 Docker 与网络建立的接口与数据包的源地址重叠。

尽管我已经清除了 docker 在 IPtables 中制定的所有规则,但最终我还是不得不更改 /etc/docker/daemon.json 以在不同的 IP 范围内启动网络。然后,我删除了所有容器并删除了 Docker 创建的所有网络。可能有一种破坏性较小的方法来完成删除 docker 网络接口,但我没有附加任何东西。

此后数据包就开始通过。因此似乎是网络接口本身造成了干扰。

相关内容