<span>ifconfig</span> is a traditional Linux command-line tool used to configure, view, and manage network interfaces (such as Ethernet, wireless network cards, loopback interfaces, etc.). Although it has gradually been replaced by the more powerful <span>ip</span> command (from the <span>iproute2</span> toolkit) in modern Linux distributions, <span>ifconfig</span> is still widely available on many systems and is familiar to many administrators.
🔧 Basic Syntax:
ifconfig [interface] [options]
✅ Common Usage Examples:
1. Display all active network interfaces
ifconfig
The output includes IP address, MAC address, subnet mask, and statistics for received/sent packets, etc.
2. Display information for a specific network interface (e.g., eth0)
ifconfig eth0
3. Enable (activate) a network interface
sudo ifconfig eth0 up
4. Disable (shutdown) a network interface
sudo ifconfig eth0 down
5. Assign an IP address and subnet mask to a network interface
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0
6. Set broadcast address and point-to-point address (less commonly used)
sudo ifconfig eth0 broadcast 192.168.1.255
⚠️ Notes:
<span>ifconfig</span>comes from the<span>net-tools</span>package, and many modern distributions no longer install it by default (such as Ubuntu 18.04+, CentOS 8+, etc.).- It is recommended to use the updated
<span>ip</span>command instead of<span>ifconfig</span>, for example:
| Function | <span>ifconfig</span> |
Recommended Replacement (<span>ip</span> command) |
|---|---|---|
| View interfaces | <span>ifconfig</span> |
<span>ip addr</span> or <span>ip a</span> |
| View routing | <span>route -n</span> |
<span>ip route</span> or <span>ip r</span> |
| Enable interface | <span>ifconfig eth0 up</span> |
<span>ip link set eth0 up</span> |
| Set IP | <span>ifconfig eth0 192.168.1.10</span> |
<span>ip addr add 192.168.1.10/24 dev eth0</span> |
📦 How to Install ifconfig (if missing)
On Debian/Ubuntu-based systems:
sudo apt update
sudo apt install net-tools
On RHEL/CentOS/Fedora-based systems:
# CentOS/RHEL 7/8
sudo yum install net-tools
# Fedora
sudo dnf install net-tools
# Or use the new command: nmcli (provided by NetworkManager)
nmcli device show
🔄 Summary
| Feature | Description |
|---|---|
| Is it recommended for new projects? | ❌ Not recommended, use the <span>ip</span> command instead |
| Is it still available? | ✅ Most old systems support it, can be used by installing <span>net-tools</span> |
| Main use case | Quickly view or temporarily configure network interfaces (suitable for learning and simple debugging) |