Get Gateway IP address

Hello

is there any way to fetch the gateway IP address?

Thanks

In short: yes :slightly_smiling_face:

You can use such a script:

#!/bin/bash

if [[ $(find "/home/root/scripts/public_ip.txt" -maxdepth 1 -mmin +60 -print) ]]; then
  IP=$(curl --silent icanhazip.com)
  echo "$IP" > /home/root/scripts/public_ip.txt
fi
cat /home/root/scripts/public_ip.txt

and send the result to CS thanks to the metadata.

2 Likes