Cliff Hacks Things.

Saturday, November 24, 2007

eeebuntu tip: ifup/down for NetworkManager

By switching to NetworkManager, I lost the use of the Linux ifup/ifdown scripts for quickly bringing network interfaces up and down. (These scripts rely on the information in /etc/network/interfaces, which I've stripped bare to transfer control to NetworkManager.)

Now, with nm-applet and kin, I have no real need or desire to control my network interfaces from the shell. However, some of my other scripts do -- in particular, when suspending and resuming the machine, I need to remove/reload the Atheros kernel modules, and I can't do that while the interface is up.

Also, my keyboard has a cute little "Wifi On/Off" button that I want to work. (More info on that in a later post.)

Fortunately, the solution turns out to be dead-simple: NetworkManager's dbus API exposes methods for bringing the network up and down.

To bring all NetworkManager-controlled interfaces down:

dbus-send --system --type=method_call \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \

(Yes, all those switches are necessary.)

To bring 'em back up:

dbus-send --system --type=method_call \
--dest=org.freedesktop.NetworkManager \
/org/freedesktop/NetworkManager \

In my case, I dropped these into scripts in /etc/acpi/suspend.d and /etc/acpi/resume.d, respectively, alongside their old-school ifup/down counterparts. Works great, assuming the drivers come back up; I'll post the trick for that in a subsequent post. (I'm transcribing my porting notes as fast as I can here.)


  • Hi,

    My experience with NetworkManager and it's function on xubuntu and the eee-pc has been less than positive. I never figured out the value of it and uninstalled it. And that's not coming from someone who has used linux for >10 years; i.e, not a noob.

    Given the dearth of documentation, I'm still using ifup/down in combination with ifscheme from the command-line to manage multiple wifi profile (wpa-psk, open, etc.)

    I'm willing to give NetworkManager a second chance. Could you point the way to some docs?

    Many thanks...

    By Blogger Fex, at 4:20 PM  

  • Fex,

    n00bs are the intended market for NetworkManager (and people like me who just don't care to grub around with ifconfig anymore), so it doesn't surprise me you were uncomfortable with it. If you're digging on the 'old school' methods for controlling interfaces, keep it up -- you'll be in for fewer surprises.

    I, however, got spoiled by the Mac and like my interfaces to work automagically. NetworkManager does this once you beat it into submission.

    As for docs, sorry, there aren't any I can find. It's possible that Xubuntu doesn't install exactly the same NM configs as Ubuntu, but it works quite well for me on the latter.

    By Blogger Cliff L. Biffle, at 12:14 PM  

  • Cliff, using this method can NetworkManager be used from the command-line?

    Just a few hours ago I was helping someone install ubuntu gutsy and had minor video problems (needed to apt-get the fglrx driver). However, to get the networking to work (WPA2 w/ 802.1X) only NetworkManager can do it (without lots of manual configuration through wpa_supplicant). So I had to drag the machine to my place where I had a zero-authentication network to get the video working so I could type a password into NetworkManager!

    By the way, are you still hacking around with the Propeller?

    By Blogger navaburo, at 2:34 PM  

  • navaburo,

    I'm sure you could configure your interfaces by manually poking NetworkManager using dbus-send -- but I don't know how to do it, nor would I want to. The NetworkManager DBUS API docs I've managed to find are incomplete. Either this stuff isn't documented outside the code, or it lives somewhere that Google can't see.

    I'd be inclined to manually configure the interface in /etc/network/interfaces long enough to get the required packages installed, and then switch back to NetworkManager if you want.

    As for the Propeller, no, beyond a few maintenance updates to propasm. My day job's about as far from small systems as you can possibly get. I've gone back to AVRs for my embedded hobby work -- it's nice to have a C compiler. That said, I've spent the last few months learning Verilog and may release something interesting soon. :-)

    By Blogger Cliff L. Biffle, at 11:13 PM  

  • Yo solo dirĂ© que he visto en De manera que un asunto de patologĂ­a general se.vietnamese girls

    By Blogger chinese girl, at 10:29 PM  

  • This is complete package. You write briefly in this article. These both blog entry totally informative for readers.

    Hadoop Training Institute in Noida

    By Blogger CIIT Noida, at 11:50 PM  

Post a Comment

<< Home