How do I connect to my local computer from any computer in the world?

This question came to me out of curiosity, since I had been working for years with virtual computers from AWS, which I always connected to from my local computer (MacBook Pro) via SSH through port 22.

The purpose of these virtual servers was generally to provide services for small and medium-sized businesses, such as cloud web servers. So I usually made sure to open the typical service ports used by SMBs, like: HTTP, HTTPS, POP3, SSH, FTP, SMTP, IMAP, among a few others…

So basically I opened my terminal and typed the following command:

ssh -i ~/Ruta/de/la/key.pem <user>@<host>

With that command I connected from my local computer to the cloud server rented from companies like AWS or DigitalOcean.

Once inside the cloud server, I installed the required software and services. For example, CPANEL or VestaCP or the like.

After some time processing all this, my curiosity grew and I wondered if I could connect to my local computer from anywhere in the world. Basically doing it the other way around. Connecting from the cloud server to my local computer (MacBook Pro). And as with most things in tech, yes, it’s possible. Let me explain how I did it:

Honestly, at first I struggled a bit because I forgot that my MODEM was responsible for assigning my IP address, and my router was showing a local IP as the WAN IP.

So that was the first step. I called my phone company and asked them to set the modem to “bridge” mode. They told me they had to escalate the call to “Layer 2” because they couldn’t do it themselves, but that they would call me back to make the change.

Some time passed and sure enough they called me back to let me know the change had been made. As expected, the internet stopped working on my TP-Link router. On the other hand, the modem continued to work fine, but the TP-Link router stopped functioning.

So the technician from my phone company told me this was because I had to clone my MAC ADDRESS. This basically means I had to enter the MAC Address of the modem from my phone company into the settings of my TP-Link router’s admin panel.

So I went to the menu Network > Internet and found the “MAC Clone” option there. I selected the “Use Custom MAC Address” option and entered the MAC Address from my provider’s modem, which the technician had given me.

To do that, I had to separate every 2 digits with a “-“, like this:

Example of MAC Address: “22-22-22-22-22-AA”

Once I entered the MAC Address, I went to the TP-Link settings and under NAT Forwarding > Virtual Servers, I added the SSH port.

Then I went to https://www.yougetsignal.com/tools/open-ports/ to check if my port was open, and sure enough, it was.

So I connected to my EC2 instances and used SSH to connect to my local computer without any issues. I also tested it from my iPhone using Termius, and it worked perfectly as well.

Leave a Reply

Your email address will not be published. Required fields are marked *