How to know my IP in Linux

IP networks

Which is the command to know the IP in Linux? Sometimes it is necessary know our IP For many cases, it is extremely simple, but if you don't know how to do it, it can be problematic. In almost all operating systems, knowing our IP is simple, just use a command from the terminal and you will get it. In GNU / Linux it is not more complicated and it would be enough to use the equivalent of Windows ipconfig, that is, the ifconfig command.

First say that ifconfig is a very useful command not only to know our IP, but to perform many other tasks related to the network. Of course there are other alternatives to know our IP, even online options that can help you, but in this case we are going to do it locally, since we have the appropriate tools and it is good that we know how to take advantage of the full potential of our Linux distro that in most cases we do not use.

As you know, ifconfig is a program available on UNIX to configure or display parameters of the network interfaces. But in our case, we will use it to know the IP of our equipment. If you want to know more you can use the manual pages (man) of the command where all the possibilities will be detailed. But the basic syntax is as follows:

ifconfig interfaz [dirección [parámetros]]

If we simply use «ifconfig" without quotation marks In the terminal, the result that it gives you will be similar to:

eth0 Link encap 10Mps

Ethernet HWaddr 00:00:c0:90:b3:42 inet addr 192.168.1.2

Bcast 192.168.1.255 Mask 255.255.255.0 UP BROADCAST RUNNING MTU 1500 Metric 0 RX packets 3136 errors

217 dropped 7 overrun 26 TX packets 1752 errors 25 dropped 0 overrun 0

This information is very valuable and we can see different parameters, but in this article we are only interested in one, which is the IP. To know our IP in Linux, we just have to move to the line where «inet addr»And the address that appears immediately after will be our IP. In this case the IP would be 192.168.1.2.

Related article:
Unzip RAR on Linux

If you do not want to use commands to find out the IP in Linux, do a simple search in Google with the text "what is my IP" and you will get countless pages they will tell you what your public IP is and if you browse through a proxy.


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

4 comments, leave yours

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Jimmy olano said

    It seems prudent to clarify that it is our IP address IN OUR LOCAL AREA NETWORK for a certain device or network interface.

    I propose, in a supplementary way, if we want to know our IP address over the internet (through the interface with which we have output), we open a terminal window:

    wget http: / / w ww. websupport .com / -O myIP.txt
    (blanks in web link, truncate spaces to use)

    and then to view said file:
    cat myIP.txt

    1.    Isaac PE said

      Hi jimmy,

      You're right. In the article I talk about the internal IP. Good point to get the external IP. This last one I have passed it by because for the majority of applications of normal users, the one that I teresa is internal. For example for ssh connections on a local network, etc.

      A greeting!

  2.   JC said

    In some distributions ifconfig is no longer present and you have to do it with the command «ip» in the form «ip addr list»

    a greeting

  3.   Walter O. Dari said

    Well, to avoid having to go to a page or download something to know what public IP we have, you can use ...

    curl ipconfig.me/ip

    … The answer usually takes time.

    Obviously curl has to be installed, although I think that in some distributions it installs them automatically with the rest of the "package".

    It is true that generally we need to know the local IP, if we also want to see the rest of the network, with nmap it is simple:

    nmap -sp 192.168.0.0/24

    Replace 192.168.0.0 with whatever is necessary according to our network configuration.

    Greetings!