Whether you're configuring remote access or troubleshooting connectivity, knowing your public IP address is a key step. This guide outlines several reliable methods to retrieve it on Linux systems using terminal commands or a browser.
Method 1: Using the curl Command
Open a Terminal window.
Run the following command:
curl ifconfig.me
Your public IP address will be displayed.
Installing curl (if not already installed):
Debian-based:
sudo apt install curl
Red Hat-based:
sudo dnf install curl
Arch-based:
sudo pacman -Sy curl
openSUSE-based:
sudo zypper install curl
Method 2: Using the dig Command
Open a Terminal window.
Run the following command:
dig +short myip.opendns.com @resolver1.opendns.com
Your public IP address will be displayed.
Installing dig (if not already installed):
Debian-based:
sudo apt install dnsutils
Red Hat-based:
sudo dnf install bind-utils
Arch-based:
sudo pacman -Sy bind
openSUSE-based:
sudo zypper install bind-utils
Method 3: Using the wget Command
Open a Terminal window.
Run the following command:
wget -qO- ifconfig.me
Your public IP address will be displayed.
Installing wget (if not already installed):
Debian-based:
sudo apt install wget
Red Hat-based:
sudo dnf install wget
Arch-based:
sudo pacman -Sy wget
openSUSE-based:
sudo zypper install wget
Method 4: Using a Web Browser
- Open any web browser.
- Search for “What is my IP address.”
- Your public IP will appear at the top of the search results.
- Alternatively, visit whatismyipaddress.com for a direct display.
These methods offer quick and effective ways to check your public IP address across various Linux distributions. Choose the one that best fits your workflow or system setup.
