DaHai8
Posts: 55
Joined: Fri Jul 31, 2015 9:21 am

P2P Access to RPi over Internet

Fri Dec 11, 2015 2:44 am

Ok, this is a real Newbie question. I don't even know what I don't know. So I may not be even asking a valid question.

Can the RPi be set up to use P2P (instead of Port Forwarding) to connect to it over the Internet via SSH, SSL, OpenVPN, etc?

I see security cameras that use P2P for direct access over the internet without having to open router ports. Can the same be done with the RPi under Raspbian?

Do you have to have a service/server somewhere to make the P2P connection?

Please point me to some resources/web pages where I can learn how to do this.

Thanks.

User avatar
karrika
Posts: 1151
Joined: Mon Oct 19, 2015 6:21 am
Location: Finland

Re: P2P Access to RPi over Internet

Fri Dec 11, 2015 6:27 am

The P2P technique does forward a port. It is just forwarded outside of your own network and the mechanism is a bit hidden.

You can easily do this from RPi also. But you need a connection point that has a real IP address and is accessible on the internet.

A typical example is how to create a concealed port to RPi that you can access from anywhere.

Start by creating a cloud server somewhere that has ssh and create an user account for RPi.

From RPi connect to the cloud server like this:

ssh -R 2345:localhost:22 user@cloudserver
or if the admin has denied GatewayPorts you can do
ssh -R *:2345:localhost:22 user@cloudserver

What happens here is that the raspberry creates a Port Forward back to itself. Anyone who connects to port 2345 on the cloud server is actually connecting to RPi on port 22.

So to connect to RPi you can run the command:

ssh -p 2345 pi@cloudserver

The same features are available in Putty by searching a little. The good thing is that RPi is hidden from the network. It can only be found through the strange port forward on that strange cloud server.

DaHai8
Posts: 55
Joined: Fri Jul 31, 2015 9:21 am

Re: P2P Access to RPi over Internet

Mon Dec 14, 2015 1:50 pm

Thank you karrika for your reply!

So it does require a server somewhere to make the connection. I was afraid of that.
With more and more Routers not supporting UPnP due to security concerns, its getting harder to access IoT devices without some corporate entity (another security concern).
Perhaps IPv6 is the answer for direct Device to Device connections, since each device has a universally unique IP address...

dhanar10
Posts: 1
Joined: Tue Jan 19, 2016 11:14 am

Re: P2P Access to RPi over Internet

Tue Jan 19, 2016 11:24 am

You can try "n2n". It is available in Raspbian. It may not be as secure as OpenVPN but it is simple.

It still needs a supernode, but public supernodes are available. So, you don't have to set up your own or have your own public ip.

I use it to ssh over the internet. Also, taking screenshot or streaming from my CCTV DVR (need fast upload though).

Return to “Advanced users”