Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

How do I find my network information - in Linux?

Jack Wallen
Apr 20, 2010
Updated • Dec 27, 2012
Linux
|
10

Taking a cue from Martin's helpful article (see "How do I find my IP Address") I thought it would be a good idea to offer the same information for the Linux operating system. But with Linux there is one issue to get around - that of the number of different tools available to use to find this information. Because there are so many graphical tools with which to find networking information, I thought it would be best to simply tackle this with everyone's favorite tool - the command line.

In this article I will show you how to find out various networking information on your Linux system. All of these tasks can be handled by any skill level of user, so don't think you have to be an ubergeek, hacker-type in order to gain this information.

IP Address

Figure 1

Let's start off with the IP Address. Of course, before you do anything, you need to open up a terminal window. Once you have that open you can then issue the necessary command. The command for finding your IP Address is ifconfig. When you issue this command you will receive information for every network connection you have available. Most likely you will see information for both the loopback (lo) and your wired network connection (eth0). If you have a wireless connection that will be listed, most likely, as wlan0. The reported information will look like that shown in Figure 1. As you can see, you not only get the IP Address, but the Broadcast address, the Subnet Mask, and the IPv6 Address.

Hostname

From that same command line, if you enter the command hostname you will see the actual hostname of your machine. In the case of my test machine, I see Ubuntu-desktop.  For more information on using this command, take a look at my article "Set your hostname in Linux".

DNS Address(es)

There is no actual command to see your DNS addresses. You don't really need one. All you need to do is examine the /etc/resolv.conf file with the command less /etc/resolv.conf, at whichpoint you will see something like:

nameserver 208.67.222.222

nameserver 208.67.220.220

Gateway address

Figure 2

Now let's find out what the Gateway address is. The command used for this is the netstat command. This command does quite a bit more than just discover your gateway. What the netstat command does is print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. But to find the gateway address you would issue the command netstat -nr and you will see something like that shown in Figure 2. You can probably guess it, but the Gateway address is 192.168.1.1. The flags you used in that command are n (for numeric addresses) and r (for route).

Of course the netstat command can do much more than that (we'll cover that in another article).

Final thoughts

Yes, there are a lot of tools that can be used in Linux. It all depends upon how you want to get your information. In both the GNOME and KDE desktops there are outstanding GUI tools you can use for all of this. But knowing the command line route makes you much more versatile.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. Doug said on April 21, 2010 at 3:24 am
    Reply

    Should have prefaced the full path on the commands. Most can be run as simple user without root access, but /sbin is not in their path.

    Good post anyway :) I can always use a reminder.

  2. Prashant said on April 20, 2010 at 10:50 pm
    Reply

    route -n for finding the gateway address.

  3. grep said on April 20, 2010 at 2:32 pm
    Reply

    Just a small note: be aware that ifconfig (and the other tools from the net-tools package) are deprecated and might not be there anymore in future linux releases (depending on the distro).

    It won’t happen overnight, but if you are still learning, might be best to learn the new commands of the new iproute2 package from the start:

    source: http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2

    1. Anonymous said on May 27, 2010 at 6:11 am
      Reply

      Thank’s man. I never hear about iproute2 before

  4. martin english said on April 20, 2010 at 7:38 am
    Reply

    A couple of things

    1) Don’t apologise for showing people how to use the command line, especially for stuff like this. Each distribution and desktop has its own ‘standard tools’ for use from the windowing environment, whereas the command line is the command line on all of them

    2) Another useful network tool / file is the hosts file – It can be used to over ride the DNS commands, so if someone has got into your machine they can make ghacks.net point to 98.124.248.77 (which is cracked.com). The only thing that should be there is a line for 127.0.0.1 and perhaps your router address. You can check the contents by using:
    less /etc/hosts
    which gives you something similar to (apologies for formatting)
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a ‘#’ symbol.
    #
    # For example:
    #
    # 102.54.94.97 rhino.acme.com # source server
    # 38.25.63.10 x.acme.com # x client host
    #
    127.0.0.1 localhost

  5. Arup said on April 20, 2010 at 5:15 am
    Reply

    In Ubuntu and other distros, simply right clicking on your network icon on top panel and clicking on connection information reveals all these info with ease and no command required.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.