Community Forum

Report IP address of Raspberry behind OpenVPN connection -> GCS

(Vladimir Pozniy) #1

Hello community,

My Raspberry connects to openvpn server automatically on boot and sends copter telemetry over UDP to a GCS on VPN network. The only problem is that IP assigned by openvpn server is different almost every time, so I have to lookup server connections all the time.

When logged on on Raspberry, I can get the IP on the openvpn network interface like this:

ifconfig tun0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v ''

I can run the the script every time the connection is started.

Questions is. What is the best way to send this IP address to my GCS? I was thinking e-mailiing it, but there should be a better solution.

Do you have any ideas?


If you are on a secure network and don’t need authentication or encryption, then what about netcat (or socat)?

Just listen on a TCP port at the GCS. Listen for an IP address:
nc -l -p 9229 | my_script_that_listens_for_RPIs_IP_address.sh

Then tell the RPI to connect to and pass the IP to the GCS with your one-liner of code:
ifconfig tun0 | grep -Eo ‘inet (addr:)?([0-9].){3}[0-9]’ | grep -Eo ‘([0-9].){3}[0-9]’ | grep -v ‘’ | nc -p 9229

(Vladimir Pozniy) #4

Good idea, but that would require listening on GCS at all times. I need to report Raspberry’s IP when my keepalive scripts detects the network is lost and initiates a reconnect script sequence. So it is more like as fail safe feature.

The IP is issued by my openvpn server and I was thinking setting a simple web server on it and writing an ip to a web server file. So when I need to find out the IP I just check the webserver andd see Navio’s current IP address.