Programmatically enable/disable UNIX network interface
Don't have a complete example, but the following key words should get you started (on Linux at least, not sure about other flavours of Unix):
ioctl, SIOCSIFFLAGS, IFF_UP
The following might be of use as far as showing the relevant APIs: http://www.google.com/codesearch/p?hl=en#2--Ws53NXRc/src/ifdown.c
For Linux, all easily doable with MNL and knowledge of the RTNL protocol:
On Unices or other operating systems, only a OS-specific call and/or the archaic ioctl call is available, the latter of which cannot express Linux multiple addresses per interface properly, so serious programs do not make use of it on that platform.