this post was submitted on 17 Sep 2023
752 points (97.6% liked)

Programmer Humor

32453 readers
361 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] mxd2@lemmy.world 5 points 1 year ago* (last edited 1 year ago) (6 children)

Well, that's something I can't do, I just can't access my public IP if I'm connected to it. Any ideas? Is it something related to my router, or my ISP?

[–] Album@lemmy.ca 14 points 1 year ago* (last edited 1 year ago) (1 children)

Enable nat loopback on your router

[–] averagedrunk@lemmy.ml 6 points 1 year ago

May be called hairpinning depending on the device.

[–] Chreutz@lemmy.world 7 points 1 year ago (2 children)

The client will look up your domain at whatever DNS it uses. It will return your public IP.

Client will send a packet with that as destination. It will reach the router which goes 'I know! The call is coming from inside the house!' and sends it to the server without modification.

The server gets it and sends a response, but the response is addressed back to client's local IP.

Client gets the response, but that packet's origin (in the header) is server's local IP.

Client goes 'wtf, I didn't call you?!' And drops the packet, still waiting for a response with your public IP as its origin.

This can be solved with the router modifying the appropriate traffic's headers so that the headers match the expected, called NAT Loopback, or by using IPv6 global addresses.

It might also work running a local DNS server that returns your server's local IP for a given domain, but that might yield certificate errors, and won't work if devices ignore the DNS coming from DHCP.

I was using straight firewall rules for some years, but lost the template when the NAT Loopback checkbox started working (OpenWRT).

[–] AnarchistArtificer 3 points 1 year ago

This is a great explanation, I wish I could've got you to explain a bunch of other network stuff to me back when I was learning

[–] mxd2@lemmy.world 1 points 1 year ago (1 children)

Thanks a lot, I actually meant public IP, which is the IP my domain is pointing at, so it's the same.

[–] Chreutz@lemmy.world 2 points 1 year ago

Yeah, I just included the DNS part for completion's sake 🙂

[–] atocci@kbin.social 5 points 1 year ago

Hey same I don't know why it doesn't work. I need to use my server's local IP when I connect from inside my house.

[–] whiskyjack@lemmy.ca 3 points 1 year ago* (last edited 1 year ago)

Couple good ideas already posted, but also you can update your hosts file with a ref to the internal IP, or if you are running your own DNS server, add an override for the domain

[–] tsuica@lemmy.ml 3 points 1 year ago

There's a few devices out there that don't offer NAT hairpin/loopback by default, such as Mikrotik.

[–] mxd2@lemmy.world 1 points 1 year ago

SORRY I MEANT PUBLIC IP