The main question that determines the flow of this article is why do we need to know the IP address of our Linux machine(s)? For a Linux superuser or administrator, this question is self-explanatory.
However, for a user who is still learning the ropes in the Linux operating system ecosystem, a brief explanation of the importance of knowing your Linux machine’s IP address is a mandated protocol.
What is an IP Address?
An IP (Internet Protocol) address uniquely identifies any device connected to the internet or on a setup/configured user private network. It uses the same logic as a government ID.
It is through an IP address that you are able to communicate, query, and retrieve information from other machines within a network.
Importance of an IP Address
Consider this scenario, when you open your web browser and visit the URL http://google.com
, you are subconsciously accessing the website via its IP address. The domain name google.com
is just an easier way of accessing the server without having to memorize its IP address.
If your server (remote or local) is not associated with a domain name, knowing your machines’ IP addresses provides a faster connection route to/from your remote machines and servers.
To perform remote administration and control on your Linux machines, you also need to know their IP addresses. Also, an IP address is important because it facilitates network configuration, especially in scenarios where you need to connect your Linux machine to other IP-address-oriented devices like smartphones, smart TVs, internet routers, and other smart gadgets.
Types of IP Addresses
An IP address can either be Public or Private (192.168.x.x, 10.x.x.x, 172.16.x.x, etc).
A public IP address is mostly associated with website and FTP servers and any user on a web browser can access it or ping its associated server machine from the command line.
A private IP address is mostly restricted to a specific network and cannot be globally pinged or accessed.
This tutorial will take us through various approaches to knowing the IP addresses of our Linux machines via the command line environment.
Find IP Address of Linux System
To find out the IP address of your Linux machine, you need to use the ip command as shown.
$ ip address
Alternatively, you can also use the ifconfig command to determine the IP address of your Linux machine. The ifconfig command is part of the net-tools package, which contains a group of programs that form the base of Linux networking.
$ sudo apt install net-tools [On Debian, Ubuntu and Mint] $ sudo yum install net-tools [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/net-tools [On Gentoo Linux] $ sudo pacman -S net-tools [On Arch Linux] $ sudo zypper install net-tools [On OpenSUSE]
To use the ifconfig command to find out the IP address of your Linux machine, execute the following command on your Linux terminal:
$ ifconfig
You should get the IP address(es) of your Linux machine and their associated network adapter names.
You might also like to read the following related articles:
A reasonable description of public vs private addresses, then after that the article only talks about private addresses, and refers to them as “the IP address”, not “the private IP address”. Bad.