1. What Is an IP Address?
An IP address is a unique number used to identify devices on a network. It is essential for sending and receiving data across the internet or a local network. There are two major types of IP addresses: IPv4 and IPv6. IPv4 uses a 32-bit address format, such as “192.168.0.1,” while IPv6 uses a 128-bit address format, such as “2001:0db8:85a3:0000:0000:8a2e:0370:7334.” IPv6 supports a significantly larger address space, allowing more devices to connect to the internet.
2. Basic Commands to Check IP Addresses in Ubuntu
Ubuntu provides various commands to check IP addresses. Using the following commands, you can easily identify the IP address assigned to your system.
2.1 ip addr show Command
The ip addr show command is a powerful and recommended tool in modern Linux distributions. It displays both IPv4 and IPv6 addresses assigned to network interfaces.
Example Usage:
$ sudo ip addr showExample Output:
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.1.10/24 brd 192.168.1.255 scope global dynamic ens33
valid_lft 86381sec preferred_lft 86381sec
inet6 fe80::250:56ff:fe9a:de91/64 scope link
valid_lft forever preferred_lft forever- The value following inet, such as “192.168.1.10/24,” represents the IPv4 address. “/24” is CIDR notation, indicating the subnet mask (equivalent to 255.255.255.0). The first 24 bits represent the network portion, and the remaining 8 bits represent the host portion.
- The value following inet6 is the IPv6 address—for example, “fe80::250:56ff:fe9a:de91.”
Additional Notes:
brdindicates the broadcast address.scopespecifies the address scope:globalfor internet-wide access, andlinkfor link-local addresses within the same network segment.
2.2 hostname -I Command
The hostname -I command displays all IP addresses assigned to the system, separated by spaces. This is useful when you need only the IP addresses without additional details.
Example Usage:
$ hostname -IExample Output:
192.168.1.10 fe80::250:56ff:fe9a:de91- The first value is the IPv4 address, and the next value is the IPv6 address. This command displays only assigned IP addresses without extra interface information.
Default Interface IP Address:
- To display the IP address of the default network interface, run the following command:
$ ip route get 1.1.1.1This command shows the route information to the specified address and identifies the default interface.
2.3 curl ifconfig.me Command
The curl ifconfig.me command retrieves your public IP address by accessing an external service. This is useful when you need to know how your system appears on the internet. However, note that this method communicates with an external server, so consider privacy implications.
Example Usage:
$ curl ifconfig.meExample Output:
203.0.113.50This output shows your global IP address as seen from the internet.
Privacy Considerations:
curl ifconfig.mesends IP-related information to an external server. If privacy is a concern, consider checking your public IP address via your router settings or another local method.
Public vs. Private IP Addresses:
ip addr showtypically displays private IP addresses used within a local network.curl ifconfig.mereveals your global public IP address. Due to NAT (Network Address Translation), internal and external IP addresses often differ. NAT enables multiple devices to share a single public IP while accessing the internet.

3. The Deprecated ifconfig Command and Its Alternative
ifconfig was once the standard network management command in Linux but is now deprecated and not installed in most modern distributions. The more powerful ip command is recommended instead.
Installing ifconfig:
$ sudo apt install net-toolsExample Usage:
$ sudo ifconfigExample Output:
inet 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255- The value after “inet,” such as “192.168.1.10,” represents the IPv4 address.
Limitations of ifconfig:
ifconfigmay not display all interfaces, especially virtual ones, and might omit IPv6 details. Theipcommand provides more comprehensive and modern network information.
4. Using NetworkManager Tools
4.1 nmcli Command
nmcli is a command-line tool for managing NetworkManager. It allows you to view detailed information about network devices. If nmcli is not installed, use the following command:
Installation:
$ sudo apt install network-managerExample Usage:
$ nmcli device showExample Output:
IP4.ADDRESS[1]: 192.168.1.10/24- The value following “IP4.ADDRESS[1]” indicates the IPv4 address.
Checking NetworkManager Status:
- To verify whether NetworkManager is running, use:
$ systemctl status NetworkManager5. Checking IP Addresses in Different Situations
Checking IP addresses is important for various networking tasks, including troubleshooting, server configuration, and preparing for remote access. Knowing multiple commands ensures you can choose the best method depending on the environment and context.
Troubleshooting Tips:
- Network Issues: If an IP address is not assigned correctly, you may fail to connect to the network. Use
ip addr showto verify the configuration and confirm that the correct interface has an IP address. Certain network configuration changes may requiresudoprivileges. - Remote Access: When configuring remote access to a server, you must know the correct public IP address. Use
curl ifconfig.meto confirm the global IP address and ensure port forwarding on your router is properly configured. - Connection Tests: To verify network connectivity, use the
pingcommand to confirm communication with a host. For example, runping google.comto test internet access. Additionally, usetracerouteto identify routing paths and pinpoint where delays or issues occur.
$ ping google.com
$ traceroute google.com- The ping results show response times and packet loss. Lack of response may indicate connection issues.
- traceroute displays latency at each hop, helping you determine where delays occur.
6. Summary
There are multiple ways to check IP addresses in Ubuntu, and each method offers unique advantages. ip addr show provides detailed network information, while hostname -I offers a simple way to obtain IP addresses. curl ifconfig.me helps identify your public IP address but requires privacy awareness. Although ifconfig is deprecated, it may still be useful in specific situations.
By mastering these commands, you can manage networking tasks more efficiently on Ubuntu. Understanding IP address concepts and NAT (Network Address Translation) provides deeper insights into network configuration and security. Refer to official documentation and additional learning resources to enhance your network administration skills.
Reference Resources:


