ifconfig
ifconfig was, for a long time, the standard way to view and configure a Linux network interface — assign an address, bring an interface up or down, check its statistics. It's the same category of question ipconfig answers on Windows, but this time the classic tool has a direct, actively maintained successor, and the previous article's mention of that fact is worth making concrete here.
What ifconfig shows
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.42 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:fe4e:66a1 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:4e:66:a1 txqueuelen 1000 (Ethernet)
RX packets 184213 bytes 231884213 (231.8 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 97452 bytes 14882031 (14.8 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
flags=4163<UP,BROADCAST,RUNNING,MULTICAST> is the same interface-state information the NIC article covered via ip link show — UP here corresponds to that article's UP flag, RUNNING corresponds to LOWER_UP, a live physical link. ether shows the interface's MAC address, and the RX/TX error, drop, and overrun counters are worth checking whenever performance looks worse than expected with no obvious cause: a rising dropped or overruns count points at the NIC or its driver, not at anything higher up the stack.
ifconfig -a lists every interface, including ones that are administratively down — without -a, a down interface simply doesn't appear at all, which can make a disabled adapter look like it doesn't exist rather than like it's just switched off.
Why ifconfig is legacy
ifconfig belongs to the net-tools package, which has had no meaningful active development since the mid-2000s. Its own man page, in the BUGS section, already points elsewhere for at least one case — hardware address display on Infiniband devices — recommending ip link from the iproute2 package instead. More broadly, most current Linux distributions no longer install net-tools by default at all; ifconfig frequently has to be installed explicitly, while ip — from the actively maintained iproute2 package — ships as standard.
The functional gap matters too, not just the maintenance status. ifconfig has no native concept of multiple routing tables, and its view of IPv6 is considerably thinner than ip's — iproute2 was written specifically to expose the fuller feature set the Linux kernel's networking stack gained after net-tools was designed.
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:4e:66:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.42/24 brd 192.168.1.255 scope global dynamic eth0
valid_lft 82734sec preferred_lft 82734sec
inet6 fe80::a00:27ff:fe4e:66a1/64 scope link
valid_lft forever preferred_lft forever
| Task | ifconfig | ip |
|---|---|---|
| Show one interface | ifconfig eth0 |
ip addr show eth0 |
| Show all, including down | ifconfig -a |
ip addr show |
| Bring an interface up | ifconfig eth0 up |
ip link set eth0 up |
| Bring an interface down | ifconfig eth0 down |
ip link set eth0 down |
| Assign an address | ifconfig eth0 192.168.1.50 netmask 255.255.255.0 |
ip addr add 192.168.1.50/24 dev eth0 |
ip's CIDR notation (/24) for the address assignment is a small but real convenience over ifconfig's separate netmask argument — the same prefix-length notation the CIDR article already covers in depth, here showing up directly in a command's syntax rather than just in subnet arithmetic.
Warning
Bringing an interface down with either tool — ifconfig eth0 down or ip link set eth0 down — on the same connection you're using to reach a remote machine will disconnect you immediately, with no automatic recovery. Test interface changes on a local machine, a lab VM, or a host with a separate out-of-band management path before running either command against a remote system's only network interface.
Practice exercises
- Run both
ifconfig eth0(or your interface's name) andip addr show eth0on the same machine, and match up which fields in each output correspond to the same underlying information. - Check whether
net-toolsis installed by default on a current Linux distribution you have access to (which ifconfig), and note whetheripwas already present without any extra install step. - Using the table above, write the
ipequivalent ofifconfig wlan0 downfollowed byifconfig wlan0 up.
Interface state and addressing are one layer of "what's going on with this machine." Name resolution is the next, and it starts with the oldest command-line DNS lookup tool most people learn — one with its own, better-documented reason for having fallen out of favor.
Sources
- Linux man-pages, ifconfig(8)
- Linux man-pages, ip-address(8)