Reverse proxy, duckdns.org and local network access.

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Wed Nov 27, 2024 20:49    Post subject: Reverse proxy, duckdns.org and local network access. Reply with quote
Already opened a topic here:
https://caddy.community/t/immich-duckdns-and-local-network-access/26489

So I have a duckdns address: ghi.duckdns.org (example name). I used caddy to setup a reverse proxy to access my Immich container outside of my network using the duckdns address. If I use that address inside my local network, the page does not load.

So I've read something about hairpin, but I have no clue how to set this up. I see something on the service page with hairpin, but then I'm lost.

Could someone help me out?

Hardware:
Netgear R7000
Build: 3.0-r55779
Sponsor
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Thu Nov 28, 2024 17:36    Post subject: Reply with quote
That's also known as NAT loopback. You can enable that feature on the Security->Firewall page by NOT checking the "WAN NAT Redirection" option.
_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Thu Nov 28, 2024 18:12    Post subject: Reply with quote
eibgrad wrote:
That's also known as NAT loopback. You can enable that feature on the Security->Firewall page by NOT checking the "WAN NAT Redirection" option.


That option was already set that way.



Schermafbeelding 2024-11-28 190622.png
 Description:
 Filesize:  44 KB
 Viewed:  16758 Time(s)

Schermafbeelding 2024-11-28 190622.png


eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Thu Nov 28, 2024 19:39    Post subject: Reply with quote
Try disabling SFE/CTF (NAT acceleration) on the Setup page. That "hack" is known to cause all kinds of weird problems. And I seem to recall the breaking of NAT loopback being one of them.

https://forum.dd-wrt.com/forum/viewtopic.php?t=335577

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Fri Nov 29, 2024 6:20    Post subject: Reply with quote
eibgrad wrote:
Try disabling SFE/CTF (NAT acceleration) on the Setup page. That "hack" is known to cause all kinds of weird problems. And I seem to recall the breaking of NAT loopback being one of them.

https://forum.dd-wrt.com/forum/viewtopic.php?t=335577


You are correct. With these settings disabled, it works. But this reduces my internet speed. Which is not ideal either.
No other options I could try?
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Fri Nov 29, 2024 18:53    Post subject: Reply with quote
Well you could map the domain name in DNSMasq, so when you're local, the name is resolved locally.

Code:
address=/somedomain.com/192.168.1.100


Of course, that limits you to a single target IP on your port forwards. But if that's all you need, it should work.

You might also consider NOT using port forwarding at all, and instead use something like Cloudflare tunnels. IOW, establish an *outbound* connection from your network to a public reverse proxy, from which you can tunnel back into your various service(s). This makes the issue of NAT loopback moot since you're always making public references to your services, regardless whether you're inside or outside the network hosting those services.

I suppose something like Tailscale or Zerotier could be used as well, but these are not quite as feature-rich as Cloudflare (there are others besides Cloudflare (e.g., Twingate); I'm only using them as an example).

Of course, this introduces a third-party and some additional complexity, but something like Cloudflare also provides additional benefits (managed certs, DDOS protection, MFA, geo-location filtering, etc.).

IOW, you might want to reconsider your overall approach here rather than remaining "old school" w/ traditional port forwarding and NAT loopback.

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Sat Nov 30, 2024 15:02    Post subject: Reply with quote
eibgrad wrote:
Well you could map the domain name in DNSMasq, so when you're local, the name is resolved locally.

Code:
address=/somedomain.com/192.168.1.100


Of course, that limits you to a single target IP on your port forwards. But if that's all you need, it should work.

You might also consider NOT using port forwarding at all, and instead use something like Cloudflare tunnels. IOW, establish an *outbound* connection from your network to a public reverse proxy, from which you can tunnel back into your various service(s). This makes the issue of NAT loopback moot since you're always making public references to your services, regardless whether you're inside or outside the network hosting those services.

I suppose something like Tailscale or Zerotier could be used as well, but these are not quite as feature-rich as Cloudflare (there are others besides Cloudflare (e.g., Twingate); I'm only using them as an example).

Of course, this introduces a third-party and some additional complexity, but something like Cloudflare also provides additional benefits (managed certs, DDOS protection, MFA, geo-location filtering, etc.).

IOW, you might want to reconsider your overall approach here rather than remaining "old school" w/ traditional port forwarding and NAT loopback.


I tried something like this, and also address=/ghi.duckdns.org/192.168.1.123, but that did not work.



Schermafbeelding 2024-11-30 160207.png
 Description:
 Filesize:  112.82 KB
 Viewed:  16607 Time(s)

Schermafbeelding 2024-11-30 160207.png


eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Sat Nov 30, 2024 18:00    Post subject: Reply with quote
You can NOT specify a port on a domain name. Domain names only resolve to an IP.

This is why I suggested something like Cloudflare, where you can *hide* your own public IP and the port behind a different FQDN!

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Sat Nov 30, 2024 18:08    Post subject: Reply with quote
eibgrad wrote:
You can NOT specify a port on a domain name. Domain names only resolve to an IP.

This is why I suggested something like Cloudflare, where you can *hide* your own public IP and the port behind a different FQDN!


That's why I have duckdns. It hides my public ip too. Or is that a wrong assumption?
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Sat Nov 30, 2024 18:13    Post subject: Reply with quote
Cyph3r2000 wrote:
eibgrad wrote:
You can NOT specify a port on a domain name. Domain names only resolve to an IP.

This is why I suggested something like Cloudflare, where you can *hide* your own public IP and the port behind a different FQDN!


That's why I have duckdns. It hides my public ip too. Or is that a wrong assumption?


Not if it's being updated w/ the WAN ip of your router! Which is typically the case. Anyone can easily use the dig or nslookup utilities to resolve your DDNS domain name and identify your public IP. In contrast, something like Cloudflare acts as a reverse proxy w/ its own domain name and public IP, which you can then map to *your* public IP and port(s), thus masking your public IP and port(s) from the end-user.

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Sat Nov 30, 2024 18:24    Post subject: Reply with quote
eibgrad wrote:
Cyph3r2000 wrote:
eibgrad wrote:
You can NOT specify a port on a domain name. Domain names only resolve to an IP.

This is why I suggested something like Cloudflare, where you can *hide* your own public IP and the port behind a different FQDN!


That's why I have duckdns. It hides my public ip too. Or is that a wrong assumption?


Not if it's being updated w/ the WAN ip of your router! Which is typically the case. Anyone can easily use the dig or nslookup utilities to resolve your DDNS domain name and identify your public IP. In contrast, something like Cloudflare acts as a reverse proxy w/ its own domain name and public IP, which you can then map to *your* public IP and port(s), thus masking your public IP and port(s) from the end-user.


I see. Just tried the dig utility and gave me my WAN ip indeed. Learned something here. Let's see what Cloudflare can do...
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Sat Nov 30, 2024 18:52    Post subject: Reply with quote
If something like Cloudflare is overkill for your needs, then you might want to consider using FT (FreshTomato) rather than DD-WRT. I know for a fact FT had the same problem w/ CTF and NAT loopback and that a fix has recently been added. I'm very familiar w/ it since I was involved w/ the OP that first reported it (he's even using the same R7000 router) and complained about the implementation (it works, I just don't like the way they did it).

https://www.linksysinfo.org/index.php?threads/r7000-fix-nat-loopback-with-ctf-enabled.78800/post-354247

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Sun Dec 01, 2024 15:20    Post subject: Reply with quote
eibgrad wrote:
If something like Cloudflare is overkill for your needs, then you might want to consider using FT (FreshTomato) rather than DD-WRT. I know for a fact FT had the same problem w/ CTF and NAT loopback and that a fix has recently been added. I'm very familiar w/ it since I was involved w/ the OP that first reported it (he's even using the same R7000 router) and complained about the implementation (it works, I just don't like the way they did it).

https://www.linksysinfo.org/index.php?threads/r7000-fix-nat-loopback-with-ctf-enabled.78800/post-354247


Ok, I'll look into it. I had some stability issues in the past with freshtomato, and DD-WRT has been great. But it's worth a try for my usecase. Is the above 'fix' in the 2024.4 release?
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9356

PostPosted: Sun Dec 01, 2024 16:30    Post subject: Reply with quote
When I tested it, I was using 2024.3, and have no reason to believe it's been removed. You'll quickly know if you enable CTF and dump the mangle table.

Only concern I have w/ 2024.4 is the following (which is unrelated to NAT loopback).

https://www.linksysinfo.org/index.php?threads/2024-4-possible-authenticated-samba-share-issue.78938/#post-354931

Several users are now reporting the same problem, so it appears to be a legitimate bug.

_________________
ddwrt-bind-static-routes-to-wan.sh (UPDATED! 11/12/24) * ddwrt-blacklist-domains.sh * ddwrt-dns-monitor.sh * ddwrt-ovpn-client-backup.sh * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-server-watchdog.sh * ddwrt-ovpn-split-advanced.sh * ddwrt-ovpn-split-basic.sh * ddwrt-mount-usb-drives.sh * ddwrt-wol-port-forward.sh
Cyph3r2000
DD-WRT Novice


Joined: 11 Oct 2023
Posts: 19

PostPosted: Sun Dec 01, 2024 17:02    Post subject: Reply with quote
eibgrad wrote:
When I tested it, I was using 2024.3, and have no reason to believe it's been removed. You'll quickly know if you enable CTF and dump the mangle table.

Only concern I have w/ 2024.4 is the following (which is unrelated to NAT loopback).

https://www.linksysinfo.org/index.php?threads/2024-4-possible-authenticated-samba-share-issue.78938/#post-354931

Several users are now reporting the same problem, so it appears to be a legitimate bug.


Then I'll skip for now. Samba needs to work. Thanks for the heads-up.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum