Recent

Author Topic: How to connect from Internet to local Mashine behind a router?  (Read 2344 times)

mercurhyo

  • Full Member
  • ***
  • Posts: 235
Re: How to connect from Internet to local Mashine behind a router?
« Reply #15 on: June 02, 2023, 12:56:26 pm »
http://miniupnp.free.fr/

this library / .DLL / .SO allows you to manage at higher level most of the router-nat things

if you bind its API to your application and are good programmer you can then open a port without manually configuring

all the rest is litterature from beginers
« Last Edit: June 02, 2023, 12:59:24 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

rvk

  • Hero Member
  • *****
  • Posts: 5490
Re: How to connect from Internet to local Mashine behind a router?
« Reply #16 on: June 02, 2023, 01:01:14 pm »
Using a library/tool is indeed the easiest (non cross-platform) method.

But using M-SEARCH and taking directly to the router to map a port shouldn't be that difficult. And it would be cross-platform.

mercurhyo

  • Full Member
  • ***
  • Posts: 235
Re: How to connect from Internet to local Mashine behind a router?
« Reply #17 on: June 02, 2023, 01:05:22 pm »
Using a library/tool is indeed the easiest (non cross-platform) method.

But using M-SEARCH and taking directly to the router to map a port shouldn't be that difficult. And it would be cross-platform.

non crossplatfarn ? go to the site please

http://miniupnp.free.fr/

I am too nice lol >:D
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

rvk

  • Hero Member
  • *****
  • Posts: 5490
Re: How to connect from Internet to local Mashine behind a router?
« Reply #18 on: June 02, 2023, 01:15:58 pm »
Ok, I was only familiar with MiniUPnP on Linux.

That said... I myself would go the native route.
But that's totally up to the programmer.

But you're correct, it is cross-platform.

mercurhyo

  • Full Member
  • ***
  • Posts: 235
Re: How to connect from Internet to local Mashine behind a router?
« Reply #19 on: June 02, 2023, 04:59:20 pm »
you're welcome @rvk

I used miniUpnpC under windows XP. As mentioned on the site you download stuffs for your fav platformS and rely on them by API .. Linux, BSD, Mac, AmigaOS, Windows.. etc etc

source code is also available

Enjoy
« Last Edit: June 02, 2023, 05:01:36 pm by mercurhyo »
DEO MERCHVRIO - Linux, Win10pro - Ryzen9XT 24threads + Geforce Rtx 3080SUPRIM
god of financial gain, commerce, eloquence (and thus poetry), messages, communication (including divination), travelers, boundaries, luck, trickery and thieves; he also serves as the guide of souls to the underworld

Key-Real

  • Full Member
  • ***
  • Posts: 132
Re: How to connect from Internet to local Mashine behind a router?
« Reply #20 on: June 13, 2023, 10:36:02 pm »
rvk was so kindly to help me with the UPnP code, see:

https://forum.lazarus.freepascal.org/index.php/topic,63652.0.html

Key-Real

  • Full Member
  • ***
  • Posts: 132
Re: How to connect from Internet to local Mashine behind a router?
« Reply #21 on: June 13, 2023, 10:37:44 pm »

I have now
 - Hole Punching
and
 - UPnP

are there other solutions?

rvk

  • Hero Member
  • *****
  • Posts: 5490
Re: How to connect from Internet to local Mashine behind a router?
« Reply #22 on: June 13, 2023, 11:32:48 pm »
are there other solutions?
For Hole Punching there are several techinques.

The one described is for when the router can be fooled with trying to connect from both ends at the same time.

But there are routers which have NAT implementations where the outgoing port isn't predictable. In that case you will need to use additional techniques to try to punch the whole (which not always works).

If that, and UPnP doesn't work... you can always communicatie via the common server (without a direct connection).

BTW. If I get to it, I will also implement username/password for the TUPNP class. Because allowing UPNP on your network is a security issue.
Putting Authentication on UPNP is at least a bit more secure (but that's not standard, not all implementations have authentication).

(Does your router have authenticated / secure UPnP ? Mine does, Asus with Asuswrt-Merlin.)

TRon

  • Hero Member
  • *****
  • Posts: 1560
Re: How to connect from Internet to local Mashine behind a router?
« Reply #23 on: June 18, 2023, 10:01:27 am »
When surfing around regarding another networking related topic I came across this blog-post about NAT traversal which might be interesting (it describes all the hurdles you can come across and how to approach/solve).

edit: not an (indirect) advertisement for using their services. I have no affiliation nor interest.
« Last Edit: June 18, 2023, 10:04:17 am by TRon »

delphius

  • Jr. Member
  • **
  • Posts: 52
Re: How to connect from Internet to local Mashine behind a router?
« Reply #24 on: June 20, 2023, 09:54:55 am »
Use something like localtunnel and don't bother your head with such nonsense anymore

rvk

  • Hero Member
  • *****
  • Posts: 5490
Re: How to connect from Internet to local Mashine behind a router?
« Reply #25 on: June 20, 2023, 10:13:18 am »
Use something like localtunnel and don't bother your head with such nonsense anymore
How would this work if both clients are behind a NAT/Firewall???

Also... this is about http(s) traffic, not any random developed protocol you might have.
And localtunnel doesn't make direct contact between both clients.

delphius

  • Jr. Member
  • **
  • Posts: 52
Re: How to connect from Internet to local Mashine behind a router?
« Reply #26 on: June 20, 2023, 10:41:50 am »
If I understood the original task correctly, it was only to provide access to the server located behind the NAT at the address and port. As for protocols, it seemed to be about a kind of training example, in which http(s) is most likely involved

rvk

  • Hero Member
  • *****
  • Posts: 5490
Re: How to connect from Internet to local Mashine behind a router?
« Reply #27 on: June 20, 2023, 10:47:34 am »
Ok, maybe I used too much information from similar topics by the same user at the same time (about udp hole punching and direct contact between clients behind a NAT. etc).

TS can elaborate if this is incorrect or not.

delphius

  • Jr. Member
  • **
  • Posts: 52
Re: How to connect from Internet to local Mashine behind a router?
« Reply #28 on: June 20, 2023, 11:01:19 am »
If we could also implement a free pascal localtunnel client, which does not seem such a difficult task, then happiness will come for an ordinary topicstarter :)

P.S. I got acquainted with all the topics on this topic from the author and could not understand the specific use case and requirements. It seems to me that it is necessary to start with the exact formulation of the task, at least in general terms, in order to give specific advice. All I understood was that the server would be behind NAT and that development should rely only on modules distributed with fpc.
« Last Edit: June 20, 2023, 04:17:22 pm by delphius »

 

TinyPortal © 2005-2018