Linux Netfilter discussions
 help / color / mirror / Atom feed
* Why is it impossible to DNAT 127.0.0.0/8?
@ 2021-04-27  7:04 Quentin, Lars
       [not found] ` <CAPJdpdCcsRuMnh433VHNmeZof+7wyWy6K2s1BzTtT5+vrwvx=g@mail.gmail.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Quentin, Lars @ 2021-04-27  7:04 UTC (permalink / raw)
  To: netfilter@vger.kernel.org

Hey,

For the last few days I tried to DNAT a port on localhost to a local VM living inside a virtual bridge network.
I got it working using the external IP with a OUTPUT rule in the NAT table, as it can't be done via PREROUTING:
`iptables -t nat -A OUTPUT -p tcp --dport 8080 -d <MY_IP> -j DNAT --to-destination 192.168.1.2:80`
which allows me to `curl <MY_IP>:8080`.

I'd expect that it `curl localhost:8080` would work with something like this:
`iptables -t nat -A OUTPUT -p tcp -o lo --dport 8080 -d localhost -j DNAT --to-destination 192.168.1.2:80`
but this just results in packages getting stuck.

After reading a lot I found [1] which tries to define it as a feature to conform the RFCs 5735/1700/1812.
Is this really the only reason or is it technically impossible due to sth like the limitations of `lo` since it is not a real device?
I feel way to much of a novice to navigate the kernel source.

Cheers
Lars Quentin

[1]: https://serverfault.com/questions/363899/iptables-dnat-from-loopback



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

end of thread, other threads:[~2021-04-28 22:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-27  7:04 Why is it impossible to DNAT 127.0.0.0/8? Quentin, Lars
     [not found] ` <CAPJdpdCcsRuMnh433VHNmeZof+7wyWy6K2s1BzTtT5+vrwvx=g@mail.gmail.com>
     [not found]   ` <CAPJdpdDkJ7VP_TdAYAyGruC5aT5BvpviKRajeQxf5+3aae_Zig@mail.gmail.com>
2021-04-28 22:03     ` Paul Robert Marino

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