iptables DNAT:“没有该名称的链/目标/匹配”

iptables DNAT:“没有该名称的链/目标/匹配”

我尝试在新的自定义 Linux 目标上使用 DNAT,但在使用以下基本命令时出现错误:

#iptables -t nat -A PREROUTING -d 10.110.0.250 -p tcp --dport 9090 -j DNAT --to 10.110.0.239:80
$iptables: No chain/target/match by that name.

我认为所有模块都已正确加载:

# lsmod  | grep ip
ipt_MASQUERADE 1686 1 - Live 0xbf15c000
iptable_nat 2396 1 - Live 0xbf150000
nf_conntrack_ipv4 11354 1 - Live 0xbf149000
nf_defrag_ipv4 1331 1 nf_conntrack_ipv4, Live 0xbf145000
nf_nat_ipv4 3401 1 iptable_nat, Live 0xbf141000
nf_nat 13364 4 ipt_MASQUERADE,xt_nat,iptable_nat,nf_nat_ipv4, Live 0xbf138000
nf_conntrack 72079 6 ipt_MASQUERADE,xt_conntrack,iptable_nat,nf_conntrack_ipv4,nf_nat_ipv4,nf_nat, Live 0xbf11b000
ip_tables 10836 1 iptable_nat, Live 0xbf114000
x_tables 16429 4 ipt_MASQUERADE,xt_conntrack,xt_nat,ip_tables, Live 0xbf10a000

转发处于活动状态:

# cat /proc/sys/net/ipv4/ip_forward
1

strace没有给我有关该问题的任何线索:

# ...
socket(PF_LOCAL, SOCK_STREAM, 0)        = 3
bind(3, {sa_family=AF_LOCAL, sun_path=@"xtables"}, 10) = 0
socket(PF_INET, SOCK_RAW, IPPROTO_RAW)  = 4
fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
getsockopt(4, SOL_IP, 0x40 /* IP_??? */, "nat\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., [84]) = 0
getsockopt(4, SOL_IP, 0x41 /* IP_??? */, "nat\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., [992]) = 0
setsockopt(4, SOL_IP, 0x40 /* IP_??? */, "nat\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1264) = -1 ENOENT (No such file or directory)
close(4)                                = 0
write(2, "iptables: No chain/target/match "..., 46iptables: No chain/target/match by that name.
) = 46
exit_group(1)                           = ?
+++ exited with 1 +++

出了什么问题?

[编辑]

我发现如果我删除目标端口,该命令就可以工作

iptables -t nat -A PREROUTING -d 10.110.0.250 -p tcp -j DNAT --to 10.110.0.239:80

[/编辑谢谢。

答案1

问题是缺少模块XT_TCPUDP

我的命令有动态加载模块的完整列表:

xt_nat 1527 1 - Live 0xbf12f000
xt_tcpudp 1961 1 - Live 0xbf12b000
iptable_nat 2396 1 - Live 0xbf127000
nf_conntrack_ipv4 11354 1 - Live 0xbf120000
nf_defrag_ipv4 1331 1 nf_conntrack_ipv4, Live 0xbf11c000
nf_nat_ipv4 3401 1 iptable_nat, Live 0xbf118000
nf_nat 13364 3 xt_nat,iptable_nat,nf_nat_ipv4, Live 0xbf10f000
nf_conntrack 72079 4 iptable_nat,nf_conntrack_ipv4,nf_nat_ipv4,nf_nat, Live 0xbf0f2000
ip_tables 10836 1 iptable_nat, Live 0xbf0eb000
x_tables 16429 3 xt_nat,xt_tcpudp,ip_tables, Live 0xbf0e1000

相关内容