How do I find my IP Address from the command line?

I recognize you can do ifconfig | grep inet, yet that reveals you numerous IPv4 addresses. Just how do I get the details one for SSHing et alia?

307
2022-06-04 20:33:58
Source Share
Answers: 1

Use ipconfig getifaddr en1 for cordless, or ipconfig getifaddr en0 for ethernet.

ipconfig getifaddr en0 is default for the Wi - Fi network adapter.

Conversely you can additionally do :

dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com

Output, as an example :

172.79.136.120
345
2022-06-04 21:02:10
Source