Adding External IP to the SSH Banner

Hey so I’ve recently had a go at editing the dietpi-banner file (I hope no-one minds), I did it as I’ve got a few rpi’s running dietpi on a few networks i.e. mine, my parents, and one of my friends houses. Was more of a little challenge I set myself to see if I can get it to work. Also because I have them as saves on my puTTy, so can be difficult to remember which is which. So now it is the usual banner, however under the IP Address line I have an additional one with the external IP. If anyone wants to know more or if the development team wants to implement it in a later version then feel free to message me or just fire away, i mean ofc you dont need my permission. I believe people may want it, not everyone I know, but some people might.
Just thought I’d share was a small achievement for me at least.

It fits to our DietPi-Banner customization request: https://github.com/MichaIng/DietPi/issues/2627
No worries about modifying our scripts. It’s GPLv2 licensed so you are free to any modifications and use the code in any way you want. Only limitation (not relevant for private purpose) is that if you publicly re-share modified files, they need to be licensed as GPLv2 as well and you need to name the original source and what you have changed :wink:.

The issue is that there is no reliable way to determine the external IP without manual input, is it?
/etc/hosts and /etc/hostname (respectively hostname command) “should” contain/match the external IP/domain, but it is not a must. One can successfully enable external access without changing the above content.

We have several software installs which require to know the external IP/domain but currently prompt an input field to enter it. I am already thinking about a proper solution to somehow ask user to enter the external IP and/or domain directly on first login (or via dietpi.txt) e.g., so we can use this info throughout our scripts non-interactively, but this again might be confusing for users which have a local-only setup.

So: It would be interesting to know how you obtain the external IP, not only to show it in the banner but as it is required in other cases as well.

To get external IP:

dig +short myip.opendns.com @resolver1.opendns.com

Has been implemented already (with v6.22). Run dietpi-banner from terminal and select WAN IP :slight_smile:. We placed an own most simply estimation script onto our server:

curl -sLm 2 https://dietpi.com/myip.php