What is ifconfig?
ifconfig (short for “interface configuration”) is a command‑line tool used in Unix‑like operating systems (Linux, macOS, BSD) to view and change network interface settings such as IP address, netmask, broadcast address, and MAC address.
Let's break it down
- Interface: a network device like eth0 (wired), wlan0 (wireless), or lo (loopback).
- IP address: the numeric label that lets the device talk on a network.
- Netmask: defines the size of the network portion of the IP address.
- Broadcast: address used to send a message to all devices on the same network.
- MAC address: hardware identifier burned into the network card.
Running
ifconfig
without options lists all interfaces and their current settings. Adding the interface name (e.g.,ifconfig eth0
) shows details for that one. Adding parameters lets you set new values (e.g.,ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
).
Why does it matter?
Understanding and controlling network settings is essential for troubleshooting connectivity problems, configuring static IPs, setting up servers, or securing a system. ifconfig gives you direct, low‑level access to those settings without needing a graphical interface.
Where is it used?
- On servers and headless devices where no GUI is available.
- In scripts that automate network configuration.
- During network troubleshooting to quickly check which interfaces are up and what addresses they have.
- Historically on many Linux distributions; still the default on many BSD systems and older Linux releases.
Good things about it
- Simple, single‑command interface that works on most Unix‑like OSes.
- Provides both read‑only information and the ability to change settings on the fly.
- Works without needing extra packages; it’s part of the core networking utilities.
- Useful for quick checks in emergency or recovery environments.
Not-so-good things
- Considered deprecated on many modern Linux distributions in favor of the
ip
command from the iproute2 suite, which offers more features and better consistency. - Limited to IPv4; handling IPv6 requires extra flags or a different tool.
- Output format varies slightly between OSes, making automated parsing harder.
- Changing settings with ifconfig is not persistent across reboots unless you edit network configuration files.