[linux-elitists] nmcli and NetworkManager configuration

Phil Mayers p.mayers at imperial.ac.uk
Tue Aug 31 05:18:38 PDT 2010


On 08/31/2010 12:56 PM, Phil Mayers wrote:
> On 08/29/2010 04:30 AM, Jason White wrote:
>> NetworkManager is increasingly being installed by Linux distributions
>> these days. Recent versions come with a shell utility, nmcli, intended,
>> for use by users who prefer the command line (I'm in that category) and
>> for servers. I understand that NM provides multiple network profiles and
>> facilitates the configuration of WPa2, 3G modems, etc.
>>
>> Some of those features could be useful. I've read the nmcli(1) manual
>> page and experimented with running nmcli, but it seems to be missing the
>> ability to configure new connections. (Having just installed NM, I don't
>> have any profiles or interface configurations set up.)
>
> NM is pretty damn good these days IMO. It's bluetooth DUN support wowed me.
>
>>
>> How is one supposed to configure NM from the shell, i.e., without
>> running X?
>
> If you're not running X, nm-applet won't be running and thus won't be
> providing the User settings service. Therefore any NM connections will
> need to be "system" connections. NM get the config for these by running
> one or more plugins. This is a good primer:
>
> http://live.gnome.org/NetworkManager/SystemSettings
> http://live.gnome.org/NetworkManagerConfiguration
>
> The short version is that NM will read RedHat/Fedora-style ifcfg-*
> files, so you can just write these out. However, the ifcfg plugin only
> support ethernet-style connections, not VPN or DUN/PPP/3G.
>
> To support these, you'll need to run the "keyfile" plugin, and write out
> an appropriate keyfile. This is basically an .ini file in
> /etc/NetworkManager/system-connections
>
>>
>> Are there any alternative projects that I should look at?
>>
>> The main use cases at the moment are, for example, switching between
>> multiple network profiles with different IPv4/IPv6 configurations;
>
> Can I ask whether you're aware that you can have>1 profile on the same
> adapter? So you don't need to "change" any config for this - just
> activate the relevant profile (in theory - I haven't tested this)
>
>> setting up wireless (including WPA2) networking quickly on a laptop,
>> etc. I could write shell scripts, of course, but I'd rather work with
>> daemons and tools designed for the purpose than to reinvent what others
>> are devoting significant development effort to create.
>
> Without X, writing keyfile configs out is probably the quickest route.

A couple more pointers:

http://projects.gnome.org/NetworkManager/developers/settings-spec-08.html

...or the older:

http://live.gnome.org/NetworkManagerConfigurationSpecification

...shows the schema; in keyfile language the setting "name" corresponds 
to the ini section and the keyname to the ini key, like so:

[802-1x]
name=802-1x
eap=peap

[connection]
name=connection
uuid=....


Turning the spec document into working keyfiles might be a bit tricky; 
there are gconf examples which translate pretty easily into keyfile on 
the page Don linked to.

One final pointer: I think the bluetooth DUN stuff depends to some 
extent on gnome-bluetooth to work, so if that's of interest you, it may 
be necessary to do some hacking with the bluetooth stack to get that 
working absent X/nm-applet.

Good luck!

Cheers,
Phil


More information about the linux-elitists mailing list