Linux Netfilter discussions
 help / color / mirror / Atom feed
* Redirect doesn't do the job as dnat does
@ 2023-11-05 14:58 Tech
  2023-11-05 15:27 ` Florian Westphal
  0 siblings, 1 reply; 6+ messages in thread
From: Tech @ 2023-11-05 14:58 UTC (permalink / raw)
  To: Netfilter list

Hi,

nftables v1.0.6 (Lester Gooch #5) on debian bookworm kernel 6.5 from 
unstable. Simple test

#!/bin/sh

sudo nft flush ruleset
sudo nft add table ip6 nat
sudo nft add chain ip6 nat prerouting { type nat hook prerouting 
priority 0 \; }
sudo nft add chain ip6 nat postrouting { type nat hook postrouting 
priority 100 \; }

#sudo nft add rule ip6 nat prerouting ip6 daddr 2001:db8::1 tcp dport { 
58194-58197 } dnat to :58198
#sudo nft add rule ip6 nat prerouting ip6 daddr 2001:db8::1 tcp dport { 
58194-58197 } dnat to [fd99:d:e:f::1]:58198

sudo nft add rule ip6 nat prerouting ip6 daddr 2001:db8::1 tcp dport 
58194 redirect to :58198 ; <= this one doesn't work

#sudo nft add rule ip6 nat prerouting ip6 daddr ::/0 tcp dport 58194 
dnat to :58198
#sudo nft add rule ip6 nat prerouting ip6 daddr ::/0 tcp dport 58194 
dnat to [fd99:d:e:f::1]:58198

in another terminal I run
nc -vl :: 58198
Listening on :: 58198

 From another computer
nc -v 2001:db8::1 58194
nc: connect to 2001:db8::1 port 58194 (tcp) failed: Connection timed out

As you see I never get input on port 58198 with redirect, also tested by 
activating forwarding like below but no luck
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding

Replacing the redirect rule with any on the 4 others rules above, I get 
the right behavior

nc -vl :: 58198
Listening on :: 58198
Connection received on 2001:db8:a:b::c 54748

nc -v 2001:db8::1 58194
Connection to 2001:db8::1 58194 port [tcp/*] succeeded!

Does it mean that redirect is broken or abandonned or did I miss something ?

-- 
Daniel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-11-08 10:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-05 14:58 Redirect doesn't do the job as dnat does Tech
2023-11-05 15:27 ` Florian Westphal
2023-11-05 15:55   ` Tech
     [not found]   ` <a7f19ab3-5fc8-4816-a403-9ae2a4b51358@tootai.net>
2023-11-08  9:33     ` Florian Westphal
2023-11-08  9:47       ` Tech
2023-11-08 10:18         ` Florian Westphal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox