From: "Quentin, Lars" <lars.quentin@stud.uni-goettingen.de>
To: "netfilter@vger.kernel.org" <netfilter@vger.kernel.org>
Subject: Why is it impossible to DNAT 127.0.0.0/8?
Date: Tue, 27 Apr 2021 07:04:54 +0000 [thread overview]
Message-ID: <4da21aab607c40b08c3e1343ca003244@stud.uni-goettingen.de> (raw)
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
next reply other threads:[~2021-04-27 7:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-27 7:04 Quentin, Lars [this message]
[not found] ` <CAPJdpdCcsRuMnh433VHNmeZof+7wyWy6K2s1BzTtT5+vrwvx=g@mail.gmail.com>
[not found] ` <CAPJdpdDkJ7VP_TdAYAyGruC5aT5BvpviKRajeQxf5+3aae_Zig@mail.gmail.com>
2021-04-28 22:03 ` Why is it impossible to DNAT 127.0.0.0/8? Paul Robert Marino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4da21aab607c40b08c3e1343ca003244@stud.uni-goettingen.de \
--to=lars.quentin@stud.uni-goettingen.de \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox