Sometimes the network has to be reconfigured on the fly. Two examples when this might happen are a laptop on the move (plugging into a different network) or a local computer which had a bad network connection on booting up. Of course with , reconfiguring the network is as easy as:

# ifdown eth0
# ifup eth0

What's easier than that? Automated configuration. As a mac user I'm spoiled, as OS X always reconfigures the network automatically when I plug in my cable. That's what I wanted for Linux as well. So if there is already an existing solution, please tell me. But if there isn't, I have one for you now.

First install the bash script network-status.sh somewhere on your computer (in /etc/network for example). Then execute the following command on boot:
mii-tool --w eth0 | while read line; do /etc/network/network-status.sh $line; done

How does this work? Well, mii-tool using the -w flag prints a line every time the link status changes. This line is then parsed by network-status.sh to run ifup or ifdown automatically.

This was hacked together in the last few minutes, so expect bugs and reports them to me. Also, if there is already a better solution for that out there, please tell me. I'm sure that other people already had the same idea before me.