Whether you are configuring a web server, setting up an SSH connection, or simply troubleshooting a network issue, knowing your machine’s IP (Internet Protocol) address is a fundamental requirement. In older versions of Linux, the ifconfig command was the standard tool for this job. However, modern Linux distributions, including Ubuntu, have largely deprecated ifconfig in favor of the much more powerful and versatile iproute2 suite. The modern, standard way to check your network configuration is by using the simple ip command.
Finding Your Local IP Address
Your local (or internal) IP address is the address assigned to your Ubuntu machine by your home or office router. It is usually formatted like 192.168.x.x or 10.0.x.x.
- Open your terminal application (press
Ctrl + Alt + T). - Type the following command:
ip addr show
(You can also use the shorthand version:ip a) - Press Enter.
Understanding the Output
The command will output a block of text detailing every network interface connected to your machine. It can look overwhelming, but you only need to focus on a few key parts.
- The Loopback Interface (lo): The first entry is usually labelled
lo. This is the “loopback” interface (address127.0.0.1). It is used by the system to talk to itself. You can ignore this for networking purposes. - Your Primary Interface (e.g., eth0, enp3s0, wlan0): Look for the second or third block of text.
- If you are connected via an Ethernet cable, it will likely be named something starting with
enoreth(e.g.,enp3s0). - If you are connected via Wi-Fi, it will likely start with
wl(e.g.,wlan0orwlp2s0).
- If you are connected via an Ethernet cable, it will likely be named something starting with
- Finding the IP Address: Once you have identified your active network interface, look a few lines down for the word
inet(which stands for Internet network). - The numbers immediately following
inetare your local IP address (for example,inet 192.168.1.55/24). The/24at the end represents the subnet mask; your actual IP address is just the192.168.1.55portion.
A Quicker, Cleaner Command
If you find the output of ip a too messy and only want to see the IP addresses without all the extra MAC address and broadcasting data, you can use a slightly different command to format the output cleanly.
Type: ip -brief addr show
This command condenses the information into a neat table. It lists the interface name on the left, its status (UP or DOWN) in the middle, and the IP address clearly on the right, making it incredibly easy to read at a glance.