External IP With Terminal
Sometimes we need a quick and easy way of finding our forward-facing /external IP. Yes, you can simply open a web browser, navigate to your router/home hub to find your external IP, or even type into google “what is my IP” but this has limitations some broadband and fibre providers are returning IPV6 addresses when you're looking for your IPV4 style external address.
If you’re configuring a Raspberry Pi or ssh’ing into a machine its not always possible or feasible to open a web browser, but using Terminal you can obtain this information. The Terminal is a built-in application on both Linux and macOS that’s super powerful.
If you're using a Mac to obtain the external IP from the desktop follow the steps below if you’re ssh’ing into a device locally just run the command.
cmd + Space > Type ‘Terminal’ > Press Enter
In the pop-up window type the following command
curl http://ipecho.net/plain
Press enter, and under the command you’ll see your external IP address.
Really simple and quick, no web browsers involved to confuse things.
oh this command also works in Windows Power shell too.