Phone :  +370 (5) 204-1903
Email :  sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to Find Linux IP Address

How to Find Linux IP Address

We all use the Internet Protocol (IP) daily in our day-to-day lives, whether we're all aware of it or not. For example, every time you type a website name or a search term into your web browser, it always looks up to the IP address of the URL and then loads the website you searched.

Linux Tutorial Dec 23, 20 by Matthew Anderson 10 min Read
How to Find Linux IP Address

Knowing the IP address of your device is very important when you are troubleshooting network issues or setting up a new connection or generally when you are configuring a firewall from your device.

IP Addresses can be classified into two categories, i.e., public and private. A public IP is an IP Address that is unique and can be accessed from the Internet or private wifi. Private IP addresses are generally reserved for internal use within your private network without being directly exposed to the Internet. Similarly, there are two types of IP addresses, IP version 4 (IPv4) and IP version 6 (IPv6).

Find Your Private IP Address

Private IP addresses are not routable over the Internet, and they are only meant to work within the local network only. Typically, a private IP address is appointed to each device inside your local area network by your router. 

This thereby gives you a unique IP address for all the devices you have within the local area network, such as your phone, laptop, smart TV, printer, media center, etc. Devices on the local network are connecting to the Internet through NAT (network address translation).

These are the various commands that will get you the IP address list to find public IP addresses for your computer or mobile.

  • curl ifconfig.me
  • curl -4/-6 icanhazip.com
  • curl ipinfo.io/ip
  • curl api.ipify.org
  • curl checkip.dyndns.org
  • dig +short myip.opendns.com @resolver1.opendns.com
  • host myip.opendns.com resolver1.opendns.com
  • curl ident.me
  • curl bot.whatismyipaddress.com
  • curl ipecho.net/plain

The following commands will get you the private IP address of your interfaces you use

  • ifconfig -a
  • ip addr (ip a)
  • hostname -I | awk '{print $1}'
  • ip route get | awk '{print $7}'
  • (Fedora) Wifi-Settings→ click the setting icon next to the wifi name that you are connected to → Ipv4 and Ipv6 both can be seen
  • nice -p device show

Public and Private IP Addresses

Private addresses are those which are used in Local Area Networks (LAN). They are also confined to a specific network as well as area. Public addresses are essential for establishing external connectivity to other networks such as the "Worldwide Web" (www) of the Internet.

NAT is an interpretation of a private IP to a public one, and this usually consists of three major types: static, dynamic, and PAT. In a static NAT network, one private IP is mapped to one public IP. A private IP address is mapped to a public IP in a dynamic NAT but from a reservoir of various public IP addresses.

Finding your Way in Networks with the Help of IP

An IP address is the most direct direction to a computer over a network. Other systems, such as DNS and Avahi, also help route one computer to another. Still, when those things or technologies are unavailable or undesired for any unspecified reason, the IP protocol is what you can use. 


The TCP/IP protocol was invented in 1978 by Bob Kahn, Vint Cerf, and many others. TCP stands for Transmission Control Protocol, the protocol responsible for the credible transmission of data over various networks. TCP generally checks the integrity of transmissions and therefore provides for re-transmission if the packets have not been delivered correctly to the right address.

On the other hand, the IP protocol generally deals with routing packets like those sent by TCP. IP stands for Internet Protocol which clearly defines its rules that let packets can be sent from an origin to a destination from computer to computer. 

Under the IP protocol that is there, packets are routed by a path of computers that gets progressively closer to the intended receiver of the packet. A unique IP address identifies each computer or device on the network, and it is a numeric identifier given to that device on the network.

Numerous ways to get IP Address on Linux

There are many ways to get your IP address on a Linux system of your device. There are two types of IP addresses available: a public IP address and a private IP address. The public IP address generally identifies your computer or network from the outside world. 

Your private IP address will identify your machine inside your private network. To get your IP addresses, you can use a mix of commands, particularly as ifconfig, IP, or hostname, or make use of graphical environment apps.

How to Find Your Public IP Address

You can discover your public IP address using various commands to connect you to the Internet for running queries.

Getting your Public IP Address with the help of dig Command

The dig command is a DNS lookup utility command used in Linux. Using it, you can look up your public IP address by connecting to many OpenDNS servers. OpenDNS hosts DNS servers that will help you discover the IP addresses of networks available on the Internet. Here the command is:

dig +short myip.opendns.com @resolver1.opendns.com 

As output, you should get back your public IP address from OpenDNS resolvers. Your IP address will be a series of groups of digits of the format or a variation of this sort.

Use of Curl to Return your Public IP Address

The curl command is a networking thing that allows you to interact with as many servers as you can on the Internet.

By Using wget Instead of curl

Wget will be commonly used for Linux to utilize rather than curl to download data and interact with many other servers on the web. You can also use wget to retrieve your public IP using the subsequent commands:

You also can check the opposite websites that you have reached at some point of your time and curl to ascertain your IP address within the browser. There are many such conditions, like once you are logged on to a Linux server, where you do not have any access to a graphical interface. In such cases, use these shells of commands. They're:

You can always retrieve your IP address using the ifconfig command, which includes various flags that filter the contents for your private IP address. you'll Run the subsequent command inside your shell:

ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v ''|([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v ''|([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v ''

IP address - The ultimate output is your private IP address. this may look very almost like etc. We will also filter the ifconfig output during this case using sed instead. It's a utility for pursuing and reworking streams of text.

You can run the subsequent command to urge your private IP address:

ifconfig | sed -En -'s/;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'

In this exam, we vet filtering ifconfig output to urge your IP address under the TCP/IP protocol. The above commands may fail if you do not have send or ifconfig installed. In this case, the command fails. Try the hostname command and follow the tactic below.

How to Find your Private IP Address using Hostname Command

  • The https://linux.die.net/man/1/hostname command refunds the DNS information available from the machine. You'll find your private address by executing the subsequent command in your shell:
  • $ hostname -I
  • The above command enumerates all of your configured addresses on all network interfaces, including your private IP address.

Get a Private IP Address with the assistance of IP Command.

We can also get the private IP address of an individual by a Linux machine using the IP command. The IP command shows and manipulates the routing, devices, policy routing, and tunnels.

We can use the subsequent variations of the IP command with flags to return to our private IP address. They are;

  • ip route get 1 | awk '{print $NF;exit}'|$ ip route get 1 | awk '{print $NF;exit}'
  • ip route get | head -1 | awk '{print $7}'|$ ip route get | head -1 | awk '{print $7}'| cut -d' ' -f8|$ ip route get | head -1 | awk '{print $7}'|$ ip route get | head -1 | awk '{print $7}'| cut -d' ' -f8|$ ip route get | head -1 | awk '{print $7}'|$ ip route get | head -1 | awk '{print $7}'| cut -d' ' -f8
  • ip route get | head -1 | awk '{print $7}'|$ ip route get | head -1 | awk '{print $7}'| cut -d' ' -f8|$ ip route get | head -1 | awk '{print $7}'|$ ip route get | head -1 | awk '{print $7}'| cut -d' ' -f8|$ ip route get | head -1 | awk '{print $7}'

These commands are the printout of the routing table entries for sending an invitation to all or any alternate servers. This generally involves our private IP address because of the source of the requests.

Finding your Private IP Address from Network Connection

Besides the instructions and, therefore, the being not conversant in them in the browser, here you'll also use Linux administrative applets. You'll have to adjust these instructions to fit your exact Linux distro.

Its ways are;

  • To navigate to your "Menu."
  • To find the "Preferences" tab.
  • to navigate to "Network" or the equivalent for managing your network information
  • You can select the network type (i.e., wifi, Ethernet, or other)
  • You can view your private IP address under the printed information about your IP
  • Suppose these usually won't add a strictly command-line environment but will work on desktop Linux systems. If you're on a command-line only login, then you'll get to try the opposite command-based methods given above.


Linux is supposedly one of the most preferred software to generate and also find an IP address. However, due to very few people knowing that software like Linux makes it a little lagging behind. If one knows all the structures and required data to use Linux, it becomes the best software to find an IP address. Despite all its drawbacks, Linux provides a huge number of ways to find out one's IP address, making it more user-friendly and too free of cost.

author img

Matthew Anderson

Leave A Comment