Rezvan Chagaev
Rezvan Chagaev

Reputation: 590

Get Public IP and port

While working a little bit with WebRTC i've learned what the beast is NAT and STUN and i was on my way to test my understanding how it all is working.

Here is the link where u can get your remote address and port along with your local one.

For example: my local ip:port is

192.168.1.2:4500

my internet provider will translate it to

209.200.1.2:14500

and will store the translation table like

|209.200.1.2:14500|192.168.1.2:4500|

and it effectively means when connection comes to 209.200.1.2:14500 it is forwarded to 192.168.1.2:4500.

Assuming that i have a correct understanding of NAT i expect that when i set up listening for an incoming connection on port 4500 (locally) some one will be able to connect to it via 209.200.1.2:14500 but it is not happening (connection can not be established) WHY?

Thx a lot for your help.

Upvotes: 1

Views: 2134

Answers (1)

NovaDenizen
NovaDenizen

Reputation: 5325

NAT was only designed to works with outgoing connections. The NAT router does not automatically become aware of a machine on a private IP beginning to listen on a port, and there is typically no guaranteed correspondence between the NAT router's public IP port and the private IP port. Also, it is impossible for the NAT router to correctly relay incoming tcp/ip connection packets (SYN) to private IPs, since it is totally unknowable which private IP they are intended for.

However, there are a body of techniques called hole-punching that manage to work practically. They typically require a third-party server with a non-NAT address to mediate between the two endpoints to set up the connection, then the bulk of the tcp/ip exchange occurs between the original two hosts.

Upvotes: 4

Related Questions