You know that the IP address visible within your network may be not the same with the public IP your network is sending. If you have a NAT router the only IP visible is the LAN IP. So how can we find the public IP the network is sending out?
First we install curl. That connects to an external web server to get the public IP.
If you’re running Ubuntu, Debian or Linux Mint type:
$ sudo apt-get install curl
On Fedora, CentOS or RHEL type:
$ sudo yum install curl
Now you can choose which external server you use to fetch the IP. The following are the commands with different servers. Use one of them.
$ curl ifconfig.me $ curl icanhazip.com $ curl ident.me $ curl ipecho.net/plain $ curl whatismyip.akamai.com $ curl tnx.nl/ip $ curl myip.dnsomatic.com $ curl ip.appspot.com $ curl ip.telize.com $ curl curlmyip.com