ifconfig is a command-line utility used to configure network interfaces on Unix-like operating systems, including Linux. It is part of the net-tools package and is used to view and manage network interface configurations.
View All Network Interfaces:
ifconfig
This command displays information about all active network interfaces on the system.
View a Specific Network Interface:
ifconfigeth0
Replace eth0 with the name of the network interface you want to view. This command displays detailed information about the specified interface.
Bring Up a Network Interface:
ifconfigeth0up
This command activates the eth0 network interface.
Bring Down a Network Interface:
ifconfigeth0down
This command deactivates the eth0 network interface.
Assign an IP Address to a Network Interface:
ifconfigeth0192.168.1.10netmask255.255.255.0
This command assigns the IP address 192.168.1.10 with a subnet mask of 255.255.255.0 to the eth0 interface.
Change the MTU of a Network Interface:
ifconfigeth0mtu1500
This command sets the Maximum Transmission Unit (MTU) of the eth0 interface to 1500 bytes.
This command assigns the IP address 192.168.1.10, subnet mask 255.255.255.0, and broadcast address 192.168.1.255 to the eth0 interface.
Assign a MAC Address to a Network Interface:
ifconfigeth0hwether00:1A:2B:3C:4D:5E
This command assigns the MAC address 00:1A:2B:3C:4D:5E to the eth0 interface.
Example of ifconfig Output
When you run ifconfig without any arguments, you might see output similar to this:
Deprecation Notice
While ifconfig is still widely used, it is considered deprecated in favor of the ip command from the iproute2 package. The ip command provides more functionality and better capabilities for modern network configuration.
Basic Usage of ip Command
View All Network Interfaces:
View a Specific Network Interface:
Bring Up a Network Interface:
Bring Down a Network Interface:
Assign an IP Address to a Network Interface:
Change the MTU of a Network Interface:
Conclusion
ifconfig is a powerful and widely used tool for network configuration on Unix-like systems. Despite being deprecated in favor of the ip command, it remains an important utility, especially in legacy systems and for quick network interface management tasks. For modern and more complex networking tasks, transitioning to the ip command is recommended.
-a, --all: This option displays all network interfaces.
-s, --statistics: This option displays statistics for the specified interface.
-v, --verbose: This option displays more information.