• Understanding IP addresses on Linux
  • Methods for finding your private (local) IP address on Linux
  • Displaying a public IP address in Linux
  • Linux IP address on servers and headless systems
  • How VPNs or containers affect IPs
  • Troubleshooting Linux IP address issues
  • Changing your local IP address in Linux
  • FAQ: Common questions about getting an IP address on Linux
  • Understanding IP addresses on Linux
  • Methods for finding your private (local) IP address on Linux
  • Displaying a public IP address in Linux
  • Linux IP address on servers and headless systems
  • How VPNs or containers affect IPs
  • Troubleshooting Linux IP address issues
  • Changing your local IP address in Linux
  • FAQ: Common questions about getting an IP address on Linux

How to get your IP address on Linux: Methods and troubleshooting

Featured 04.03.2026 18 mins
Ernest Sheptalo
Written by Ernest Sheptalo
Ata Hakçıl
Reviewed by Ata Hakçıl
William Baxter
Edited by William Baxter
get-linux-ip-address

Your IP address is a key part of how your Linux system connects to networks and the internet. Whether you are setting up a new connection, verifying network settings, or troubleshooting connectivity issues, knowing how to find your IP address is essential.

This guide explains how to get both your private (local) and public IP addresses on Linux using different methods, including graphical tools, terminal commands, and built-in utilities. It provides clear, step-by-step instructions for various distributions and common scenarios, helping you confidently manage and diagnose your network configuration.

Understanding IP addresses on Linux

An IP address is a unique number assigned to a device on a network. On Linux, it identifies your system on both local and external networks, allowing it to send and receive data. Linux uses this information to route traffic correctly, whether you’re accessing local resources or the internet.

Every Linux system connected to a network needs an IP address. This includes desktops, laptops, servers, and even virtual machines or containers. Linux supports two main versions of IP addresses:

  • IPv4: This is the older and most common format. It looks like four numbers separated by dots, such as “192.168.0.1.”
  • IPv6: This is the newer format, designed to support more devices. It uses longer combinations of numbers and letters separated by colons, such as “2001:0db8:85a3:0000:0000:8a2e:0370:7334.”

Both formats function the same way; IPv6 simply expands the address space to accommodate more devices.

Types of IP addresses explained

There are many types of IP addresses, which can be grouped based on where they’re used and how they’re assigned. Here are the most common ones:

Type of IP address What it means Where it’s used
Public IP address An address assigned to a network by an internet service provider (ISP). It allows communication with the wider internet. Used for communication between a local network and the internet.
Private IP address Also known as local IP addresses, these are used within a local network. Devices on the same network use it to communicate with each other. Used inside homes, offices, and other internal networks.
Static IP address An address that stays the same over time unless it’s manually changed. Commonly used for servers, printers, or systems that need a fixed address.
Dynamic IP address An address that changes automatically. Dynamic Host Configuration Protocol (DHCP) assigns it from a pool of available addresses. Common in home and office networks where automatic configuration is preferred.

Learn more: For more information, check out our guide to IP address classes.

Why knowing your IP is important

Knowing your private (local) or public IP address can help in several everyday situations. Each serves a different purpose when managing or diagnosing network connections:

  • Verifying network setup: Checking your device’s private IP address confirms it has successfully connected to your local network, for example, your home Wi-Fi or office LAN.
  • Identifying connection issues: If a system can’t access other devices on the same network, reviewing its private IP address can help troubleshoot local connectivity problems. If it can’t access the internet, checking the public IP address can help determine whether your router or ISP connection is functioning properly.
  • Configuring network services: Some applications, servers, or devices on a local network require a specific private IP address to work correctly, for example, when setting up file sharing, hosting a local web server, or configuring port forwarding.
  • Online security awareness: A public IP address is visible to websites and online services. It can reveal your approximate location and ISP, so understanding it helps assess privacy risks.
  • Remote access and system management: Administrators may need a public IP address to access a system over the internet or a private IP address to manage devices on the same local network.

Methods for finding your private (local) IP address on Linux

Linux provides multiple ways to check your local IP address. Some methods use the terminal, while others rely on the graphical interface. Both approaches provide the same core information, just presented in different ways.

Using the terminal

The terminal is a text-based interface that allows direct communication with the system. It’s one of the most reliable ways to view network details, including your private IP address. To open the terminal in most Linux distributions:

  • Press Ctrl + Alt + T or search for Terminal in the applications menu.The Ubuntu application menu with the Terminal icon highlighted for selection.

Once open, commands can be entered to display network information. The sections below explain the most common ones.

Common command: ip addr

The “ip addr” command is the standard way to view network details in modern Linux systems. To use it:

  1. In the Terminal app, type ip addr and press Enter.The ip addr command in a Linux terminal displaying detailed network interface information.

The system will display a list of network interfaces. An interface is simply a network connection, such as Wi-Fi or Ethernet. Look for:

  • The “inet” followed by a number: This is the IPv4 address.
  • The “inet6” followed by a longer string: This is the IPv6 address.

If you wish to determine what interface the connection uses, look for the following labels:

  • “lo” for a loopback address.
  • “eth0," "ens33," or “enp0s3” for Ethernet.
  • “wlan0” for Wi-Fi.

Quick command: hostname -I

If a shorter output is preferred, the “hostname -I” command can help. It provides a simpler result by listing IP addresses without extra details. To use it:

  1. Open the Terminal app, then type hostname -I and press Enter.The hostname -I command in a terminal displaying the system's local IP address.

The system will return one or more IP addresses in a single line. Just bear in mind that it doesn’t show which interface the address belongs to.

Active interface IP: ip route get 1.1.1.1

Sometimes, multiple IP addresses appear, and it’s unclear which one is actively being used for internet traffic. The ip route get 1.1.1.1 command shows the IP address used for an outbound connection by displaying the route the system selects to reach an external host. Unlike ping, it doesn’t send any packets; it simply asks the kernel to simulate the routing decision and display the result.

To use it:

  1. Open the Terminal app, then type ip route get 1.1.1.1 and press Enter.The ip route get command in a terminal, displaying the source IP.
  2. Look for src followed by an IP address.

The “src” value shows the source IP address the system would use to reach that destination. This makes it easier to identify the active interface without manually reviewing every connection.

Alternative command (legacy): ifconfig

The “ifconfig” command was widely used in older Linux systems. It belongs to the net-tools package, which has been mostly replaced by newer utilities. To use it:

  1. Open the Terminal app, then type ifconfig and press Enter.The ifconfig command, displaying network all connections.

If the “ifconfig” command isn’t found, it usually means the net-tools package isn’t installed. The information it provides is the same as "ip addr,” showing all network interfaces and their assigned IP addresses.

Using the Linux GUI

For those who prefer not to use the terminal, most Linux distributions provide a Graphical User Interface (GUI). The GUI allows network details to be viewed through menus and settings panels.

Open network settings (GNOME/KDE)

In GNOME (Ubuntu):

  1. Access the Settings app.The Ubuntu application menu with the Settings icon highlighted.
  2. Select the Network tab.The Network section in Ubuntu Settings.
  3. View the IP address.A detailed view of the IPv4 and IPv6 addresses within the Ubuntu Wired network settings.

In KDE-based distributions:

  1. Open the Start menu and select the System Settings tab.The System Settings menu from the application launcher on a Fedora KDE desktop.
  2. Access the Wi-Fi & Internet tab.The Wi-Fi & Internet section within the Fedora KDE System Settings.
  3. Click your active connection, then select IPv4 or IPv6 to view your address.IPv4 and IPv6 configuration properties for a specific wired connection within the Fedora KDE networking settings.

View Wi-Fi vs. Ethernet IP addresses

If both Wi-Fi and Ethernet are available, each connection can have its own IP address, but only the active one handles traffic at any given time. To find the correct address, first identify which connection shows as connected, then open its details panel and look for the IPv4 or IPv6 entry.

Wi-Fi interfaces are typically labeled as wireless, while Ethernet appears as wired. Checking the details of the active connection ensures the IP address you see belongs to the currently active interface.

Displaying a public IP address in Linux

Your ISP assigns a public IP address to your network. It’s the address websites and online services see when you connect to the internet.

In most home and office networks, this works through Network Address Translation (NAT). Devices on the local network use private, non-routable IP addresses, while the router translates their traffic and presents a single public IP address externally.

On Linux, the public IP address isn’t directly assigned to your device in typical NAT setups, so it doesn’t appear in local network configuration files. Instead, you retrieve it by querying an external service that reports the public address your connection appears to come from.

Using online tools

One of the easiest ways to trace an IP address is to use an IP checking website. All you have to do is visit a website that displays the detected IP address, and you’re done. They do this by reading the incoming connection address as reported by your device. This approach is useful when:

  • The system has a graphical interface.
  • Terminal access isn’t preferred.
  • A quick visual check is needed.

If a virtual private network (VPN) is active and functioning correctly, the site will show the VPN server’s IP address. This is because connecting to a VPN masks your ISP-assigned public IP address behind the VPN server’s IP address, helping limit IP address tracking.

Terminal commands for public IP

You can also use the terminal to check your public IP address. This method sends a request to an external service and displays the result. These commands are quick, lightweight, and don’t require opening a browser, which makes them especially useful on minimal or command-line interface (CLI) systems.

Command: “curl ifconfig.me”

One of the most common commands for checking a public IP address is “curl ifconfig.me.” It works by sending a request to the ifconfig.me website, which then returns the IP address it detects from your connection. To use it:

  1. Open the Terminal app.
  2. Type “curl ifconfig.me” and press Enter.Type “curl ifconfig.me” and press Enter.
Troubleshooting “curl” issues

Sometimes the curl command doesn’t work as expected. The system may return an error or say the command isn’t found. Common causes include:

  • The “curl” command isn’t installed: Some minimal Linux distributions don’t include it by default. Install it using your system’s package manager (for example, “sudo apt install curl” on Debian/Ubuntu).
  • No internet connection: If the system isn’t connected to the internet, the request can’t reach the external server. Check the connection and try again.

Linux IP address on servers and headless systems

Not all Linux systems have a desktop environment. Many servers run without a graphical interface. These are often called headless systems because they don’t use a monitor, keyboard, or mouse directly. Below are simple methods for finding your IP address.

How to get your IP on a headless Linux server

On a headless Linux system, the IP address must be checked using terminal commands since there’s no graphical interface. This requires logging into the server locally or remotely, running a command to display all network interfaces, and identifying which connection is active.

If physical access is available, the IP can be checked directly from the console. Otherwise, it may be necessary to review network settings through a hosting provider’s dashboard or the router interface.

Finding the IP of a remote server (SSH)

Secure Shell (SSH) is a protocol for securely connecting to another computer over a network. It allows remote command-line access. To connect via SSH, the remote server's IP address is required. If the address isn’t known, it can often be found through:

  • A cloud hosting control panel.
  • A router’s connected devices list.
  • Network scanning tools within the same local network.

Once connected through SSH, standard terminal commands can be used to confirm the server’s internal IP address. If the server has both a public and a private IP address, the SSH address depends on the network setup. In cloud environments, a public IP is typically used. In local networks, private IP addresses are more common.

How VPNs or containers affect IPs

Network setups can become more complex when additional layers are introduced. Two common examples include:

  • Virtual private network (VPN): A VPN creates an encrypted tunnel between your device and a VPN server. It routes your internet traffic through this tunnel, so external services (like website or app providers) see the VPN server's public IP address instead of your real public IP address. Learn more about this process in our guide to hiding your IP address.
  • Containers: Tools like Docker create isolated environments with their own private internal networks. In the default bridge mode, each container is assigned its own private IP address within Docker’s virtual network. In host mode, the container shares the host machine’s network stack instead of receiving a separate private address. Containers typically do not have their own public IP addresses unless explicitly configured to expose services externally.

In these situations, the main system retains its private IP address on the local network, while the VPN assigns a different public IP address that websites see. At the same time, containers may have their own separate private IP addresses within virtual networks. This can make it appear as though multiple systems are running on a single machine, and it may not be immediately clear which network interface is handling outbound traffic.

Troubleshooting Linux IP address issues

Sometimes an IP address doesn’t appear, or the network doesn’t work as expected. When that happens, a few basic checks can help identify the problem.

What to do if your private IP address doesn’t appear

If no private IP address is listed for your network interface, start with simple checks before assuming there’s a serious problem. Begin by checking the network cable and making sure it’s firmly connected. If you’re using Wi-Fi, confirm that wireless networking is enabled and connected to a network.

Restarting the network service can sometimes resolve temporary glitches, and a full system reboot may also help. If a private IP address still doesn’t appear after these steps, the issue may be related to the network interface status or DHCP configuration.

Check interface status (link up/down)

To check the interface status (link up/down) on Linux, the recommended command is “ip link show.” In the output, look for “UP,” which indicates that the network interface is operational.Linux Terminal showing the "ip l show" command.

Check the DHCP or NetworkManager status

Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses in most home and office networks. If the DHCP service doesn’t respond, the system won't receive an address. One way to confirm whether a request succeeded is to log in to your router or modem and check the DHCP client list for your device.

Alternatively, many Linux desktop distributions manage network connections with NetworkManager. You can verify that the service is running and that a connection is active using tools such as:

  • nmcli: A command-line interface (CLI) tool that lets you view device status, manage connections, and troubleshoot networking directly from the terminal.
  • nmtui: A text-based (curses) interface that provides a simple interactive menu for managing connections without a graphical desktop.

Why you see multiple private IP addresses

It’s common for a Linux system to show more than one private IP address when you inspect network interfaces. This doesn’t indicate a problem. Instead, it reflects how modern systems manage multiple network connections.

A Linux machine may have multiple private IP addresses because:

  • It supports both IPv4 and IPv6.
  • It has multiple network interfaces, such as Ethernet and Wi-Fi.
  • Virtual machines or containers are running.

No internet after getting an IP

Sometimes a system successfully receives an IP address but still can’t access the internet. This usually means the issue isn’t the address itself, but another part of the network configuration. Below are some troubleshooting tips to help resolve the problem.

Check the gateway and routes

The default gateway acts as the exit point from the local network. If the gateway is incorrect or missing, traffic intended for external networks may not leave the local network. As a result, external websites won’t load, and connection attempts may time out.

Here are some quick tests you can try:

  • Check your default gateway: Run the “ip route show” command and look for a line starting with “default via <gateway_IP>.”
  • Ping the gateway: Use the “Ping <gateway_IP>” command. If this fails, your system can’t reach the gateway.
  • Check the routing table: Use the “ss -r” command.

Routes determine how traffic moves between networks. If the routing information is wrong, the system may not know where to send outgoing data. Verifying the gateway and routing table helps confirm that traffic is being directed properly.

Check DNS settings

Even if the network connection is active, websites may fail to load if DNS settings are incorrect. DNS works like a phonebook for the internet: it translates domain names into IP addresses. Problems in this process can prevent access to websites and reduce privacy. When DNS is misconfigured:

  • Websites may not resolve.
  • Error messages may appear stating the server can’t be found.
  • Queries may be sent to unintended servers, potentially exposing browsing activity.

To resolve it, try opening a terminal in Linux and running the following command to flush the DNS cache on systems that use systemd-resolved: “sudo resolvectl flush-caches.” Note that this command will not work on distributions that use a different DNS service.

This clears the local DNS cache and forces the system to retrieve updated DNS records, pulling fresh information from the internet. Doing this can help fix problems like websites not loading or errors that say “server not found.”

Changing your local IP address in Linux

There are two main ways to change a local IP address on a Linux system: temporarily (at runtime) or persistently (in configuration). Temporary changes are useful for testing, while persistent changes ensure the system retains the same IP after reboot.

Manual configuration steps (high-level)

Manually setting an IP address involves defining several pieces of information. These values must match the network’s structure. At a high level, manual configuration requires:

  • An IP address: The unique address assigned to the system.
  • A subnet mask: This defines which part of the address identifies the network and which part identifies the device.
  • A default gateway: The router that directs traffic outside the local network.
  • Domain Name System (DNS) servers: DNS translates domain names into IP addresses so websites can load correctly.

All of these settings must align with the local network. If even one value is incorrect, the system may not connect properly.

Temporary vs. persistent IP changes

  • Temporary changes: These can be applied with commands like ip addr add <IP> or by requesting a new address via DHCP.
  • Persistent changes: These require editing system configuration files or using network management tools like NetworkManager to assign a static IP. Learn more in our guide to configuring a static IP address on any device.

FAQ: Common questions about getting an IP address on Linux

How to get the IP address in Linux?

Getting your private (local) IP address in Linux can be done using either terminal commands or graphical tools. Terminal commands like “ip addr” or “hostname -I display” detailed or quick information about your network interfaces and their assigned private IP addresses.

On systems with a graphical user interface (GUI), opening the network settings shows the private IP addresses assigned to Wi-Fi or Ethernet connections. To check your public IP address, you typically need to query an external service instead.

What is the ipconfig command in Linux?

The ipconfig command is a Windows networking tool and isn’t available on Linux. On Linux, the legacy equivalent is ifconfig (from the net-tools package), which can display interface details such as IP addresses and status. Modern Linux systems use the ip command, such as ip addr and ip link, which provide more complete and up-to-date networking information.

How do I find my IP address in the terminal?

Finding your IP address in the terminal is straightforward with a few commands. The “ip addr” shows all interfaces and their IP addresses, while “hostname -I” provides a quick list of active addresses. For public IPs, commands like “curl ifconfig.me” fetch the address seen by external servers. Using the terminal is especially useful on headless systems or servers without a graphical interface.

What to do if my IP address doesn't appear?

If your IP address doesn’t appear, check your network settings and the status of your interface. Ensure cables are plugged in, Wi-Fi is enabled, and the interface shows as “up.” Restarting the network service or checking Dynamic Host Configuration Protocol (DHCP) assignments can resolve temporary issues. If the problem persists, consider contacting your internet service provider (ISP).

How to change my IP address in Linux?

Changing an IP address in Linux can be done temporarily or permanently. Temporary changes are often achieved by using a VPN or a container, which assigns a different IP address for the duration of the session or while the service is running. Permanent changes can come from the internet service provider (ISP) (for public IPs) or be configured locally by assigning a static IP to the device or interface in the system’s network settings.

How to find my public IP address in Ubuntu?

Finding a public IP address in Ubuntu usually involves querying an external service. The curl ifconfig.me command retrieves the address the internet sees, while browser-based tools display the same information visually. Keep in mind that if a VPN is active, the reported public IP may belong to the VPN provider rather than your internet service provider (ISP).

How to get my IP address on a headless Linux server?

Getting an IP on a headless Linux server is done entirely through terminal commands since there’s no graphical interface. Commands like ip addr, hostname -I, or checking the network interface configuration reveal the system’s IP. For remote servers, connecting via Secure Shell (SSH) may also be necessary, and cloud hosting dashboards often list the assigned IP addresses for quick reference.

Take the first step to protect yourself online. Try ExpressVPN risk-free.

Get ExpressVPN
Content Promo ExpressVPN for Teams
Ernest Sheptalo

Ernest Sheptalo

Ernest is a tech enthusiast and Writer at ExpressVPN, where he shares tips on staying safe online and protecting user data. He’s always exploring new technology and loves experimenting with the latest apps and systems. In his free time, Ernest enjoys disassembling devices and learning new languages.

ExpressVPN is proudly supporting

Get Started