Ifconfig Command - Network Interface Configuration Tool

Learn how to use the ifconfig command for network interface configuration. Display, enable, disable, and set IP addresses, netmasks, and MAC addresses for network interfaces.

Ifconfig Command

The ifconfig command is a powerful utility used in Unix-like operating systems to configure and display network interface parameters. While it has been largely superseded by the ip command in modern Linux distributions, understanding ifconfig is still valuable for managing older systems or for historical context. This tool allows administrators to view network interface details, assign IP addresses, set subnet masks, change MAC addresses, and manage interface states (up/down).

Display Network Interface Information

To see the status and configuration of all active network interfaces on your system, you can run ifconfig without any arguments. This is often the first step in diagnosing network issues.

# Display all network interfaces and their configuration
ifconfig

View Specific Interface Details

If you need to inspect the configuration of a particular network interface, such as eth0, you can specify the interface name.

# View configuration details for a specific interface (e.g., eth0)
ifconfig eth0

Manage Network Interface States

You can enable or disable network interfaces using the up and down options, respectively. This is useful for temporarily taking an interface offline or bringing it back into service.

# Enable a network interface (e.g., eth0)
ifconfig eth0 up

# Disable a network interface (e.g., eth0)
ifconfig eth0 down

Configure IP Addresses and Subnet Masks

Assigning an IP address and subnet mask to an interface is a core function of ifconfig. This allows the interface to communicate on the network.

# Assign an IP address to an interface (e.g., eth0)
ifconfig eth0 192.168.1.10

# Set a subnet mask on a network interface
ifconfig eth0 netmask 255.255.255.0

Interface Aliasing and MAC Address Modification

ifconfig also supports creating network interface aliases, which allows a single physical interface to have multiple IP addresses. Additionally, you can change the hardware (MAC) address of an interface, though this should be done with caution.

# Add an alias for a network interface with a separate IP address
ifconfig eth0:0 192.168.1.20

# Remove alias from a network interface
ifconfig eth0:0 down

# Set a broadcast address on a network interface
ifconfig eth0 broadcast 192.168.1.255

# Change the MAC address of a network interface
ifconfig eth0 hw ether 00:11:22:33:44:55

For more advanced network configuration and management on modern systems, consider using the ip command. For detailed information on network protocols and standards, refer to resources like MDN Web Docs and RFC 791 (IP Protocol).