Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the NAT translated IP and port of some local port

I have some software running on port 50885 on a computer behind a NAT

How can I access this port from the internet? I can initiate something from the computer as I have to launch the app.

If I get it correctly : with my local address:port, lets say : 192.168.0.10:50885 If something goes trough the NAT initiated by the computer, Then there should be some sort of port forwarding created automatically and there should be some sort of publicly IP:PORT that should knock on the 50885 port on the computer behind the NAT. Am I right?

If so, wouldn't it be possible to ask a server-side script like in php, Hey, tell me what this publicly IP & Port are?

I'm a bit confused about Port Forwarding.

like image 501
Vincent Duprez Avatar asked Nov 30 '25 03:11

Vincent Duprez


1 Answers

Per my understanding, assuming you use socket local_ip:local_port to connect remote1_ip:remote1_port. After NAPT device local_ip:local_port becomes translated_ip:translated_port. remote1 can get translated_ip:translated_port but I have not found such service. Next time you establish a new connection with remote2_ip:remote2_port with the same client local_ip:local_port, will translated_ip:translated_port be kept unchanged? Normally NAPT sever will reserve it for some time, say 5 minutes. So if someone from remote3:remote3_port to connect translated_ip:translated_port within 5 minutes (since the last packet sent to translated_ip:translated_port), NAPT server will direct traffic to local_ip:local_port. If remote3_port=remote1_port, though remote1_ip!=remote1_ip, the connection will be accepted by the local socket. If the information expired, NAPT sever will allocate a new translated_ip2:translated_port2.

like image 125
Leon Avatar answered Dec 02 '25 18:12

Leon