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.
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.
If 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 [-v] [-a] [-s] interface options | address
Displays the configuration of a specific interface:
Displays a short list:
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.
Displays all interfaces which are currently available, even if down:
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.
An ethernet connection is possible again using this device. This is the iproute equivalent:
This is the iproute equivalent of deactivating an interface.
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.
Be more verbose for some error conditions:
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:Enable
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:
Disable the promiscuous mode of the interface:
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:
To disable, run:
Enable or disable all-multicast mode:Enable
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.
Or for iproute –
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:
You can have multiple addresses assigned to an interface.
To remove an alias:
If any other aliases were created after enp0s3:0 (e.g. enp0s3:1 and enp0s3:2), then those will be removed too.Using iproute:
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.
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’.
If you only want information from a single interface, use its device name (e.g. eth0) as a parameter:
Or using ‘ip’:
This parameter sets the interface metric.
This parameter sets the Maximum Transfer Unit (MTU) of an interface.
Set the remote IP address for a point-to-point link (such as PPP).
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 an IPv6 address to an interface.
Remove an IPv6 address from an interface.
Create a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination.
Set the interrupt line used by this device. Not all devices can dynamically change their IRQ setting.
Set the start address in I/O space for this device.
Set the start address for shared memory used by this device. Only a few devices need this.
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.
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).
Set the multicast flag on the interface. This should not normally be needed as the drivers set the flag correctly themselves.
The IP address to be assigned to this interface.
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.