Oct 11, 2023 4 min read

How to Find your IP Address on the Linux

Find your IP Address on the Linux with our step-by-step tutorial. It is a unique numerical label assigned to every device on the internet.

Find your IP Address on the Linux
Table of Contents


Before we begin talking about how to find your IP Address on the Linux let’s briefly understand - What is an IP Address?

An IP address is a unique numerical label assigned to every device on the internet. It acts as an identifier, allowing devices to communicate and exchange data with each other. IP addresses consist of four sets of numbers separated by periods, such as

They serve two main functions: network identification and location addressing. IP addresses are crucial for accessing websites, sending emails, and connecting to the internet. Understanding IP addresses helps users troubleshoot network issues and maintain secure internet connections. There are two types of IP Addresses, IP Version 4 (IPV4) and IP Version (IPV6).

In this tutorial, you will find your IP Address on the Linux. We will also address some of the FAQs related to IP Addresses.

Advantages of IP Address

  1. Communication: IP addresses enable devices to connect and communicate over the internet, allowing seamless information exchange.
  2. Website Accessibility: IP addresses facilitate easy access to websites, enabling users to browse and engage with online content.
  3. Device Identification: IP addresses uniquely identify devices, aiding in network troubleshooting, security management, and device tracking.
  4. Geolocation: IP addresses provide geolocation data, allowing businesses to tailor and target their services based on users' locations.
  5. Secure Connections: IP addresses play a crucial role in establishing secure connections, ensuring safe interactions between devices and protecting sensitive information.

Finding Your Private IP Address

1) The Private IP addresses are meant to work within the local network only and are not routable on the internet. The router assigns a private IP to every device in your network. In this way, all the devices like Laptop, Phone, Smart TV, etc. gets a unique IP Address.

Below is the list of some of the IPV4 address ranges reserved for private networks:


2) Use ip, ifconfig or hostname to determine your system's private IP Address.

On Linux, a standard tool for displaying and configuring the network interfaces is ip. To show a list of all network interfaces and the associated IP addresses, use the following command:

ip addr

3) Some more commands that can be used to display the private IP address:

hostname -I

Finding Your Public IP Address

1) A public IP address allows direct access to the internet as it is globally routable and is assigned to a network device. ISP assigns the public IP address to the devices and every device has a unique IP address.

To determine the public IP address, you need to contact the remote server over HTTP/HTTPS and get the IP address from the remote server response.

Type what is my ip in your browser to find your public IP address.

2) In case you are on a headless Linux server, or you want to assign the IP address to a shell script variable you can use command-line tools like dig , curl and wget.

Most DNS providers, like OpenDNS and Google, will allow querying their servers and obtaining your public IP address.

You can even use any of the following commands to get your IP:

dig ANY +short @resolver2.opendns.com myip.opendns.com
dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net

3) Now, there are many online HTTP/HTTPS services. It will respond with your public IP address. Below are some of them:

curl -s http://tnx.nl/ip
curl -s https://checkip.amazonaws.com
curl -s api.infoip.io/ip
curl -s ip.appspot.com
wget -O - -q https://icanhazip.com/

4) If any of the commands above do not work, then there may be a problem with online services.

To avoid remembering the long commands, you can create an alias in your ~/.bashrc or ~/.zshrc file. For like, you can add the below alias:

alias pubip='dig ANY +short @resolver2.opendns.com myip.opendns.com'

Now, whenever you will need to find your public IP, do it by typing pubip in your terminal.

FAQs to Find your IP Address on the Linux

Is there a command to show only the IP address? 

Yes, you can use "hostname -I" or "ip -4 addr show" to view your IP address without additional details.

How can I find the IP address of a specific network interface? 

Run the command "ifconfig [interface_name]" or "ip addr show [interface_name]" to obtain the IP address of a particular interface.

I only want to see the IPv4 address. What command should I use? 

Execute "ip -4 addr show" or "hostname -I | awk '{print $1}'" to get the IPv4 address only.

Can I find my IP address using GUI tools? 

Yes, you can use network manager GUI tools like nm-connection-editor or nm-applet to view IP addresses in a user-friendly way.

Is there a way to find IP addresses of all connected devices on my network? 

The "arp -a" or "nmap -sn [network]" command can help you discover IP addresses of devices on your local network.

Can I change my IP address in Linux? 

Yes, you can change your IP address temporarily using commands like "ifconfig [interface] [new_ip_address]" or assign a static IP permanently in network configuration files.

How do I find my DNS server's IP address on Linux? 

Running "cat /etc/resolv.conf" will display the DNS server's IP address configured in your Linux system.


We hope this detailed tutorial helped you find your IP Address on Linux.

If you have any queries or doubts, please leave them in the comment below. We'll be happy to address them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.