How to obtain the external IPv4 address via Terminal
It is not possible without checking an external source.  

In a typical networking environment, nothing on your computer knows the external IP address the computer is using to communicate with the public internet.  Instead, the computer has a private IP address and sends all traffic to the private IP address of a router which then forwards the traffic the the public internet using a public IP address.

The only reliable way to determine the public IP address associated with your computer's traffic is to contact an external source and have it tell you what IP address it sees your traffic coming from.