⚠ Deprecation Notice: The ifconfig command is deprecated in many modern Linux distributions and has been replaced by the ip command from the iproute2 package. However, ifconfig is still widely used and available on most systems. For new scripts and automation, consider using ip addr, ip link, and ip route instead.
About ifconfig
The ifconfig (interface configuration) command is used to configure, manage, and query network interface parameters. It can display information about active network interfaces, assign IP addresses, enable or disable interfaces, and modify various network parameters. While deprecated, it remains one of the most commonly known networking commands.
Key Functions:
Display network interface configuration
Assign IP addresses and netmasks
Enable and disable network interfaces
Configure MTU (Maximum Transmission Unit)
Set hardware (MAC) addresses
Monitor network statistics
Note: Most ifconfig operations require root privileges. Use sudo ifconfig for configuration changes. Installation: apt install net-tools (Debian/Ubuntu) or yum install net-tools (RHEL/CentOS).
Displays configuration and statistics for only the eth0 interface. This is useful for:
Focusing on a specific network adapter
Troubleshooting connectivity issues
Monitoring traffic on one interface
Verifying configuration changes
Common interface names include: eth0/eth1 (Ethernet), wlan0 (WiFi), enp3s0 (predictable network names), lo (loopback).
Example 3: Display All Interfaces (Including Inactive)
ifconfig -a
The -a option displays all interfaces, including those that are currently down/inactive:
Shows disabled network adapters
Lists all available hardware interfaces
Useful for inventory and troubleshooting
Helps identify interfaces that need to be brought up
This is particularly useful when trying to enable a network interface that's currently down.
Note: An interface shown with ifconfig -a but not with ifconfig (without options) is in the DOWN state and not currently active.
Example 4: Assign IP Address to Interface
sudo ifconfig eth0 192.168.1.150
Assigns the IP address 192.168.1.150 to the eth0 interface. This command:
Requires root/sudo privileges
Takes effect immediately (no reboot required)
Changes are temporary (lost on reboot unless saved in network config)
Can be used for quick testing or temporary reconfiguration
To verify the change: ifconfig eth0 | grep inet
Warning: This change is temporary and will be lost after reboot. To make permanent changes, edit network configuration files (e.g., /etc/network/interfaces or use NetworkManager/netplan).
Warning: Changing MAC addresses may violate network policies or terms of service. Only change MAC addresses on networks you own or have explicit permission to test.
Test with IP first, then domain names to isolate DNS issues
Check firewall rules: sudo iptables -L -n
Security Considerations
Promiscuous Mode Warning: Setting an interface to promiscuous mode (ifconfig eth0 promisc) allows it to capture all network traffic, not just packets addressed to it. This should only be used for legitimate network analysis and requires proper authorization.
Security Tip: Regularly monitor for unexpected changes in network configuration. Unauthorized MAC address changes or IP assignments could indicate a security compromise.
Best Practice: Always document network configuration changes. Use version control for network configuration scripts and maintain an inventory of all network interfaces and their purposes.