Get Public IP Address from Terminal

terminalbeginnerlinuxmacos

Quick command to retrieve your public IPv4 address from the command line using curl

#terminal#networking#ip-address#curl#command-line

Get Public IP Address from Terminal

Overview

Quick command to retrieve your public IPv4 address from the command line using curl

Prerequisites

  • Terminal access
  • Curl

Instructions

To get your public IPv4 you just need to type this command:

echo $(curl -sS ifconfig.me)

You can add it to your rc config file with an alias such as publicip, whatsmyip, or whatever you want!

Troubleshooting

If you encounter any issues:

  1. Verify all prerequisites are installed
  2. Check command syntax carefully
  3. Ensure you have necessary permissions