TFTP、IPTables 和 (s)-NAT 问题

TFTP、IPTables 和 (s)-NAT 问题

我在使用 IPtables 进行 NAT 后的 TFTP 下载时遇到了一些问题,我真的需要你的帮助。我熟悉网络原理,但对 IPtables 还很陌生,所以如果我做错了什么,我很抱歉。

我有一台运行 Ubuntu 20.04 的服务器,它有两个网卡,并尝试连接到 TFTP 服务器。虽然其他一切都运行正常,但在尝试 TFTP 时,我遇到了超时。根据 tcpdump,我有一种怀疑,我看到一些 icmp 流量(可能)没有正确转换,但我不确定。

拓扑信息

TFTP server: 130.221.69.14:udp\69
MyServer (TFTP-CLIENT) :
eth0 = uplink / 172.25.17.6
eth1 = downlink / 10.14.254.0/24 (Which NAT's to eth0 with config below)


IFACE_WAN=eth0
IFACE_LAN=eth1
NETWORK_LAN=10.14.254.0/24

... iptables 配置

echo "1" > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o $IFACE_WAN -s $NETWORK_LAN ! -d $NETWORK_LAN -j MASQUERADE
iptables -A FORWARD -d $NETWORK_LAN -i $IFACE_WAN -o $IFACE_LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s $NETWORK_LAN -i $IFACE_LAN -j ACCEPT

当在 eth1/$NETWORK_LAN (NAT 之前) 上执行 tcpdump 时,我看到:

我在这里看不到 ICMP 流量。

root@swmgmt:~# tcpdump -i eth1 -n  dst 130.221.69.14
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), capture size 262144 bytes
20:38:34.901901 IP 10.14.254.164.59384 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:38:38.897841 IP 10.14.254.164.59384 > 130.221.69.14.69:  38 RRQ "switch-config/by-    name/switch1" octet
20:38:43.899754 IP 10.14.254.164.59384 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:38:49.903083 IP 10.14.254.164.59384 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:38:56.907874 IP 10.14.254.164.59384 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:39:04.908915 IP 10.14.254.164.59384 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:39:12.909728 IP 10.14.254.164.59384 > 130.221.69.14.69:  23 ERROR EUNDEF "Session terminated"

当在 eth0/$NETWORK_WAN (NAT 之后)上执行 tcpdump 时,我看到:

我在这里看到了 icmp 流量?

20:21:31.898048 IP 172.25.17.6.59650 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:21:31.899090 IP 172.25.17.6 > 130.221.69.14: ICMP 172.25.17.6 udp port 59650 unreachable, length 55
20:21:39.024682 IP 172.25.17.6.59650 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:21:39.025524 IP 172.25.17.6 > 130.221.69.14: ICMP 172.25.17.6 udp port 59650 unreachable, length 55
20:21:47.029243 IP 172.25.17.6.59650 > 130.221.69.14.69:  38 RRQ "switch-config/by-name/switch1" octet
20:21:47.030220 IP 172.25.17.6 > 130.221.69.14: ICMP 172.25.17.6 udp port 59650 unreachable, length 55
20:21:55.030448 IP 172.25.17.6.59650 > 130.221.69.14.69:  23 ERROR EUNDEF "Session terminated"

任何帮助都将不胜感激!

真诚的 Tor。

答案1

您可能需要加载 tftp NAT 助手,因为 tftp 是不能与 NAT 很好地兼容的协议之一。

尝试modprobe nf_nat_tftp

注意:以上信息来自使用 nftables 的系统,而不是 iptables。您的情况可能会有所不同。无论如何,请尝试在目录下找到它,可能是在顶层的/lib/modules/<kernel-version>/kernel/net/子目录中或在 ipv4 或 ipv6 目录下。netfilter

相关内容