How do you get external ip on command line

I need to find out WAN IP address. How do you get external ip on command line? What command I need to type?

Get external IP on Linux or Unix command line

  1. Open the terminal
  2. Type the following command
    dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
  3. We can also use host command:
    host myip.opendns.com resolver1.opendns.com

A note about MS-Windows users

  1. Open prompt
  2. Type the following nslookup command:
    nslookup myip.opendns.com. resolver1.opendns.com

See my guide for more information
https://www.cyberciti.biz/faq/how-to-find-my-public-ip-address-from-command-line-on-a-linux/