The ifconfig command enables a user to view the current IP addressing information for each NIC recognized by the system. Viewing the IP address configuration is one of the earliest steps in network troubleshooting. The ifconfig command shows the IP address, subnet mask, broadcast ID, MAC address, basic performance information, and NIC name. The tool also enables NICs to be placed in an up or a down configuration (enabled or disabled).
The ifconfig command is officially deprecated in Linux, as noted in the man page; however, it is still available in many current distributions.
Syntax
The syntax of the ifconfig command is:
# ifconfig [options] [interface]
If you encounter the below error while running the ifconfig command:
ifconfig: command not found
you may try installing the below package as per your choice of distribution:
OS Distribution | Command |
---|---|
Debian | apt-get install net-tools |
Ubuntu | apt-get install net-tools |
Alpine | apk add net-tools |
Arch Linux | pacman -S net-tools |
Kali Linux | apt-get install net-tools |
CentOS | yum install net-tools |
Fedora | dnf install net-tools |
Raspbian | apt-get install net-tools |
ifconfig Command Examples
1. To see all the interfaces on the system:
# ifconfig -a
2. To see all the interface stats:
# ifconfig -s # ifconfig -s eth1
3. To add the IPv6 address to the interface:
# ifconfig eth1 add
4. To delete the IPv6 address to the interface:
# ifconfig eth1 add
5. To create a new SIT device:
# ifconfig eth5 tunnel ::
6. To set the interrupt line used by the device:
# ifconfig eth1 -irq addr
7. To set the start address in I/O space for this device:
# ifconfig eth1 io_addr addr
8. To Set the start address for shared memory used by this device:
# ifconfig eth1 mem_start addr
9. To Set the physical port or medium type to be used by the device:
# ifconfig eth1 media type
10. To Set the hardware address of this interface:
# ifconfig eth1 hw class address
11. To Set the multicast flag on the interface:
# ifconfig eth1 multicast
12. To set the IP address to the interface:
# ifconfig eth1 address 192.168.27.100
13. To Set the length of the transmit queue of the device:
# ifconfig eth1 txqueuelen length