Reading Time: 2 minutes

Change-IP-Address-on-Linux

When troubleshooting network issues, setting up new connections, or configuring a firewall, knowing the IP address of your device is the most vital component of any of those processes.

There are two major types of IP addresses, Public and Private IP addresses. A public IP address is the device’s IP address visible to every device connected to the internet. A private IP address is the IP address used by the router to identify the devices on the same local network.

Today’s article will show you how to find your IP address in Linux. So without further ado, let’s get started.


Find Your Public IP Address on Linux

Public IP addresses are unique and assigned by the internet service provider (ISP). One of the most easier ways to figure out your public IP address is to hop on a desktop and visit What is my IP Address?, IP2location.com or IPaddress.com.

However, Linux users can determine their public IP address using command-line tools such as dig, curl and get.

To find your public IP address on Linux using the command-line, paste the following commands on your command line application:

  • curl -s https://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/
  • dig ANY +short @resolver2.opendns.com myip.opendns.com
  • dig ANY +short @resolver2.opendns.com myip.opendns.com
  • dig ANY +short @ns1-1.akamaitech.net ANY whoami.akamai.net


Four Ways To Find Your IP Address on Linux

Here are four different ways to find your IP address on Linux:

Method 1: On the Desktop

To find your IP address on Linux using the user interface, follow the steps mentioned below:

  1. Click on the Network Connection icon (Wi-Fi icon) at the top right corner of the title bar.
  2. A drop-down menu will appear in front of you.
  3. Select Connection Information from the available option.
  4. From the Connection Information windows, you can see your IP address written in front of the IP Address field.

Method 2: On the Shell with IP command

To find your IP address through the terminal, follow the steps below:

  1. First, launch the terminal on your Linux by pressing Ctrl+ T, or you can click on the terminal icon directly if it is shown on your taskbar.
  2. Type the following command in terminal: ip addr show.
  3. Press Enter.
  4. As soon as you press Enter, you will be shown various information on the screen.
  5. The 4th line, which starts with inet, will have your IP address written next to it.

Method 3: On the Shell with ifconfig command

To find your IP address through the ifconfig command, follow the steps below:

  1. Launch Terminal on your Linux by pressing Ctrl+ T, or you can click on the terminal icon directly if it is shown on your taskbar.
  2. Type the following command in terminal: /sbin/ifconfig
  3. Press Enter.
  4. As soon as you press Enter, you will be shown various information on the screen.
  5. The 4th line, which starts with inet addr, will have your IP address written next to it.

Method 4: On the Shell with hostname command

To find your IP address through the hostname command, follow the steps below:

  1. Launch Terminal on your Linux by pressing Ctrl+ T, or you can click on the terminal icon directly if it is shown on your taskbar.
  2. Type the following command in terminal: hostname -I
  3. Press Enter.
  4. As soon as you press Enter, you will be shown your IP address on the screen.

Use 3rd party websites to get your IP at shell prompt

You can also use third-party websites to find your IP at shell prompt. However, we don’t recommend this method due to security reasons. It’s best to stick with one of the methods discussed above.

If you still want to go with this method, here are the commands you would need to add to your Linux terminal:

curl checkip.amazonaws.com
curl ifconfig.me
curl icanhazip.com
curl ipecho.net/plain
curl ifconfig.co
## store output in $server_ip ##
server_ip="$(curl ifconfig.co)"
## Display it ##
printf "Server public ip4 %s\n" $server_ip


Finding Public/WAN IP address on a router

Some routers also allow you to log in to its panel through the Linux terminal. All you need to do is use telnet or ssh command prompts. Enter the following commands on your terminal to find your public/ WAN IP address of your router:


telnet your-router-ip-here
ssh user@your-router-ip-here
telnet 192.168.0.254
ssh admin@192.168.1.254
[admin@dd-wrt ~]# ifconfig eth1 | grep ‘inet addr:’
[admin@dd-wrt ~]# ip addr show nas01


Different Countries IP Addresses:

With these IP Addresses you can unblock various channels.

Final Thoughts

We hope that our article on how to find your IP Address in Linux will help you find out your IP address on Linux easily.

IP addresses give our devices an identity so that we can recognize them whenever we want to.

Knowing your device’s IP address is also essential in establishing communication with other devices on the same network.