ifconfig Command
The ifconfig command (interface configuration) is used to configure and display network interface parameters in Linux and Unix systems. It's essential for network administration and troubleshooting.
Syntax
ifconfig [INTERFACE] [ADDRESS] [PARAMETERS]
Description
The ifconfig command is used to configure network interface parameters and display network interface information. It can assign IP addresses, configure netmasks, enable/disable interfaces, and much more.
Key features:
- Display network interface information
- Configure IP addresses and netmasks
- Enable and disable network interfaces
- Set hardware addresses (MAC)
- Configure network parameters
ip command in modern Linux distributions, but it's still widely used and available.
Common Options
| Option | Description |
|---|---|
-a |
Display all interfaces (active and inactive) |
-s |
Display short list (similar to netstat -i) |
up |
Activate the interface |
down |
Deactivate the interface |
netmask addr |
Set the IP network mask |
broadcast addr |
Set the broadcast address |
hw ether addr |
Set the hardware (MAC) address |
mtu N |
Set the Maximum Transfer Unit |
Examples
Display all active interfaces
Shows configuration of all active network interfaces
Display all interfaces (active and inactive)
Shows all network interfaces regardless of status
Display specific interface
Shows configuration of the eth0 interface only
Assign IP address to interface
Assigns IP address 192.168.1.100 to eth0 interface
Assign IP address with netmask
Assigns IP address with specific subnet mask
Enable network interface
Activates the eth0 network interface
Disable network interface
Deactivates the eth0 network interface
Set broadcast address
Sets IP, netmask, and broadcast address
Change MAC address
Changes the hardware (MAC) address of the interface
Set MTU (Maximum Transfer Unit)
Sets the MTU size for the interface
Configure interface with multiple parameters
Configures IP, netmask, broadcast, and enables interface
Display short interface list
Shows a condensed list of all interfaces
Add alias IP address
Adds an alias IP address to the interface
Remove alias IP address
Removes the alias IP address from the interface
Understanding ifconfig Output
Sample output explanation
Key information displayed:
- flags - Interface status (UP, BROADCAST, RUNNING, etc.)
- mtu - Maximum Transfer Unit size
- inet - IPv4 address, netmask, and broadcast
- inet6 - IPv6 address information
- ether - MAC address and queue length
- RX/TX - Receive and transmit statistics
Common Use Cases
When to Use ifconfig
- Network Troubleshooting - Check interface status and configuration
- Temporary Configuration - Quick IP address changes for testing
- Interface Management - Enable/disable network interfaces
- Network Monitoring - View traffic statistics and errors
- System Administration - Configure network settings
Modern Alternative: ip Command
The ip command is the modern replacement for ifconfig:
| ifconfig Command | ip Command Equivalent |
|---|---|
ifconfig |
ip addr show |
ifconfig eth0 |
ip addr show eth0 |
ifconfig eth0 up |
ip link set eth0 up |
ifconfig eth0 192.168.1.100 |
ip addr add 192.168.1.100/24 dev eth0 |