分类: LINUX
2011-02-12 13:17:43
has a good overview of settings services in general. "System settings" is the name of the D-Bus service (using the bus name org.freedesktop.) that provides system-wide configuration data to . In NM 0.7, this service is implemented in a separate process (nm-system-settings) while in NM 0.8 the service is built into itself. The system settings service implements the org.freedesktop. and the org.freedesktop. D-Bus interfaces.
System settings are stored in a system-wide location (typically somewhere in /etc) and are available at boot time, before login, and to all users of the machine. To accomplish this, and to provide a good level of integration with various distribution-specific configuration systems that users are already familiar with, the system settings service relies on "system settings plugins" to read and write the distros native configuration file format.
Configuration
By default, the system settings service is configured through the /etc/NetworkManager/nm-system-settings.conf (NM 0.7 and 0.8.0) or /etc/NetworkManager/NetworkManager.conf (NM 0.8.1 and later) file, which may be changed through use of the "--config=" argument for either nm-system-settings (NM 0.7) or (NM 0.8). This file must contain a "[main]" section that has at least one configuration option: "plugins". So a minimal system settings configuration file looks like this:
[main]
注:keyfile也是一插件 。
可用man networkmanager.conf查看帮助
Multiple plugins may be specified in a preference order using ',' as a separator (ie, "plugins=ifcfg-rh,keyfile") to allow more than one plugin to be used. This will cause connections to be read from all listed plugins. In the previous example ("plugins=ifcfg-rh,keyfile") both standard ifcfg files from /etc/sysconfig/network-scripts and keyfile connections from /etc/NetworkManager/system-connections would be read and used. When creating new connections, or making a user-settings connection into a system-settings connection, the plugins will be asked to save the connection in the order listed here. If the first plugin cannot write out that connection type, or can't write out any connections, the next plugin is tried. If none of the plugins can save the connection, the error is returned to the user.
Plugins
keyfile
The 'keyfile' plugin is the generic plugin that supports all the connection types and capabilities that NM has. It writes files out in a .ini-style format in /etc/NetworkManager/system-connections. For security, it will ignore files that are readable or writeable by any user or group other than 'root' since private keys and passphrases may be stored in plaintext inside the file.
The keyfile config format is a simple .ini-style format with each section corresponding to a setting name as described in the settings specifications (0.7 0.8). Each configuration key/value pair in the section is one of the keys listed in the settings specification. If the specification says the value type is "string" then the keyfile value type should be a string; if it's "byte array" the keyfile value type should be a list of hexadecimal-formatted bytes separated by semicolon (';'). MAC addresses may be written as textual MAC addresses (ie, "00:11:22:33:44:55"). Some values are inconvenient for people to use and it is expected that these will be fixed to be more useful in the near future.
A sample keyfile configuration for a wired network is:
[connection]
NOTE: since SSIDs may contain embedded NULLs, they must be specified as byte arrays (ie, "ssid=102;111;111;98;97;114;").
Persistent Hostname
The keyfile plugin pulls the system persistent hostname from the system settings service configuration file from the "[keyfile]" section. To set a persistent hostname when using the keyfile plugin, add the following block to the system settings service configuration file:
[keyfile]
It is not necessary to restart or nm-system-settings when making these changes, as the configuration files are watched for changes and reloaded when necessary.
Unmanaged devices
The keyfile plugin uses the nm-system-settings.conf file (0.7 and 0.8.0) or .conf (0.8.1 and later) for configuration of unmanaged devices. To set devices that should be ignored by ,
list them in "unmanaged-devices" key in "[keyfile]" section. Devices
are specified in the following format: "mac:
[keyfile]
Logging
At this time, the keyfile plugin won't give you much feedback about what its doing or why configuration failed to validate. We hope to fix this soon.
ifcfg-rh
The 'ifcfg-rh' plugin is used on Fedora and Red Hat Enterprise Linux distributions to read and write configuration from the standard /etc/sysconfig/network-scripts/ifcfg-* files. It current supports reading wired, wifi, and 802.1x connections, but does not support reading or writing mobile broadband, PPPoE, or VPN connections. To allow reading and writing of these until the ifcfg-rh plugin is updated, add ",keyfile" to your "plugins=" line in /etc/NetworkManager/nm-system-settings.conf (0.7 and 0.8.0) or .conf (0.8.1 and later). In NM 0.7, the ifcfg-rh plugin does not support IPv6. Full IPv6 support is being added for NM 0.8 and will be finished by NM 0.8.1.
Persistent Hostname
The persistent machine hostname is pulled from /etc/sysconfig/network's HOSTNAME variable.
Unmanaged devices
In order for a device to be ignored by , it has to be marked such in its ifcfg-* file. The indication is done by NM_CONTROLLED variable, but you must also specify the device's HWADDR:
NM_CONTROLLED=no
Device Aliases
The plugin does not yet support interface "aliases" (ie, eth0:1). This is a legacy configuration mechanism from the days when /sbin/ip and netlink didn't exist. ifcfg-rh will support reading alias files in the future, but as the alias style is deprecated write support will not be added. Instead, put all IP addresses and prefixes into the main ifcfg file like so:
IPADDR=192.168.0.2
Nameservers
Many users run into problem with resolv.conf not showing the proper nameservers with ifcfg-rh. Because /etc/resolv.conf must be reconstructed every time a connection is activated or deactivated as DNS information changes depending on the active connection, static nameservers should be added to the specific ifcfg file they are for like so:
DNS1=4.2.2.1
This will ensure that the nameservers are correct every time for static IP configurations.
iSCSI
In NM 0.8, the ifcfg-rh plugin has the ability to read preconfigured iSCSI connections. You must have a valid iSCSI ifcfg in /etc/sysconfig/network-scripts like the following:
# Intel Corporation 82540EP Gigabit Ethernet Controller (Mobile)
ifcfg-rh will then query the iscsiadm tool to retrieve firmware settings for your iSCSI adapter and use those when bringing up the device.
Logging
In general, the ifcfg-rh plugin is pretty good about logging what it's doing, including why various ifcfg files may fail validation and thus be ignored. Check /var/log/messages when starts up for more information. You'll see output like:
NetworkManager: ifcfg-rh: parsing /etc/sysconfig/network-scripts/ifcfg-Auto_eth0 ...
In this case, one file failed to validate because it was missing the LEAP username.
ifupdown
This plugin is used on the Debian and Ubuntu distributions, and reads connections from /etc/network/interfaces. Since it cannot write connections out (that support isn't planned) it is usually paired with the 'keyfile' plugin to enabled saving and editing of new connections. The ifupdown plugin supports basic wired and wifi connections, including WPA-PSK.
Persistent Hostname
As the standard location for the persistent system hostname on Debian-base distributions is /etc/hostname, the ifupdown plugin reads the hostname from that location.
Unmanaged Devices
The ifupdown plugin also uses the /etc/NetworkManager/nm-system-settings.conf file (0.7 and 0.8.0) or .conf (0.8.1 and later) for some configuration. All ifupdown-specific options go in a "[ifupdown]" section. If the "managed" key is set to "false", then any device listed in /etc/network/interfaces will be completely ignored by . Remember that controls the default route, so because the device is hidden, will assign the default route to some other device.
ifcfg-suse
The ifcfg-suse plugin is only provided for simple backward compatibility with SUSE and OpenSUSE configuration. Most setups should be using the 'keyfile' plugin instead. The ifcfg-suse plugins supports reading wired and wifi connections, but does not support saving any connection types.
User Settings and System Settings
The user settings will be stored here.
/home/userdirectory/.gconf/system/networking/connections
The System settings will be stored here.
/etc/NetworkManager