An IP (Internet Protocol) address is a unique identifier assigned to devices on a network, allowing them to communicate with each other. On Linux systems, it’s common to need to find the IP address of your machine, whether for network troubleshooting, remote access, or configuration purposes. In this blog post, we’ll explore different methods to find your IP address on Linux, including the use of the
hostname commands. We’ll also discuss the difference between private and public IP addresses.
Finding Your IP Address Using the ip Command
ip command is a modern and versatile tool for managing network interfaces on Linux. It has largely replaced the older
ifconfig command and is now the preferred choice for many Linux distributions.
To find your IP address using the
ip command, you can use the following command:
ip addr show
This command displays detailed information about all network interfaces on your system. Look for the
inet entry associated with your network interface (e.g.,
eth0 for Ethernet or
wlan0 for Wi-Fi). The IP address is listed next to the
If you want to display information for a specific network interface, you can specify the interface name as follows:
ip addr show eth0
eth0 with the name of the network interface you’re interested in.
Finding Your IP Address Using the ifconfig Command
ifconfig command is an older tool for managing network interfaces, but it’s still available on many Linux systems. To find your IP address using the
ifconfig command, simply run:
This command provides information about all active network interfaces. Similar to the
ip command, look for the
inet entry associated with your network interface to find the IP address.
Finding Your Public IP Address Using the hostname Command
The methods mentioned above are used to find the private IP address of your machine within your local network. However, if you’re connected to the internet, you also have a public IP address assigned by your internet service provider (ISP).
To find your public IP address, you can use the
hostname command with the
-I option as follows:
This command displays all IP addresses associated with your machine, including your public IP address if you’re connected to the internet.
Finding Your Public IP Address Using Web Services
You can also find your public IP address using web services that provide this information. For example, you can use the
curl command to query one of the following services:
curl ifconfig.me curl icanhazip.com curl ifconfig.co
Each of these services will return your public IP address.
Finding your IP address on Linux is a simple and straightforward task that can be accomplished using various commands and tools. Whether you’re using the modern
ip command, the classic
ifconfig command, or web services, you can quickly find both your private and public IP addresses.
We hope you found this tutorial helpful and that you now have a better understanding of how to find your IP address on Linux. Whether you’re a system administrator, network engineer, or Linux enthusiast, knowing how to find and work with IP addresses is an essential skill in the world of networking.
A Special Offer
But wait, that’s not all!
If you want to become a true Linux ninja, you’ve got to check out my new e-book called “Shell Samurai – Master the Linux Command Line.” 📚🥷
This e-book is jam-packed with tips, tricks, and techniques that will help you master the Linux command-line like a samurai.
Whether you’re a beginner or an experienced user, Shell Samurai has something for every Linux user.
What are you waiting for?
Grab your copy of “Shell Samurai – Master the Linux Command Line” today and start your journey to becoming a Linux command line master!
Click the link below to grab your copy, and use coupon code KERNEL for 20% off: