LinuxTutorial2 min read

How to Check Your IP Address on Linux

Find your local and public IP address on Linux using ip addr, hostname, and ifconfig — with clear examples for both wired and wireless interfaces.

Developer terminal on a laptop in low light

Local vs Public IP

Your local IP is assigned by your router and is only reachable on your local network (e.g. 192.168.1.10). Your public IP is the address the internet sees. Both are useful to know for different reasons.

ip addr — The Modern Way

The ip command is the current standard on all modern Linux distributions:

ip addr
# or the shorter alias:
ip a

Look for your main network interface (usually eth0 for wired or wlan0 for Wi-Fi on older systems, enp3s0 or wlp2s0 on newer ones). The inet line shows your IPv4 address:

2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP>
    inet 192.168.1.42/24 brd 192.168.1.255 scope global dynamic enp3s0

Show only IPv4 addresses

ip -4 addr show

hostname — Quick One-liner

hostname -I          # print all local IP addresses
hostname             # print the machine's hostname

hostname -I is the fastest way to get your IP when you don't need the full interface details.

ifconfig — The Classic Tool

ifconfig is older but still available on many systems. Install it with sudo apt install net-tools if it's missing:

ifconfig
ifconfig eth0        # show a specific interface

Find Your Public IP

Your router hides your local IP behind NAT. To see the public address that websites see:

curl ifconfig.me
curl icanhazip.com
curl ipinfo.io/ip

Check Specific Interface Details

ip addr show eth0          # wired interface
ip addr show wlan0         # wireless interface
ip link show               # show all interfaces with their state (UP/DOWN)

Practical Use Cases

  • Set up SSH: share your local IP with someone on the same network
  • Configure a firewall rule for your IP
  • Debug network issues by confirming you have a valid IP
  • Find your server's IP to point a domain name at it