How to communicate between ROS machines through VPN
I am working on a project which requires two machines comunicating through a VPN. At the moment I am trying to connect my PC to a remote server (through VPN as well), both have ROS kinetic installed, and I would like to run a simple listener/talker communication.
They are connected using openvpn, by means of a tun0 interface which gives respectively to the server and to the PC the addresses 10.8.0.1 and 10.8.0.2. Both the machines are able to ping each other, hence I assume that the VPN is working properly.
I run the following commands on the machines:
SERVER:
Roscore:
clear
sudo -s
cd ~/catkin_ws/
catkin_make
. ~/catkin_ws/devel/setup.bash
export ROS_IP=10.8.0.1
export ROS_MASTER_URI=http://10.8.0.1:11311
roscore
Listener
clear
sudo -s
cd ~/catkin_ws/
catkin_make
. ~/catkin_ws/devel/setup.bash
export ROS_IP=10.8.0.1
export ROS_MASTER_URI=http://10.8.0.1:11311
rosrun rospy_tutorials listener.py
PC:
Talker
clear
cd ~/catkin_ws/
catkin_make
. ~/catkin_ws/devel/setup.bash
export ROS_IP=10.8.0.2
export ROS_MASTER_URI=http://10.8.0.1:11311
rosrun rospy_tutorials talker.py
Note that I have to instance every time the ROS_IP and the ROS_MASTER_URI since I open a new terminal.
However, the PC is not able to find the ROS master running on the server.
Therefore I would like to point out whether this is a problem of wrong ROS configuration or a VPN problem, maybe I need to set some IP forwarding rules.
Thanks for you help.