Whether you're a DevOps engineer managing cloud servers or a developer setting up a local service, finding an IP address is a fundamental skill in Linux. The modern ip addr command is the new standard, but you'll still find older systems where knowing the classic ifconfig is a lifesaver. This guide cuts through the noise and shows you the practical commands you'll actually use day-to-day to find both private and public IPs.
Ready to streamline your server management? Server Scheduler helps you cut cloud costs by up to 70% by automating when your AWS, Azure, and Google Cloud resources run. Schedule a demo to see how it works!
Stop paying for idle resources. Server Scheduler automatically turns off your non-production servers when you're not using them.
Knowing how to find an IP address in Linux isn't just an academic exercise for system administrators—it's essential for anyone working with networked machines. It serves as the starting point for nearly every network-related task: configuring a firewall, connecting to a remote database, exposing a web application, or even troubleshooting a connection issue like trying to remotely restart a PC. The IP address is the unique identifier that allows devices to locate and communicate with each other, both on a local network and across the vast public internet. To truly grasp modern networking, it's also helpful to understand the difference between IPv6 and IPv4, as you will encounter both in command-line outputs.

The tools for this job have evolved significantly over time. For many years, ifconfig was the default command for network interface configuration. In fact, many veteran Linux users still type ifconfig out of pure muscle memory, despite it being officially deprecated since 2009. This is why modern DevOps professionals and system administrators have largely transitioned to the ip command suite. This newer tool is far more powerful, versatile, and specifically designed for the complex and scalable network infrastructures we manage today. While ifconfig can suffice for a quick check, the ip command is the tool you must master for serious network configuration and troubleshooting.
If you are working on any modern Linux system, the ip command should be your primary tool for all network-related tasks. It has long been the industry standard, having replaced the older ifconfig utility. The ip command is a core part of the powerful iproute2 package and provides a much more comprehensive set of features for network administration. When your goal is simply to find an IP address, the most common command you'll use is ip addr show. However, most users prefer its popular alias, ip a, for its brevity and efficiency. This simple command gives you a complete overview of your system's network configuration.

Running this command lists all your network interfaces along with their assigned addresses. This is how you can find both IPv4 and IPv6 addresses, check MAC addresses, and identify interface names such as eth0 for a wired connection or wlan0 for wireless. In a practical scenario, you might use it to confirm the private IP address of a newly provisioned cloud server or to inspect the network configuration of a Docker container. Its fundamental importance is why we feature it in our Bash scripting cheat sheet.
Pro Tip: Filtering for a Specific Interface When dealing with multiple network interfaces, the output of
ip acan be cluttered. You can easily focus on a single interface by adding its name to the command. For example, runningip addr show eth0will display information only for theeth0interface, making it much easier to find the specific IP you need.
While the ip command is the modern standard, you will inevitably encounter older systems or legacy scripts that still rely on ifconfig. Although it's officially deprecated, understanding how to use ifconfig remains a practical and valuable skill for any system administrator. Running ifconfig by itself will display a list of all network interfaces, similar to ip addr. The output format is more traditional and can seem less organized, so it's important to know what to look for. The most critical piece of information, the IPv4 address, is typically found next to the inet label. For example, you might see inet 192.168.1.105 for the eth0 interface. Another useful, albeit less common, command for quickly retrieving just the IP address is hostname -I. This command provides a clean, fast, and efficient way to see the routable IP addresses for the local machine without any extra details, making it ideal for scripting purposes.
| Feature | ip Command (iproute2) |
ifconfig (net-tools) |
|---|---|---|
| Availability | Standard on all modern Linux distros | Often not installed by default on new systems |
| Functionality | Manages IPs, routes, tunnels, and more | Primarily for basic interface configuration |
| IPv6 Support | Full, native support for IPv6 | Limited and less intuitive support |
| Output Format | Consistent and easily parsable for scripts | Varies by system; less script-friendly |
| Development | Actively maintained and developed | Deprecated; no new features being added |
Discovering your server’s public IP address requires a different approach than finding its private one. Internal commands like ip addr are excellent for revealing private IPs—the addresses used exclusively within your local network (LAN). However, your public IP is the address that the rest of the world uses to see and interact with your server on the internet. To find this external-facing address, you need to query an outside service that can report back what it sees.

The curl command is perfectly suited for this task. By running a simple command like curl ifconfig.me or curl icanhazip.com, you can contact one of these public services. They are designed to do one simple thing: echo your public IP address directly back to your terminal. This method provides a quick and reliable way to verify how your server is perceived on the public internet. For more useful command-line tricks, you might appreciate our guide on how to download a file with SSH. If you are working within a cloud environment like AWS, there is an even more efficient method. Cloud providers offer a metadata service that you can query directly from the instance. For example, on an AWS EC2 instance, running curl http://169.254.169.254/latest/meta-data/public-ipv4 will instantly return the public IP without needing to reach an external service. This technique is indispensable for automation scripts.
Knowing your server's IP is one thing, but understanding how it communicates with the outside world is where real troubleshooting begins. A fantastic command to find ip address in linux and, more importantly, its path, is ip route. This command peels back the curtain on your system's routing table, showing you the exact path your server's outbound traffic takes—including its default gateway. The ip route command has been a cornerstone of Linux networking since the iproute2 suite was introduced. Today, it's the standard for network management on the vast majority of servers. Understanding routing is also critical for cost management in the cloud, as misconfigured routes can lead to unnecessary data transfer fees. For a deeper dive, this handy IP command cheat sheet is a valuable resource.
For more granular diagnostics, a go-to command is ip -s link. This provides a detailed statistical breakdown for each network interface, showing you valuable information about received (RX) and transmitted (TX) packets.
This output is not just a wall of numbers; it tells a story about your network's health. Metrics like rx_dropped and tx_errors are goldmines for debugging. A consistently high number of dropped packets, for example, is often a tell-tale sign of an under-provisioned machine struggling to keep up with network traffic. It turns raw data into a clear signal that your infrastructure needs attention. If you're seeing connection problems that routing and packet stats can't explain, our guide to fixing the Connection Refused error might just have the answer you're looking for.
Hopefully, this guide has equipped you with the command-line tools you need to quickly find IP addresses on any Linux system. Mastering the terminal is a significant part of being an effective administrator. If you are managing cloud servers, the next logical step is to optimize your infrastructure. Server Scheduler can slash your cloud bill by up to 70% by automating when your development, test, or staging resources run. Stop paying for servers you aren't using. Start your free trial and see how much you can save.