Skip to main content

Command Palette

Search for a command to run...

How to Check IP on Linux

Updated
6 min read

Checking your IP address on Linux is something you might need to do often. Whether you’re troubleshooting network issues, setting up a server, or just curious about your connection, knowing how to find your IP is essential. Luckily, Linux offers several easy ways to check your IP address, both through the command line and graphical tools.

In this article, I’ll guide you through the most common methods to check your IP on Linux. You’ll learn how to use terminal commands like ip and ifconfig, as well as how to find your IP using desktop environments. By the end, you’ll feel confident finding your IP address anytime you need it.

What Is an IP Address and Why It Matters

An IP address is a unique number assigned to your device on a network. It helps computers find and communicate with each other. On Linux, your device can have multiple IP addresses, such as:

  • Private IP: Used within your local network (like your home Wi-Fi).
  • Public IP: The address visible on the internet.

Knowing your IP address helps you:

  • Troubleshoot network problems.
  • Configure network services.
  • Connect remotely to your Linux machine.

Checking IP Address Using the ip Command

The ip command is the modern and preferred way to check IP addresses on Linux. It replaces the older ifconfig tool and provides more detailed information.

To check your IP address, open the terminal and type:

ip addr show

This command lists all network interfaces and their details. Look for lines starting with inet to find IPv4 addresses. For example:

3: wlp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic wlp2s0

Here, 192.168.1.10 is the IP address of the wireless interface.

Quick Ways to Get Just the IP Address

If you want to see only the IP address without extra info, use:

ip -4 addr show wlp2s0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'

Replace wlp2s0 with your network interface name. This command extracts just the IPv4 address.

How to Find Your Network Interface Name

If you don’t know your interface name, run:

ip link show

This lists all interfaces, like eth0, wlp2s0, or enp3s0.

Using the ifconfig Command to Check IP

ifconfig is an older tool but still widely used. Some Linux distributions may not have it installed by default, but you can add it via the net-tools package.

To check your IP, type:

ifconfig

You’ll see output for each network interface. Look for the inet or inet addr field. For example:

wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.10  netmask 255.255.255.0  broadcast 192.168.1.255

Here, 192.168.1.10 is your IP address.

Installing ifconfig if Missing

If the command is not found, install it with:

sudo apt install net-tools   # For Debian/Ubuntu
sudo yum install net-tools   # For CentOS/RHEL

Checking Public IP Address from the Terminal

Your Linux machine’s public IP is the one visible on the internet. To find it, you can use online services via the terminal.

Try this command:

curl ifconfig.me

Or:

curl icanhazip.com

These commands fetch your public IP from external servers.

Alternative Tools to Check Public IP

  • wget -qO- ifconfig.me
  • dig +short myip.opendns.com @resolver1.opendns.com

These are handy if curl is not installed.

Using GUI Tools to Find Your IP Address

If you prefer not to use the terminal, most Linux desktop environments provide graphical ways to check your IP.

GNOME Desktop

  1. Click the network icon on the top panel.
  2. Select “Settings” or “Network Settings.”
  3. Choose your active network connection.
  4. Look for the “Details” or “IPv4” section to see your IP address.

KDE Plasma

  1. Click the network icon in the system tray.
  2. Select “Connection Information.”
  3. Your IP address will be displayed under the active connection.

XFCE and Others

Most desktop environments have similar network settings accessible via the system menu or control panel. Look for “Network” or “Wi-Fi” settings.

Checking IP Address for Specific Network Interfaces

Sometimes, you want to check the IP for a particular interface, like Ethernet or Wi-Fi.

Use the ip command with the interface name:

ip addr show eth0

Or with ifconfig:

ifconfig eth0

This shows IP details only for that interface.

Understanding IPv4 vs IPv6 Addresses on Linux

Linux supports both IPv4 and IPv6 addresses. IPv4 looks like 192.168.1.10, while IPv6 looks like fe80::1a2b:3c4d:5e6f:7g8h.

When you run ip addr show, you’ll see both types:

  • Lines starting with inet show IPv4.
  • Lines starting with inet6 show IPv6.

IPv6 is becoming more common, so it’s good to recognize both.

Troubleshooting When No IP Address Shows

If your interface shows no IP address, try these steps:

  • Restart the network service:

    sudo systemctl restart NetworkManager
    
  • Check if the interface is up:

    sudo ip link set eth0 up
    
  • Renew DHCP lease:

    sudo dhclient -r eth0
    sudo dhclient eth0
    

Replace eth0 with your interface name.

Summary Table: Commands to Check IP on Linux

CommandDescriptionNotes
ip addr showShow all IP addressesModern, preferred method
ip -4 addr show <interface>Show IPv4 address for interfaceUse with interface name
ifconfigShow IP addresses (older tool)May need installation
curl ifconfig.meGet public IP addressRequires internet connection
ip link showList network interfacesHelps find interface names

Conclusion

Now you know several ways to check your IP address on Linux. Whether you prefer the command line or graphical tools, Linux makes it easy to find your IP. The ip command is the most reliable and modern method, but ifconfig is still useful if installed.

Remember, your device can have multiple IPs, including private and public addresses. Knowing how to find them helps you manage your network better. Next time you need to check your IP on Linux, you’ll have the right tools and commands ready.

FAQs

How do I find my IP address on Linux using the terminal?

Use the ip addr show command to list all IP addresses. Look for the inet line under your network interface for your IPv4 address.

What if the ifconfig command is not found on my Linux system?

You can install it by running sudo apt install net-tools on Debian-based systems or sudo yum install net-tools on Red Hat-based systems.

How can I check my public IP address from Linux?

Run curl ifconfig.me or curl icanhazip.com in the terminal to get your public IP from external services.

Can I check my IP address using a graphical interface on Linux?

Yes, most desktop environments like GNOME and KDE have network settings where you can view your IP address under the active connection details.

What is the difference between IPv4 and IPv6 addresses on Linux?

IPv4 addresses are in the format x.x.x.x (e.g., 192.168.1.10), while IPv6 addresses are longer hexadecimal strings (e.g., fe80::1a2b:3c4d). Linux supports both types.

More from this blog

L

LinuxBloke | Linux Tips, Tricks & Troubleshooting

672 posts