How to Find Your IP Address on Linux

On Linux, just like any other OS, there's a difference between your local IP (inside your network) and your public IP (what the internet sees). Here are the terminal commands for both.

Finding your public IP

The simplest way is to open the Show-IP.ir homepage in a browser. If you're working on a headless server with no GUI, this site also works straight from the command line — just like ifconfig.me:

curl show-ip.ir

That instantly returns your server's public IP address as plain text. For the full details as JSON:

curl show-ip.ir/json

Finding your local IP with the ip command

On modern Linux distributions (Ubuntu, Debian, Fedora, Arch), the standard command is ip:

ip addr show

Or more concisely:

ip -4 addr show | grep inet

The address next to your active network interface (usually eth0, wlan0, or enpXsY) is your local IP.

The older way: ifconfig

On older distributions, or if you have the net-tools package installed, you can also use:

ifconfig

The hostname command

Another quick way to see your local IP:

hostname -I

Key takeaways

  • For your server's public IP: curl show-ip.ir
  • For your local IP: ip addr show or hostname -I
  • For full details as JSON: curl show-ip.ir/json
Show-IP.ir
Find your public IP address along with your country, city, ISP, time zone and location on a map. Includes VPN/proxy/Tor detection and a free subnet calculator.
Try it
Back to articles