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:
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 ‘127.0.0.1’ | nc -p 9229 192.168.222.1
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.