K
K
Kop3t32015-10-03 19:26:57
Python
Kop3t3, 2015-10-03 19:26:57

How to link 2 PCs behind NATs in python?

Good day!
There are 3 hosts:
1 and 2 => clients behind NAT. If you try to determine the type of nat through STUN, then it writes Full Cone Nat (moreover, one of them (2) depending on the STUN server used - either full cone or symmetric)
3 => server with a white ip.
The question is how, having these 3 components, connect 1 and 2 directly using python sockets.
Here is an example of what I did:
1) From (1) I send a udp packet to (3).
2) On (3) I receive this packet and find out the external ip and port (1).
3) With (2) I send a udp packet to the ip and port (1) that I received in step 2.
and nothing comes through.
What am I doing wrong, and maybe there are ready-made libraries for this in python?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
T
TyzhSysAdmin, 2015-10-03
@POS_troi

If 1 port is not thrown into the network to the desired host, then it is not surprising that it does not work.

M
Maksim, 2015-10-05
@chumayu

Raise a VPN server on a server with a white IP IP (there are a lot of instructions), install vpn clients on the computers behind nat and drive whatever your heart desires.

L
Leonid, 2020-09-17
@sled

1. Get an external IP address and port for PC1 and PC2
2. Through a common social network account (VK), exchange IP addresses and ports

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question