Ever wonder where your computer lives on the Internet?
Like your home address, your Ubuntu system also has a digital address known as an IP address — a unique set of numbers that identifies your device on a network.
Knowing your IP address in Ubuntu is crucial for network administration activities such as connecting to a device or a network, troubleshooting network issues, and configuring software.
This easy-to-follow guide will walk you through the simple steps to locate your IP address in an Ubuntu environment. We will cover four simple ways you can use to find your IP address in Ubuntu.
How to Find the IP Address in Ubuntu Via the Terminal
Many Ubuntu users prefer using the terminal because it is quick and straightforward.
Let’s explore three simple commands (hostname, ip, and ifconfig) you can use to find the IP address of your Ubuntu computer.
Method #1: Check the IP Address with the hostname Command
Launch the terminal and enter the following command:
# hostname -i
The -i flag tells the hostname command to display the machine’s IP address.
Here’s the output on our test Ubuntu system:
Method #2: Check the IP Address with the ip addr Command
The next method uses the ip addr command. Alternatively, you can use the ip addr show variation of the command in the terminal:
# ip addr
The ip addr command provides detailed information about the ways your device is connected to the Internet.
For instance, you can see that our test system has an IPv4 address in the inet entry (inet 78.159.101.29/26) and an IPv6 address in the inet6 entry (fe80::d6ae:52ff:fec5:d1a9/64).
Method #3: Check the IP Address with the ifconfig Command
This method is especially useful for users who are coming from a Windows background and are more familiar with the ipconfig command.
The syntax of the command is as follows:
# ipconfig
This command will produce the following output:
The ifconfig command is often considered a direct counterpart of ipconfig in Ubuntu. It is supported by all major versions and you can easily use it if you are interested in how to check the IP address in Ubuntu 20.04 via the command line or in the terminal.
How to Check the IP Address in Ubuntu From the GUI
If you prefer checking the IP address of your Ubuntu system through the GUI, you should first login in the server’s GUI.
Next, go to Settings (You can either go directly or search for it through the system’s search bar:
and choose Advanced Wired Settings (the gear icon) from the Network section.
A new window with details about your wired connection settings will pop up. Look for your Ubuntu system’s IP addresses under IPv4 Address and IPv6 Address:
How to Check IP Address in Ubuntu 20.04
While we recommend using the latest stable Ubuntu version on your server, we understand many users prefer the older Ubuntu 20.04.
So, if you are looking for how to check the IP address in Ubuntu 20.04 in the terminal or via the command line (usually through a script) we recommend the ifconfig command. This command is well supported in Ubuntu 20.04 and you can use the name of a specific network interface with the command to get a more concise output in the terminal.
How to Find IP Address in Laptop
If you have an Ubuntu laptop, you can check the IP addresses assigned to your machine by using the cURL command in the terminal. The syntax of the command is as follows:
View IPv4 Address of Your Laptop
Run the following command in the terminal to see the laptop’s IPv4 IP address:
# curl -s ipv4.icanhazip.com
View IPv6 Address of Your Laptop
If you also need the IPv6 address, run the following command in the terminal:
# curl -s ipv6.icanhazip.com
Alternatively, you can launch a browser tab and visit the following web addresses:
For IPv4 address: https://ipv4.icanhazip.com/
For IPv6 address: https://ipv6.icanhazip.com/
Find Local IP Address Through hostname
You can also use the hostname command to view the local IP address of your system. The syntax of the command is as follows:
# hostname -I
Note that the output shows the local IP address (both IPv4 and IPv6) assigned to your machine.
Types of IP Addresses
Now that you know how to check IP address on Ubuntu and laptops, let;s take a closer look at the idea of IP Address.
IP addresses can be divided on the basis of format and accessibility.
IP Addresses by Format
IP addresses are available in the following two major formats – IPv4 and IPv6.
Addresses
- An older and more common IP address.
- Contains four sets of numbers in this format: 000.000.000.000
- Each set ranges from 0 to 255.
- There can be about 4 billion possible IPV4 addresses.
- IPv4 addresses are used for most devices and websites connected to the Internet.
IPv6 Addresses
- Newer and advanced IP address type.
- Solves the issue of the impending shortage of IPv4 addresses.
- Contains numbers and letters like: 2001:0db8:85a3:0000:0000:8a2e:0370:7334.
- IPv6 offers an incredibly large number of unique IP addresses.
IP Addresses by Accessibility
Every Ubuntu server on a network needs a unique IP address because network conflict can arise if two computers share the same IP address.
Newer network configurations can sort this out and ask you to fix it. But some older systems might mix it up and try to send a packet to two addresses. Most systems have public and private addresses to avoid this scenario.
Private IP Address/h4>
- The private IP address is used within the network.
- It often starts with 192.168.x.x.
- Your computer gets a private IP address assigned automatically in smaller networks.
Public IP Address
The public IP address is seen by websites when you visit them.
Conclusion
In this guide, we presented three commands (ifconfig, ip addr, and hostname) to find your IP address in Ubuntu. We also covered how to check IP address in Ubuntu 20.04, a popular version of the server OS. Additionally, we covered how to find IP address in laptops so that you can see the IPv4 and IPv6 addresses assigned to your machine.
FAQs
Q. How can I find my IP address in Ubuntu using the command line?
To find your IP address in Ubuntu, you can use any of these commands: ip address show or ifconfig. These commands will display information about your network interfaces, including the IP addresses assigned to them.
Q. What is a public IP address?
A public IP address is assigned to your device by your internet service provider (ISP) that allows you to communicate with other devices and servers on the Internet.
Q. What is a private IP address?
A private IP address is assigned to your device on a local network, such as your home or office network. It allows your device to communicate with other devices within the same network.
Q. How can I find my public IP address in Ubuntu?
To find your public IP address in Ubuntu, use the next-mentioned command: curl ifconfig.me. It’ll retrieve your public IP address from a web service.
Q. What is the difference between a public and private IP address?
A public IP address is used for communication between devices on the internet, while a private IP address is used for communication within a local network.
Q. Is there an Ubuntu equivalent of Windows ipconfig command?
If you have a Windows background, you can use the ifconfig command to check IP address in Ubuntu. The command will display information about your network interfaces, including the IP addresses assigned to them in a familiar format.