OpenVPN setup on Raspberry Pi
I first tried using Husarnet and opening a port on my router, but I found it was not stable (the router). Switched to using OpenVPN instead and had more success. Has been a while since I tried Husarnet though, likely worth revisiting.
OpenVPN server
https://openvpn.net/faq/connection-initiated-with-x-x-x-x-but-i-cannot-ping-the-server-through-the-vpn/ - Then restarted the OpenVPN service on the server.
Start command in screen on rpi:
sudo openvpn --config profile-<profile-number>.ovpn
Connect laptop to VPN client.
ssh -i /Users/matthewpye/.ssh/create_laptop -o "ProxyCommand ssh -i /Users/matthewpye/Documents/vpn_server/vpn_server.pem -W %h:%p openvpnas@<ec2-ip>.eu-central-1.compute.amazonaws.com" rpi@<rpi-vpn-ip>
https://<ec2-ip>:943/?src=connect
No ping response from server
Can ssh into the rpi from laptop just fine, and also ping between them when they are connected to OpenVPN server. Cannot ping from a client to the VPN server gateway address with ping 172.27.232.1
, which would have been useful for checking VPN is active on RPi.
OpenVPN client service on RPi
Added the file to /etc/openvpn/client/vpn-client.conf
and the credentials to login in a file called login.conf
at the same location. vpn-client.conf
is also stored locally in Documents/vpn_server
.
<user>
<password>
Now on boot, a service called openvpn-client@vpn-client.service
should start and connect us to the VPN. We can check the status of this service to decide if we need to reboot.
Creating static IPs for devices in OpenVPN admin panel
Let’s set up static IPs for each device, seems to be done by creating multiple user profiles and assigning each a static IP.
- Created the second openvpn_laptop profile and use that on the laptop.
- Using the openvpn profile on the rpi.
- Maximum 2 connections on OpenVPN free plan.
What are we trying to develop in the near future?
- Able to login to a UI from anywhere without VPN.
- Server needs to be hosted in AWS, as the Vodafone router will not enable me to open ports.
- From this UI, able to view robot camera feeds.
- WebRTC stream camera data, through VPN.
- Able to view robot location data.
- WebRTC data channel. (Avoiding the RosBridge).
- Able to trigger robot missions and drive the robot with a gamepad.
- 2-way data channel.
What are the first steps for this?
MVP for a demo would be:
- Robot with Camera connected to raspberry pi.
- Camera data visible on client laptop.
- Client laptop able to send gamepad or keystroke commands to move robot.
Plan to achieve first steps
- Camera data streaming to WebRTC, can view the stream from laptop when connected to VPN.
- Lets get a RPi and camera connected to the robot, view the stream, then trigger ROS2 commands from the RPi when ssh’d into it.