Sorry I'm retarded in advance

Sorry I'm retarded in advance.

Is there a way to make to computers with private ips communicate with tcp? I know about port forwarding but is there a way to automate that?

Attached: Screenshot_20180819-185118__01.jpg (1080x541, 105K)

port forwarding is only required for sending an incoming connection from the internet to a specific computer, since all the machines on your home computer share the same public-facing IP via the router.

you don't need any kind of forwarding for communicating with another machine on your network since you're not crossing the private/public boundary

Automated port forwarding = UPnP
It's not a really good method though, it's not 100% supported and it's not very secure.

The best way is to use a server in the middle to relay the packets, like a STUN server.

i wasnt taliking about sending stuff to other computers on my network i have done that before i meant communicating with other networks (im bad at explaining shit)

but wont i need to port forward to get responses from the server?

You want your computer with a private IP to communicate with another computer on a separate network?

yeah basically

Where is this separate network? Is it local, just on a different subnet, or is it remote?

Python has library that allows you to create tcp client and a server. You can make a server/client and send data back and forth in 3 lines. Library is called socket and comes bundled with python.

You only need port forwarding enabled in your router settings if your computer is behind NAT

thats upnp
but don't do that its a security risk
you can do that if you don't care tho idk i love hardening everything because i have autism

i mean just a computer(s) in another place

No, port forwarding is in most home networks necessary for establishing incoming connections only. When you use a relay server in the middle you're virtually making connections on both ends outgoing and there's no need for forwarding in that case.

Not him, but is this the "hole punching" technique?

but you do need to get data from the server? so wont you need to port forward to get that?

If this is a temporary thing you can just use a VPN like LogMeIn or a Tor hidden service for Nat punchthrough. If you want a permanent solution use upnp or forwarding.

The term you're looking for is NAT traversal
When a TCP packet is sent, a temporary port is opened to receive the response.

So let's say the packet looks like this:
Source: 192.168.1.106 (your internal IP)
Source port: 11111 (the temporary port)
Destination: 80.40.20.10 (a server somewhere)
Destination port: 80

Now it gets routed through your gateway. It makes another temporary port and remembers where to forward the response that will come there to your computer)
Source: 31.41.59.26 (your external IP)
Source port: 12345 (router's temporary port)
Destination: 80.40.20.10 (a server somewhere)
Destination port: 80

Now it finally reaches the server and it sends the response, which goes to 31.41.59.26:12345 and reaches your gateway. It knows this is the port where your computer is supposed to receive the response and so it forwards it to 192.168.1.106:11111

So basically there are temporary ports for receiving responses

If I'm understanding you correctly you simply want a direct line of communication with another computer somewhere on the internet. To accomplish this, you'll have to have some sort of client-server relationship with the target (which can be accomplished using almost any language).

However, your packets will still need to traverse some router to go from you to the internet to the target. That's just how packet switched networks work. To accomplish this, you'll need to forward ports from the router to the process doing the communication. As for "automating this process", that depends on your router. Some models present an API, others don't. Most have an admin web interface, so you could use Pythons RoboBrowser, or BeautifulSoup library's to select the port forwarding options.

ok tnx that makes sense

Not if there’s a server as the middle man. How do you think most forms of internet messaging work?

thats what i was trying to understand but explained it pretty well

so if you want to do it without any port forwarding you have to have a server as a middle man right?