Get all our network configuration with commands

Either because we are managing a server or because we do not yet have a graphical environment, there are times when we need to know all the network data that the computer to which we are connected has, here I will explain how to obtain this data.

IP adress

A simple command can tell us our IP, I mean: ifconfig


It will show us something like this:

ifconfig As you can see, all network interfaces appear, in the 2nd line of each interface we see something like: «internet»… Inet is the IP address, for example, if I do a grep filtering inet I can show only the IPs:

sudo ifconfig | grep inet

It would show us our IPv4 and IPv6 IPs.


The same command allows us to know our MAC address, we can see it in the line that begins with "ether", we can still use a grep to filter by ether and that only our MACs appear:

sudo ifconfig | grep ether

DNS server

To know our DNS server we can see the content of the /etc/resolv.conf file:

cat /etc/resolv.conf

There we will see the domain of our network (in case we have one in the LAN) or the IP of the DNS server that we use.

Gateway or Gateway

Knowing our gateway is just as easy, we will use:

ip route show

We will see that several lines may appear, but the (generally) first line contains our gateway at the beginning, it is the line that begins with default

ip-route Anyway ... obviously you can use grep again to filter by default:

ip route show | grep default

And ... getting more exquisite we can use awk to show only the 3rd column, that of the IP:

ip route show | grep default | awk {'print $3'}

But hey, this is to get us detailed 😀

Hostname or Computer Name

Simple, very simple ... just run: hostname


The end!

So far the post goes, I do not know if I have any pending configuration ... if so, share the command to show it in a terminal 😉


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

8 comments, leave yours

Leave a Comment

Your email address will not be published.



  1. Responsible for the data: Miguel Ángel Gatón
  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.   Gonzalo said

    It never hurts to remember them

  2.   Hugo said

    In the case of DNS, this is not always the case.
    In Ubuntu or some of its derivatives the file '/etc/resolv.conf' contains 'nameserver'
    How to determine the DNS configured in these cases?

    1.    Xurxo said

      This happens because the system is using: / usr / sbin / NetworkManager and it is this program that is in charge of calling / sbin / dhclient.

      If you want to see all the information including the IP names of the nameserver, just run the command:


      In Ubunto and Mint it will offer you something like this:

      Network Manager Tool

      State: connected (global)

      - Device: eth0 —————————————————————–
      Type: Wired
      Driver: jme
      State: unavailable
      Default: no
      HW Address: 00: 90: F5: C0: 32: FC

      Carrier Detect: yes

      wired properties
      Carrier: off

      - Device: wlan0 [Auto MOVISTAR_JIJIJI] ——————————————
      Type: 802.11 WiFi
      Driver: rtl8192ce
      State: connected
      Default: yes
      HW Address: E0: B9: A5: B3: 08: CA

      Speed: 72 Mb / s

      wireless Properties
      WEP Encryption: yes
      WPA Encryption: yes
      WPA2 Encryption:yes

      Wireless Access Points (* = current AP)
      * MOVISTAR_D44A: Infra, F8: 73: 92: 50: D4: 53, Freq 2452 MHz, Rate 54 Mb / s, Strength 40 WPA

      IPv4 Settings:
      Prefix: 24 (


      That is, all the information that the commands in this post (and some more) offer you separately at once. To know other options, you already know: «man nm-tool» 🙂

      Apart from the orders:


      1.    barnarasta said

        #dig | grep SERVER

        and it will tell you the DNS used

      2.    chemabs said

        As of Ubuntu 15.04 you must use:

        nmcli device show

        because nm-tool disappeared:

  3.   cohiote said

    Dear, I installed Huayra 2.0 and I have updated to 2.1.
    At least in these versions, by default there is no "ifconfig" command, otherwise I use the "ip" command to see the status of the network cards:

    ip addrsh

  4.   jhb said

    xd men jnbkj kjbkjbk kjbkj kj kj

  5.   JMonzon said

    How do I update a change of IP address of my mail server in the ISP DNS?