How to find my IP address on Ubuntu Linux

Finding your IP address on Ubuntu can be crucial for various networking tasks, such as setting up a server, troubleshooting connectivity issues, or simply ensuring your network’s security. Ubuntu, with its powerful command-line interface and graphical user interface options, offers multiple methods to discover your machine’s IP address. Whether you’re a seasoned system administrator or a curious novice, understanding how to locate your IP address is a valuable skill in the digital age. Keep in mind that your internal IP address is different from your system’s external IP.
In this tutorial you will learn:

  • How to use simple command-line tools to find your IP address
  • The method to check your IP via Ubuntu’s graphical user interface (for desktop users)
  • Where to locate your IP address in system configuration files (for static IP configurations)
How to find my IP address on Ubuntu Linux
How to find my IP address on Ubuntu Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any recent version of Ubuntu Desktop or Server: 16.04,18.04,20.04,22.04,24.04
Software Standard Ubuntu installation
Other Terminal access for command-line methods, GUI access for desktop method
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Discovering Your IP Address on Ubuntu

DID YOU KNOW?
While most Linux administrators are well-versed with networking commands, they may not fully appreciate the advanced capabilities of the ip command from the iproute2 package that has superseded ifconfig in Ubuntu and other modern distributions. This robust suite of tools offers a breadth of features like multiple routing tables for complex network configurations, policy-based routing, and nuanced manipulation of IP addresses, multicast, and routing tables. The ip command’s consistent syntax facilitates intricate scripting and automation, catering to sophisticated network setups such as load balancing and fault tolerance, making it an indispensable tool for the contemporary demands of network administration.

There are several ways to find your IP address on Ubuntu. Depending on whether you are using a desktop or server version, you might prefer a graphical or command-line method. Below are the most common and straightforward ways to check your IP address.

  1. Using the ip Command: A quick way to find your IP address
    $ ip a

    Using the ip a command in Ubuntu’s terminal provides a detailed enumeration of all available network interfaces on your system, along with their corresponding IP addresses. When you execute this command, it will present a list, where each entry represents a different network interface. For wired connections, the relevant interface is often labeled as enp1s0 or eth0, whereas for wireless connections, it is typically identified as wlan0. In the output, alongside the interface name, you’ll find the inet line, which includes the IP address assigned to that interface.

    This address is what enables your machine to communicate with other devices on the network or the internet. For more advanced network configurations, there may also be secondary addresses, virtual interfaces, or tunnel interfaces listed. Each of these will be accompanied by their own IP addresses under their respective sections in the command’s output.

    The result of the ip a command on a Linux system, indicating the local IP address for the network interface.
    The result of the ip a command on a Linux system, indicating the local IP address for the network interface.
  2. Querying Network Manager: Get detailed network information
    $ nmcli device show

    This command not only reveals the IP addresses but also provides extensive network configuration details, such as the gateway and DNS servers for each interface. It even offers insight into IPv6 configurations when they are set up, making it a comprehensive tool for network management and diagnostics.

    the output of the nmcli device show command, highlighting the local IP address, gateway, and DNS server for an IPv4 network configuration and placeholders for IPv6 if configured.
    The output of the nmcli device show command, highlighting the local IP address, gateway, and DNS server for an IPv4 network configuration and placeholders for IPv6 if configured.
  3. Checking Hostname: A simple command to list your IP address
    $ hostname -I

    This command outputs all the network IP addresses associated with your machine.

    The hostname -I showing my local IP address
    The hostname -I showing my local IP address
  4. Inspecting Configuration Files: For static IP configurations, check the relevant network configuration file.

    In modern Ubuntu versions, network settings are managed with netplan, located in /etc/netplan/. Here, you may encounter files like 01-netcfg.yaml,50-cloud-init.yaml or 00-installer-config.yaml, which are used to define network interfaces in a user-friendly YAML format. This system allows for the implementation of advanced network configurations and seamlessly integrates with Ubuntu’s network management services.

    Conversely, older Ubuntu systems rely on the /etc/network/interfaces file for network configuration. It’s a more traditional and less intuitive method, where you’d typically find settings for static IP addresses and network interfaces named eth0, wlan0, and so on. This method is familiar to those accustomed to Unix and Linux networking practices, and knowledge of it is useful for managing legacy systems.



  5. Using networkctl: Another method for systemd users
    $ networkctl status

    This command outputs a comprehensive status report of network interfaces, detailing their operational state as routable or otherwise. It also specifies the local IP address assigned to each active interface, along with the default gateway, offering a quick overview of the network configuration directly from the command line.

    the networkctl status command output on a Linux system, indicating the state of the network interfaces and the local IP address along with the gateway on interface enp1s0.
    The networkctl status command output on a Linux system, indicating the state of the network interfaces and the local IP address along with the gateway on interface enp1s0.
  6. Installing iftop: For real-time IP address monitoring
    $ iftop

    This method involves the iftop package, which you must install on your Ubuntu machine. Once installed, executing the iftop command with sudo allows for real-time network traffic monitoring. This tool gives you visibility into the flow of data packets, showing the IP addresses that your computer is communicating with at any given moment. With sudo privileges, iftop offers an elevated level of detail in the traffic analysis, presenting a dynamic, constantly updating display of network connections and bandwidth usage.

    The image displays the iftop command output, showing the IP and MAC addresses for a network interface.
    The iftop command output, showing the IP and MAC addresses for a network interface.
  7. Utilizing ifconfig: An older method, requires installing net-tools
    $ ifconfig

    This method, leveraging the ifconfig command, remains prevalent in older systems and with users who have a longstanding familiarity with it from other Unix-like operating systems. It is a testament to the enduring utility of traditional tools in networking that provide essential information such as IP addresses, network masks, and MAC addresses, as well as traffic statistics that can be crucial for network troubleshooting and configuration. Despite the availability of newer tools, ifconfig continues to be a cornerstone utility for many due to its simplicity and comprehensive output.

    The image showcases the ifconfig command output, listing network interface details such as the IP address, netmask, broadcast address, and the MAC address, alongside statistics on transmitted and received data packets.
    The image showcases the ifconfig command output, listing network interface details such as the IP address, netmask, broadcast address, and the MAC address, alongside statistics on transmitted and received data packets.
  8. Through the GUI (For Desktop Users): Access your IP address via Settings

    In Ubuntu’s desktop environment, you can effortlessly find your IP address without using the command line. Begin by navigating to the Settings through the system menu. Within the settings, select Network to view your active connections. Here, click on the gear icon adjacent to the network you are connected to, such as your wired or wireless connection.Upon clicking, a detailed settings window will appear, providing various network details.

    Within the Details tab of this window, you will find your current IP address, along with other valuable information such as the hardware (MAC) address, the gateway your system is using to connect to the internet, and the DNS settings that resolve domain names into IP addresses. This graphical approach provides a user-friendly way to access your network configurations.

    The network settings window on an Ubuntu desktop, where detailed network information, including the IP address, hardware address, default gateway, and DNS settings, is displayed.
    The network settings window on an Ubuntu desktop, where detailed network information, including the IP address, hardware address, default gateway, and DNS settings, is displayed.

Additional Information: How to Find Your External IP Address

Discovering your external (public) IP address in Ubuntu can be useful for various networking tasks, such as remote access or troubleshooting external connectivity issues. Unlike local (private) IP addresses, your external IP is assigned by your internet service provider and is how the internet sees your device. To find it, you can use a command-line tool like curl to fetch your IP from an external service. Execute the following command in your terminal:

$ curl ifconfig.me
or
$ wget -qO- ifconfig.me

This command contacts the ifconfig.me website, which responds with your public IP address. It’s a quick and straightforward method to know how your Ubuntu system appears to the outside world.

Conclusion

Whether you prefer the simplicity of the command line or the visual approach of the GUI, Ubuntu offers various ways to find your IP address. By familiarizing yourself with these methods, you can efficiently manage and troubleshoot your network connections, ensuring a smooth and secure online experience on Ubuntu.