You have to connect to an external provider who can look at your publicly exposed IP and print it on screen. This is required when you work with cloud services such as AWS, Azure or Google cloud and you want to verify your public IP for a number of reasons

Here is an example, using IP provider service IPEcho.net
Code:
wget -qO- http://ipecho.net/plain ;echo

The code in action:
Code:
[root@devopsrun1 ~]# wget -qO- http://ipecho.net/plain ; echo
198.1.1.30

Notes:
In this example, the IP address has been changed for security reasons.
We are adding an echo command to add a newline character at the end of the line, otherwise your bash prompt will appear on the same line where ip address gets printed.