This post will show you how to determine your public-facing IP address from the command line.
Upon an interactive logon, Ubuntu prints some brief machine information. This includes a header, sysinfo from /usr/bin/landscape-sysinfo and a summary of available patches.
You may add your own scripts by creating a bash script in /etc/update-motd.d and set the execute permission on the file. The files in the directory have a particular naming convention, and are run in alphabetical (numeric) order.
On external facing machines, I often create a script which will print the external IP address following the networking info of the landscape-sysinfo script.
Create file /etc/update-motd.d/61-external-ip owned by root
and give it execute permission:
sudo chmod 755 /etc/update-motd.d/61-external-ip
Place the following in this new file:
#!/bin/sh
ONE=$(/usr/bin/curl -s checkip.amazonaws.com)
TWO=$(/usr/bin/curl -s ifconfig.me)
if [ $ONE = $TWO ]
then
printf " External IPv4: "
printf $ONE
else
printf " External IPv4 may be: "
printf $ONE
printf " or"
printf $TWO
fi
printf "\n"
Save the file, then logon to the machine and look at the interactive logon messages. Some of the output will look like:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64)
System information as of Mon 19 Jul 2021 01:30:42 PM MDT
System load: 0.58
Usage of /: 5.4% of 1.79TB
Memory usage: 15%
Swap usage: 0%
Temperature: 44.0 C
Processes: 173
Users logged in: 1
IPv4 address for enp0s25: 192.168.0.9
External IPv4: 123.456.7.89