Search code examples
androidnathotspot

port forwarding (NAT) in android hotspot


Im setting up a raspberry based surveillance system using motioneyeos.

I connect the raspberry to the router and set the Nat in the router to redirect connections to port 80 to the raspi. And it works.

The problem is that the system is gonna be in a house where I have no internet, so I'm using an old phone with a SIM there. I connect to the 4G and open the hotspot. Then I connect the raspberry to the hotspot and, from the same net, it works nice.

Now when I connect from the outside I cannot access the raspi, obviously. I can only access the phone. Is there a way to do the Nat as we do in our routers?


Solution

  • The solution is use remote.it. This is a free for non commercial service that has a server in the cloud.

    • You have to go to remote.it and create an account, and retrieve a token.
    • Then you install their client in your raspberry pi and execute it (is console based, so good for headless systems)
    • provide it with your user, pasword, and token
    • tell him you want to share SSH(22) and HTML(80)

    Now your raspi makes an outgoing connection to their server, that is not prevented by your 3G connection. In order to access your raspi from the outside you have to:

    • Visit remote.it and login. You should be able to see your registered devices
    • select the device, and the protocol you want to get
    • the website will provide a fake address and port
    • connect (putty, ssh, or webbrowser) to this address and voilá.

    You are accessing your pi from behind the 3G router without dealing with new hardware nor configuring networks