Search code examples
linuxbashipip-addressnetcat

Global connection via netcat


I would like to make very easy connection between two devices: Device One is in WiFi1 and Device Two in WiFi2; The Device One has local address 192.168.4.65; The WiFi1 has IP address 12.34.56.78 (only example)

I want to run "nc -l <some parameters>" on my first device, and "nc <address>" on the second, so they connect;

I know, what to do if I want to connect two devices in a local area network;

But for global I have no Idea, what <some parameters> and <address> should be; can someone please help?


Solution

  • Thanks to @that-other-guy and @Barmar!!

    You can do it by managing your router settings; If you configurate port forwarding, it will move you to the device you want to;

    targeting 12.34.56.78:1234 to 192.168.4.65:1234. Then nc -l 1234 will be reachable with nc 12.34.56.78 1234