An IP address is a sequence of numbers assigned to each computer to identify its logical location within a network. Devices in a network must have unique IP addresses to ensure traffic is routed accurately and delivered to the correct computer.
IP addresses are the first piece of information system administrators look for when managing and troubleshooting networked systems.
Find out how to retrieve your IP address using the Linux command line or GUI.
Finding Private IP Addresses in Linux
Private IPs function within a local network and are not directly exposed to the internet. Knowing the private IP address is necessary when configuring advanced network settings, local servers, printers, and other devices on the same internal network.
Access the Linux command line and use one of the commands below to find your private IP address.
Note: The examples in this article are presented using Ubuntu 22.04.
Using ip Command
The system will scan hardware and display the status of each network adapter. The entries include one for a wired (Ethernet) adapter and a wireless (Wi-Fi) adapter. You may also have an entry for a virtual adapter.
inet line shows the IPv4 address assigned to that interface. In this example, the private IPv4 for the Ethernet interface is:
The IPv6 address for the same interface is under the
The numbers after the slash,
/64, specify the length of the network prefix, and help determine how the IP address space is partitioned into networks and subnets.
Using hostname Command
The Linux hostname command is used to configure the system's hostname but can also retrieve IP address information.
Note: The output of
hostname commands can vary depending on the Linux distribution and local network settings. The
ip command provides a more consistent overview of IP information across different distributions.
Enter the following command to retrieve your private IP address:
In this example, the Ubuntu 22.04 system displays the private IPv4 address.
Using ifconfig Command
The third method to find your IP address involves using the ifconfig command.
ifconfig has been deprecated in favor of the
ip command in many Linux distributions, but it is still available on some systems or can be installed separately.
Enter the following command to check the private IP address on your system:
The system displays all network connections, including connected, disconnected, and virtual. Look for the one labeled UP, BROADCAST, RUNNING, MULTICAST to find your IP address. This lists both IPv4 and IPv6 addresses.
Note: While checking the IP address, you may notice the term Loopback. This refers to an IP address that returns traffic to the same computer. Usually, the loopback address is
If using a point-and-click interface to navigate the Linux system, you can check your IP address by following these steps:
1. Open the Application menu.
2. Type settings into the search bar.
3. Click Settings.
4. Open the Network tab.
5. Click the Advanced Wired Settings icon.
6. This opens a new pop-up window with details on wired settings.
Both the IPv4 and IPv6 addresses are listed.
Finding Public IP Address in Linux
Before connecting to a network, computers connect to a router using a local IP address. The router, in turn, connects to a bigger network (like an Internet Service Provider) with its own IP address system. This is the IP address registered on a website when you visit it.
Note: Learn everything you need to know about public and private IP addresses in our article Public vs. Private IP Address.
Using IP Lookup Websites
You can reach out to an external service to find your public IP address. Use a browser to navigate to one of the following online IP lookup tools:
The websites typically display the public IP address within the browser.
Alternatively, use command-line tools like
dig to display the external IP address. More information is in the sections below.
The curl command is primarily used to transfer data over various network protocols. It can also retrieve a system's public IP address. Enter the following command to display the system's public IP from icanhazip.com:
curl -s https://icanhazip.com
The system returns the public IP address in the terminal.
Note: Did you know that when you use
curl to connect to an insecure website, the output responds with an error? To resolve this issue, visit our guide on making curl ignore certificates.
The wget command retrieves files from the internet, including IP addresses. Use the following command to check your public IP from the Amazon AWS website:
wget -O - -q https://checkip.amazonaws.com
The IPv4 address in this example is
The dig command gathers and displays DNS information. You can use
dig to find out the public IP address of your system by querying an external DNS server. The following command asks the OpenDNS resolver for the public IP address of your system:
dig +short myip.opendns.com @resolver1.opendns.com
+short option simplifies the output and only displays the IP address.
The guide showed how to find a private and public IP address in Linux using the command line, graphical interface, and external IP lookup services.
It is challenging to remember every single Linux network command at a moment's notice. Keep our downloadable Linux network commands cheat sheet handy whenever you need a swift refresher.