Linux ifconfig Command Tutorial for Beginners (7 Examples)

Network management work includes a lot of stuff, and precisely for this reason, there are several Linux command line utilities that help you with different kind of network-related tasks. In this tutorial, we will discuss one such utility dubbed ifconfig. But before we start with it, it's worth mentioning that all examples discussed in this article have been tested on an Ubuntu 16.04 LTS machine.

Linux ifconfig command

The ifconfig command gives you the ability to configure network interfaces. Of course, you can also fetch information related to network interfaces with this tool. Following is its syntax:

ifconfig [-v] [-a] [-s] [interface]
ifconfig [-v] interface [aftype] options | address ...

And here's how the tool's man page explains it:

       Ifconfig  is  used to configure the kernel-resident network interfaces.
       It is used at boot time to set up interfaces as necessary.  After that,
       it  is  usually  only  needed  when  debugging or when system tuning is

       If no arguments are given, ifconfig displays the  status  of  the  cur?
       rently  active interfaces.  If a single interface argument is given, it
       displays the status of the given interface only; if a single  -a  argu?
       ment  is  given,  it  displays the status of all interfaces, even those
       that are down.  Otherwise, it configures an interface.

Following are some Q&A-styled examples that should give you a good idea on how the ifconfig command works.

Q1. How to use the ifconfig command?

Basic usage is fairly simple - just execute the 'ifconfig' command sans any options.


In output, you'll see information related to all active interfaces. For example, in my case, the following output was produced.

How to use ifconfig command

Note that in case you want the command to display all interfaces (including those currently down), use the -a command line option.

Q2. How to make ifconfig display compact output?

For a short list output, use the -s command line option.

ifconfig -s

Here's a sample output:

How to make ifconfig display compact output

Q3. How to make ifconfig display info about a specific interface?

This you can do by specifying the name of the interface as an argument to the ifconfig command.

ifconfig [interface-name]

For example:

How to make ifconfig display info about specific interface

Q4. How to disable or enable a network interface using ifconfig?

To do this, just specify the 'down' or 'up' flags. For example, to disable an interface dubbed eth0, use the ifconfig command in the following way:

ifconfig eth0 down

Similarly, to enable, use the following command:

ifconfig eth0 up

Q5. How to change a network MTU using ifconfig?

This you can do by using the 'mtu' flag along with the new mtu value.

ifconfig [interface-name] mtu [mtu-value]

For example:

ifconfig eth0 mtu 900

PS: For those who aren't aware what MTU is, head here.

Q6. How to enable promiscuous mode on an interface?

Promiscuous mode allows a network to receive all packets on the network. If that's your requirement, you can enable this mode using the 'promisc' flag.

For example:

ifconfig eth0 promisc

Note that you can disable the promiscuous mode in the following way:

ifconfig eth0 -promisc

Q7. How to change hardware address of network interface?

The ifconfig command also allows you to change the MAC address corresponding to a network interface. This you can do in the following way:

ifconfig [network-name] hw [class] [hardware-address]

For example:

ifconfig eth0 hw ether 70:4d:7b:70:d2:3e

Here's how the man page explains this option:

              Set the hardware address of this interface, if the device driver
              supports  this  operation.  The keyword must be followed by the
              name of the hardware class and the printable ASCII equivalent of
              the  hardware  address.   Hardware  classes  currently supported
              include ether (Ethernet), ax25 (AMPR AX.25), ARCnet  and  netrom
              (AMPR NET/ROM).


So you can see, the ifconfig command lets you do a lot of things related to network interfaces. While we have discussed quite a few command line options here, there are many others as well. Once you are done practicing the ones we've discussed here, head to the tool's man page to learn more.

Share this page:

Suggested articles

1 Comment(s)

Add comment


From: Sandro at: 2018-06-25 13:01:58

ifconfig, as all of the net-tools package commands,  is deprecated. Is better to explain the ip command and alla of the iproute2 package commands.