How To Find IP Address on Rocky Linux
Finding your IP address is a fundamental task when managing a Linux system, especially in server environments like Rocky Linux. Whether you’re troubleshooting network issues, configuring a static IP, or simply trying to understand your system’s network setup, knowing how to find both your private and public IP addresses is essential.
This guide will walk you through various methods to find your IP address on Rocky Linux, including using terminal commands like ip
and ifconfig
, as well as external tools for retrieving your public IP. Additionally, we’ll cover the differences between static and dynamic IP addresses and provide troubleshooting tips for common network issues.
What is an IP Address?
An IP address (Internet Protocol address) is a unique string of numbers assigned to each device connected to a network. It serves as an identifier that allows devices to communicate with each other over the internet or within a local area network (LAN). Without an IP address, your device wouldn’t be able to send or receive data.
There are two main types of IP addresses: public and private. Each plays a different role in networking, and it’s important to know which one you need depending on the task at hand.
Types of IP Addresses: Public vs Private
Your system may have both a public and private IP address:
- Public IP Address: This is the address assigned by your Internet Service Provider (ISP) that identifies your device on the global internet. It is accessible from anywhere in the world.
- Private IP Address: This is used within your local network (e.g., home or office). Devices within the same network use private IP addresses to communicate with each other. These are not accessible from outside the local network.
Knowing both of these addresses can be helpful for tasks such as remote access, server configuration, or resolving connectivity issues.
How To Find Your Private IP Address on Rocky Linux
Your private IP address is what identifies your device within a local network. There are several ways to find it using command-line tools commonly available in Rocky Linux.
Using the ip
Command
The ip
command is the modern replacement for the older ifconfig
command and provides more detailed information about your network interfaces. To find your private IP address, follow these steps:
- Open a terminal window on your Rocky Linux system.
- Type the following command and press Enter:
ip addr show
- You will see output similar to this:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 08:00:27:12:34:56 brd ff:ff:ff:ff:ff:ff inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic enp0s3 valid_lft 86399sec preferred_lft 86399sec inet6 fe80::a00:27ff:fe12:3456/64 scope link valid_lft forever preferred_lft forever
- The line starting with
inet
shows your IPv4 address (e.g.,192.168.1.100
). The line starting withinet6
shows your IPv6 address.
Using the Deprecated ifconfig
Command
The older ifconfig
command is still available in many distributions, including Rocky Linux, although it has been deprecated in favor of the more robust ip
. If you prefer using it or if it’s already part of your workflow, here’s how you can find your private IP:
- If you don’t have it installed, you can install it using:
sudo yum install net-tools
- Once installed, run:
/sbin/ifconfig
- The output will look something like this:
enp0s3 Link encap:Ethernet HWaddr 08:00:27:12:34:56 inet addr:192.168.1.100 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fe12:3456/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:12345 errors:0 dropped:0 overruns:0 frame:0 TX packets:12345 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1234567 (1.2 MB) TX bytes:1234567 (1.2 MB)
- Your private IPv4 address will be listed next to “inet addr:“, while IPv6 addresses will appear under “inet6 addr:“. In this case, it’s again
192.168.1.100
.
How To Find Your Public IP Address on Rocky Linux
Your public IP address is what identifies your system on the broader internet, outside of your local network.
Using External Services via Command Line Tools
You can easily retrieve your public-facing IP using external services that return this information by querying their servers.
-
- Curl Method:
Run this command:
curl ifconfig.me
It will return just the public IPv4 address of your machine.
-
- Curl with ipinfo.io:
Another option is:
curl ipinfo.io/ip
This also returns only the public-facing IPv4.
-
- `dig` Method:
You can use DNS queries with `dig`:
dig +short myip.opendns.com @resolver1.opendns.com
This method queries OpenDNS servers to return your public IPv4.
These methods work by sending requests to external services that detect and return your public-facing IP.