Linux tools

ifconfig Commands To Configure, Monitor And Debug Network Interface

ifconfig Commands To Configure Monitor And Debug Network Interface

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 needed.  

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

Install ifconfig

Newer Linux operating systems such as Debian 9 and incarnations of Arch Linux may not have ifconfig installed. The developers have deprecated it in favor of ‘ip’ command. It is still possible to install ifconfig by installing the ‘net-tools’ package using your distribution’s package manager.  

Address FamiliesIf the first argument after the interface name is recognized as the name of a supported address family, that address family is used for decoding and displaying all protocol addresses.  Currently supported address families include:

  • inet (TCP/IP, default)
  • inet6 (IPv6)
  • ax25 (AMPR Packet Radio)
  • ddp (Appletalk Phase 2)
  • ipx (Novell IPX)
  • netrom (AMPR Packet radio)

ifconfig Syntax

# ifconfig [-v] [-a] [-s] interface options | address

ifconfig Options

Note: You must be root (or have permissions) to use ifconfig.

# ifconfig interface

Displays the configuration of a specific interface:

ifconfig interface
# ifconfig -s

Displays a shortlist:

ifconfig -s
​$ ip address

​NOTE: ‘ip address’ can be shortened to ‘ip addr’ or ‘ip a’.   This command is the iproute counterpart to the previous ifconfig command. Like the last command, it shows the IPv4 and IPv6 addresses, the MTU, broadcast, and flags associated with each interface. If the -s parameter is included in the command (ip -s address), information about transmitted packets will be included in the output as well. Including -s twice (ip -s -s address) will reveal more information about packet transmission.

show all interfaces iproute

Displays all interfaces which are currently available, even if down:

ifconfig -a
​$ ip address
$ sudo ifconfig enp0s3 up

We just took the ethernet connection up. If we run ‘ifconfig’ with no parameters this interface will not show on the list as it has been deactivated.

ifconfig interface up

An ethernet connection is possible again using this device. This is the iproute equivalent:

$ sudo ip link set enp0s3 up
ip link interface up
$ sudo ifconfig enp0s3 down

This is the iproute equivalent of deactivating an interface.

$ sudo ip link set enp0s3 down
ip link network interface down

We just took the ethernet connection down. If we run ‘ifconfig’ with no parameters this interface will not show on the list as it has been deactivated.   Whenever a network interface is deactivated, the driver controlling the device is shut down so the system cannot use it. It will still know that the device is there and you can start the driver by activating said network device.

# ifconfig -v

Be more verbose for some error conditions:

ifconfig -v
# ifconfig interface [-]arp

Advanced ifconfig Commands

Advanced actions can, of course, be performed using ifconfig and ip. These are just a few examples of such actions. Toggling promiscuous mode, creating aliases for interfaces, and setting IP addresses, are just a few examples that also require superuser privileges to carry out on the command-line.

Enable or disable the use of the ARP protocol on this interface:


# ifconfig interface arp
# ifconfig interface -arp

Promiscuous Mode

By default, an interface has this feature turned off. Normally an interface receives only the packets intended for that interface. Turning on promiscuous mode (if the network device supports it) will have the interface accept all incoming packets on the network. Promiscuous mode is used for packet sniffing, mostly for diagnosing network connectivity problems.To see if an interface has promiscuous mode turned on: look for the “PROMISC” keyword in the output of ‘ifconfig’ relating to that interface.

Enable the promiscuous mode of the interface:
$ sudo ifconfig enp0s3 promisc

Disable the promiscuous mode of the interface:
$ sudo ifconfig enp0s3 -promisc
enable or disable network promiscuous mode

ifconfig Equivalent to iproute for managing promiscuous mode

As with ifconfig, to see if an interface has promiscuous mode turned on, look for “PROMISC” keyword in the output of ‘ip address’ to see if the interface is in promiscuous mode.

To enable, run:

$ sudo ip link set enp0s3 promisc on
To disable, run:
$ sudo ip link set enp0s3 promisc off
iproute enable disable promiscuous mode

Enable or disable all-multicast mode:​Enable

# ifconfig interface allmulti
# ifconfig interface -allmulti

Setting Static IP Addresses

This step isn’t necessary if you are running a DHCP client (such as dhclient on Linux) to fetch IP addresses, which is usually the case. If you do need to assign a static IP address to a network interface it is a very simple task.  

$ sudo ifconfig enp0s3
Or for iproute -
$ sudo ip address add dev enp0s3

Aliasing Interfaces

Creating “aliases” is really simply assigning another IP address to an interface. There are situations where this is desired. To do so with ifconfig, run this: 

$ sudo ifconfig enp0s3:0
You can have multiple addresses assigned to an interface.
$ sudo ifconfig enp0s3:1
ifconfig aliasing address
To remove an alias:
$ sudo ifconfig enp0s3:0 down

If any other aliases were created after enp0s3:0 (e.g. enp0s3:1 and enp0s3:2), then those will be removed too. Using iproute:

$ sudo ip address add dev enp0s3

To delete:

$ sudo ip address delete dev enp0s3

Keep in mind that these IP addresses will disappear anyway once the computer is shut down. Place these commands for assigning multiple IPv4 addresses to one device in a startup script if you want to have such configurations after shutting down.

Most common ifconfig Commands

Listing network interfaces and detailed information about them, activating and deactivating network devices are basically the most common uses for ifconfig and the ‘ip’ command.

Show Active Interfaces

$ ifconfig

This simply lists all of the network interfaces that are currently active. Information from each entry includes the MAC address of the device (HWaddr) except for the local loopback interface (lo), number of packets transmitted, how many errors occurred when transmitting these packets, the Maximum Transfer Unit (MTU) of each interface, and flags shown for a device (such as UP and BROADCAST). If online (up), the IPv4 (inet addr) and IPv6 (inet6 addr) addresses assigned to the device are shown as well as the broadcast and netmask addresses. For a shortened version run ‘ifconfig -s’.

​This command is the iproute equivalent to running ‘ifconfig’.

$ ip address show up
ip address show up command

Show a Single Interface

If you only want information from a single interface, use its device name (e.g. eth0) as a parameter: 

$ ifconfig enp0s3
Or using ‘ip’:
$ ip address show enp0s3
ifconfig get interface

More parameters

metric N This parameter sets the interface metric.
mtu N ​This parameter sets the Maximum Transfer Unit (MTU) of an interface.
​[-]pointopoint addr Set the remote IP address for a point-to-point link (such as PPP).
netmask addr Set the IP network mask for this interface. This value defaults to the usual class A, B or C network mask (as derived from the interface IP address), but it can be set to any value.
add addr/prefixlen Add an IPv6 address to an interface.
del addr/prefixlen Remove an IPv6 address from an interface.
tunnel Create a new SIT (IPv6-in-IPv4) device, tunneling to the given destination.
irq addr Set the interrupt line used by this device.  Not all devices can dynamically change their IRQ setting.
io_addr addr Set the start address in I/O space for this device.
mem_start addr Set the start address for shared memory used by this device. Only a few devices need this.
media type ​Set the physical port or medium type to be used by the device. Not all devices can change this setting, and those that can vary in what values they support.  Typical values for  type are 10base2 (thin Ethernet), 10baseT (twisted-pair 10Mbps Ethernet), AUI (external transceiver) and so on. The special medium type of auto can be used to tell the driver to auto-sense the media.
[-]broadcast [addr] If the address argument is given, set the protocol broadcast address for this interface. Otherwise, set (or clear) the IFF_BROADCAST flag for the interface.
hw class address 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).
multicast Set the multicast flag on the interface. This should not normally be needed as the drivers set the flag correctly themselves.
address The IP address to be assigned to this interface.
txqueuelen length Set the length of the transmit queue of the device. It is useful to set this to small values for slower devices with a high latency (modem links, ISDN) to prevent fast bulk transfers from disturbing interactive traffic like telnet too much.


​You can use ifconfig (part of the net-tools package) to manage connections via different interfaces, be they ethernet or wireless, and find information from the network devices. With it, and ‘ip’, you can connect and disconnect interfaces, allow for packet sniffing and diagnostics, and assigning IP addresses to an interface, if necessary. Many of these are quite simple using the terminal. On newer Linux systems, ‘ip’ from the iproute toolkit is preferred over ‘ifconfig’, even though ifconfig will still be used for some time on Linux, and other UNIX-based systems.

LinuxAndUbuntu hosting is sponsored by massiveGRID

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This website uses cookies to improve your experience. We'll assume you're ok with this. Thank you! Ok Read More