Author: Joe Barr
I’ve always assumed that ifup and ifdown were conditional commands that performed their assigned duties only if the interface device in question was up or down, as the command might be. I was dead wrong. I blame my mistake on being a programmer, rather than being stupid, but it’s simply too close to call.
The if in ifup, ifdown, and ifstatus is not a programmer’s if — it’s an abbreviation for interface. On the off chance that I’m not the only one who has misunderstood these commands because of their rather iffy names, here’s what they really do and how they are used.
Ifup and ifdown are normally hidden from view and used only in scripts run at startup and shutdown time, so why would we care about them? Well, grasshopper, interfaces happen, that’s why. Equipment malfunctions may leave you in need of these commands in between power on and power off.
Have you ever lost your connection to the Internet and ended up rebooting in order to restore it? One morning recently, the CAT 5 cable connecting my desktop to my Linksys router was pulled loose by a kitten foraging for Baud knows what behind my monitor. I didn’t know that at the time — all I knew was that my connection to the Internet suddenly stopped responding.
I checked the cable modem and the router, but didn’t notice the cable that had been pulled loose from the back of the router. If I had known about ifstatus, I could have solved the puzzle at once.
The first clue
The format for this command is ifstatus interface-name -o options
. To check the only Ethernet connection on my desktop box, without specifying any options, I would enter:
ifstatus eth0
After intentionally disconnecting the cable at the back of the router, I ran the command, and ifstatus had this to say:
eth0 device: VIA Technologies, Inc. VT6102 [Rhine-II] (rev 74) eth0 configuration: eth-id-XX:XX:XX:XX:XX:XX eth0 DHCP client (dhcpcd) is running IPADDR=192.168.1.110 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 HOSTNAME='linux' DOMAIN='lan' DNS=192.168.1.1 DHCPSIADDR=192.168.1.1 DHCPCHADDR=XX:XX:XX:XX:XX:XX REBINDTIME=37800 eth0 is up 2: eth0: 2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,NOTRAILERS,UP> mtu 1500 qdisc pfifo_fast qlen 1000mtu 1500 qdisc pfifo_fast qlen 1000 link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff inet 192.168.1.110/24 brd 192.168.1.255 scope global eth0 inet6 fe80::250:8dff:fe4e:9dd0/64 scope link valid_lft forever preferred_lft forever eth0 IP address: 192.168.1.110/24 Configured routes for interface eth0: 169.254.0.0 - 255.255.0.0 eth0 Active routes for interface eth0: 192.168.1.0/24 proto kernel scope link src 192.168.1.110 169.254.0.0/16 scope link default via 192.168.1.1 1 of 1 configured routes for interface eth0 up
At first glance, I thought it was telling me all was well when I knew it wasn’t. Then I noticed the line following the one that says “eth0 is up.” NO-CARRIER was clearly saying that it wasn’t connected.
Once I determined the problem and put the cable back where it belonged, I could have resolved it without rebooting the desktop machine by using ifdown and ifup.
At first I tried ifup eth0
, but all it would do is tell me the interface was already up. So I shut down the interface with ifdown eth0
, then hit it with ifup again, and just like that I was reconnected.
I noticed that ifup and ifdown seem to have been replaced by ifupdown on my Ubuntu box, and it also has slightly different formats for the individual ifup and ifdown commands. I believe most Debian-based distributions do use ifupdown, so be sure to use man
or info
to check the proper format of the commands on your system.