Difference between revisions of "NetworkManager"

From ArchWiki
Jump to navigation Jump to search
(Problems starting nm-applet as normal user: - small typo in nm-applet policy)
Line 39: Line 39:
There is a plasmoid in the [[AUR]] for NetworkManager called '''networkmanager-plasmoid-svn'''. Note that it still is in development.
Install the package kdeplasma-applets-networkmanager from extra. Launch it from Applications > System > Network Manager (knetworkmanager).

Revision as of 19:59, 29 October 2009

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end


Network Manager is a set of co-operative tools that make networking simple and straightforward. Whether wireless or wired, Network Manager allows you to quickly move from one network to another: once a network has been configured and joined once, it can be detected and re-joined automatically at a later date.

Network Manager 0.7 is a major overhaul of the NetworkManager program.

Some of the new features include:

  • Support for cellular data cards
  • Multiple Active Devices
  • System-wide Configuration
  • wpa_supplicant dbus Control Interface
  • More Wireless/Wired Authentication Methods

Step 1: Installation

NetworkManager is available in the extra repository so:

# pacman -S networkmanager

Step 2: GUIs


network-manager-applet (formerly gnome-network-manager) is available in the extra repository:

# pacman -S network-manager-applet


Note: if you can't make any of the below stuff work, network-manager-applet is an option.


Install the package kdeplasma-applets-networkmanager from extra. Launch it from Applications > System > Network Manager (knetworkmanager).


You can try to use knetworkmanager which is no longer maintained in any Arch official repositories in binary form. You can get it from the AUR.


Xfce uses the same package as GNOME:

# pacman -S network-manager-applet 

You can also install xfapplet plugin, which allows GNOME applets to be displayed within the xfce4 panel:

# pacman -S xfce4-xfapplet-plugin

If after installation you get four or more instances of nm-applet running when automatically starting gnome services and you're not using a session manager; consider doing the following:

  1. Kill all nm-applet processes
  2. Add Template:Codeline to the autostarted applications.
  3. Log out of Xfce.
  4. Delete the XFCE session file (in ~/.cache/sessions/)
  5. Log into Xfce and all is good.

Fluxbox and Other WM's

You will need the hicolor theme to be able to run nm-applet:

# pacman -S gnome-network-manager hicolor-icon-theme

After configuring your system for use with NetworkManager, to autostart the NetworkManager applet, go to Settings → Autostarted Applications then add, Template:Codeline, This should start up the network manager applet on startup, the Template:Codeline option is used to prevent multiple instances of the nm-applet, you should only need it if multiple instances are running when you startup.

  • NetworkManager seems to have trouble loading on various box-environments and compiz. By using the ck-launch-session pre-fix, nm-applet seems to work correctly.


exec ck-launch-session startlxde

Step 3: Configuration

Disable the interfaces

If you want to use NetworkManager on an interface you will have to disable it in Template:Filename. You can do this by placing a Template:Codeline in front of the interface of your choice, for example:

INTERFACES=(!eth0 !ath0)
Note: I had to enable (i.e, remove the Template:Codeline) eth0 again afterwards for my card to work, although YMMV. Confirmed with ath_pci madwifi module – I also had to re-enable my cards for them to work.

NetworkManager parses your Template:Filename to see if you want to have a static or dynamic IP on your interfaces.

So just put your preferred config into it.

Example for static IP:

 eth0="eth0 netmask broadcast"

Example for dynamic IP:


Set hostname

Note: This procedure broke hostname on my system.

By default NetworkManager 0.7 will do a reverse lookup of your IP to determine your hostname. Most times this will result in "localhost".

The solution is to create the file Template:Filename, and add the following.

plugins = keyfile

hostname = <your hostname>

Edit daemons

You must disable the default network daemon and add the hal and networkmanager daemons in this order:

DAEMONS=( ... !network hal networkmanager ... )
Note: If you happen to specify the fam daemon in your array, it must appear after networkmanager. The same also applies to portmap if specified.

Get in the network group

Add yourself to the network group, replacing Template:Codeline with the appropriate user name:

# gpasswd -a USERNAME network

Configure network services

There are quite a few network services that you will not want running until NetworkManager brings up an interface. Good examples are ntpd and network filesystem mounts of various types. NetworkManager can start these services when you bring an interface up, and stop them when you bring it down.

To use this feature just add scripts to /etc/NetworkManager/dispatcher.d and make them executable for all users; for security, make them owned by root:root and writable only by the owner. The scripts will be run in alphabetical order at interface up time, and in reverse alphabetical order at interface down time. To ensure what order they come up in, simply add an alphabetical character and an underscore at the front of the script name; for example, a_portmap and b_netfs (which ensures that the portmapper is up before NFS mounts are attempted).

I found this naming trick useful for the following items: a_portmap b_netfs c_ntpdate d_ntpd e_cups f_clamav I run a local NTP server, and do not connect my laptop to foreign wireless networks. I also make NFS mounts. There's no point in cups if you're not on the network. Clamav's freshclam signature updater requires networking to connect. I may hack on it some to separate the freshclam service from the clamav on-access scanner so I can keep the on-access scanner running all the time but only run freshclam when the networking is up.

Warning: if you connect to foreign or public networks, be aware of what services you are starting and what servers you expect to be available for them to connect to. You could make a security hole by starting the wrong services while connected to a public network.

Proxy settings

Network Manager doesn't directly handle proxy settings.

See Proxy settings for more informations.

PolicyKit issues

Because many Display Managers (including KDM) do not natively support policykit at login, you will run into some permission issues with D-Bus and NetworkManager.

There are several options to resolve this issue (Choose only one).

session	optional	pam_ck_connector.so
Warning: This may cause the malfunction of KDE PowerDevil.
       <policy group="users">
               <allow send_destination="org.freedesktop.NetworkManager"/>
               <allow send_interface="org.freedesktop.NetworkManager"/>

If this does not work, check if there are any policy errors by starting NetworkManager manually:

# kill `pidof NetworkManager`
# NetworkManager --no-daemon
  • Put the following script in ~/.kde4/Autostart or similar for other WMs or DEs:


DHCP problems

If you have problems with getting an IP via DHCP try to add the following to your Template:Filename:

 interface "eth0" {
   send dhcp-client-identifier 01:aa:bb:cc:dd:ee:ff;

Where Template:Codeline is the MAC-adress of this nic.

Problems starting nm-applet as normal user

Sometimes, the gnome applet fails to start with the following error:

** (nm-applet:2941): WARNING **: <WARN>  applet_dbus_manager_start_service(): Could not acquire the NetworkManagerUserSettings
  Message: 'Connection ":1.19" is not allowed to own the service "org.freedesktop.NetworkManagerUserSettings" due to security
policies in the configuration file'

This depends on NetworkManager changing its behaviour since version 0.7, ignoring the "network" group altogether and instead uses ConsoleKit, which seems to be a bit dodgy at times. This solution was provided by madhatter:

Edit your /etc/dbus-1/system.d/NetworkManager.conf to read:

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
        <policy user="root">
                <allow own="org.freedesktop.NetworkManager"/>
                <allow send_destination="org.freedesktop.NetworkManager"/>
                <allow send_interface="org.freedesktop.NetworkManager"/>

        <allow own="org.freedesktop.NetworkManager.PPP"/>
                <allow send_destination="org.freedesktop.NetworkManager.PPP"/>
                <allow send_interface="org.freedesktop.NetworkManager.PPP"/>
        <policy group="network">
                <allow send_destination="org.freedesktop.NetworkManager"/>
                <allow send_interface="org.freedesktop.NetworkManager"/>
        <policy at_console="true">
                <allow send_destination="org.freedesktop.NetworkManager"/>
                <allow send_interface="org.freedesktop.NetworkManager"/>
        <policy context="default">
                <deny own="org.freedesktop.NetworkManager"/>
                <deny send_destination="org.freedesktop.NetworkManager"/>
                <deny send_interface="org.freedesktop.NetworkManager"/>

                <deny own="org.freedesktop.NetworkManager.PPP"/>
                <deny send_destination="org.freedesktop.NetworkManager.PPP"/>
                <deny send_interface="org.freedesktop.NetworkManager.PPP"/>

        <limit name="max_replies_per_connection">512</limit>

Also, change your /etc/dbus-1/system.d/nm-applet.conf to read:

<!DOCTYPE busconfig PUBLIC
 "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
    <policy user="root">
        <allow own="org.freedesktop.NetworkManagerUserSettings"/>

        <allow send_destination="org.freedesktop.NetworkManagerUserSettings"/>
        <allow send_interface="org.freedesktop.NetworkManagerSettings"/>

        <allow send_interface="org.freedesktop.NetworkManagerSettings.Secrets"/>
    <policy group="network">
        <allow own="org.freedesktop.NetworkManagerUserSettings"/>
        <allow send_destination="org.freedesktop.NetworkManagerUserSettings"/>
        <allow send_interface="org.freedesktop.NetworkManagerUserSettings"/>

        <deny send_interface="org.freedesktop.NetworkManagerSettings.Secrets"/>
    <policy at_console="true">
        <allow own="org.freedesktop.NetworkManagerUserSettings"/>

        <allow send_destination="org.freedesktop.NetworkManagerUserSettings"/>
        <allow send_interface="org.freedesktop.NetworkManagerSettings"/>

        <deny send_interface="org.freedesktop.NetworkManagerSettings.Secrets"/>
    <policy context="default">
        <deny own="org.freedesktop.NetworkManagerUserSettings"/>

        <allow send_destination="org.freedesktop.NetworkManagerUserSettings"/>
        <allow send_interface="org.freedesktop.NetworkManagerSettings"/>
        <deny send_interface="org.freedesktop.NetworkManagerSettings.Secrets"/>

    <limit name="max_replies_per_connection">512</limit>

This should solve any problems.

Tips & tricks

Checking Whether Networking Is Up In A Cron Job Or Script

Some cron jobs require networking to be up to succeed. You may wish to avoid running these jobs when the network is down. To accomplish this, add an if test for networking that queries NetworkManager's nm-tool and checks the state of networking. The test shown here succeeds if any interface is up, and fails if they are all down. This is convenient for laptops that might be hardwired, might be on wireless, or might be off the network.

if [ `nm-tool|grep State|cut -f2 -d' '` == "connected" ]; then
       #Whatever you want to do if the network is online
       #Whatever you want to do if the network is offline - note, this and the else above are optional

I find this useful for a cron.hourly script that runs fpupdate for the F-Prot virus scanner signature update, as an example. Another way it might be useful, with a little modification, is to differentiate between networks using various parts of the output from nm-tool; for example, since the active wireless network is denoted with an asterisk, you could grep for the network name and then grep for a literal asterisk.

Automatically unlock keyring after login

This will prevent nm-applet from asking for your keyring password.

In Template:Filename (or your corresponding daemon in /etc/pam.d), add these lines at the end of the "auth" and "session" blocks if they don't exist already:

auth            optional        pam_gnome_keyring.so
session         optional        pam_gnome_keyring.so  auto_start

In Template:Filename, use this line for the 'password' block:

password    optional    pam_gnome_keyring.so

Next time you log in, you should be asked if you want the password to be unlocked automatically on login.

See http://live.gnome.org/GnomeKeyring/Pam for reference.

If you're using kde / kdm you can use pam-keyring-tool from AUR. Put a script like the following in ~/.kde4/Autostart

echo PASSWORD | /usr/bin/pam-keyring-tool --unlock --keyring=default -s

Similar should work with openbox, lxde, etc

Automatically connect on boot

Since version 0.7 the NetworkManager is able to connect on boot, before a user has logged in and unlocked the keyring.

First make sure that the keyfile plugin is loaded Template:Filename should look like this:


If this wasn't in the file before, you have to restart nm-system-settings

# killall -TERM nm-system-settings

or simply reboot.

Now grant your user the right to modify system-connections with

$ sudo polkit-auth --grant org.freedesktop.network-manager-settings.system.modify --user "YOURUSERNAME"

And finally in the connection-editor check the Available to all users box.

The connection is now saved in /etc/NetworkManager/system-connections/"CONNECTION NAME".

On reboot, NetworkManager will try to connect to it, when in range.

Ignore specific devices

Sometimes it is desired, that network manager ignores some devices and don't try to get an IP. First you have to find out the Hal UDI (e.g. with lshal):

info.product = 'Networking Interface'  (string)
info.subsystem = 'net'  (string)
info.udi = '/org/freedesktop/Hal/devices/net_00_1f_11_01_06_55'  (string)
linux.hotplug_type = 2  (0x2)  (int)
linux.subsystem = 'net'  (string)

Add the udi to /etc/NetworkManager/nm-system-settings.conf:


Multiple devices can be specified, delimited by a semicolon:


No need of restarting networkmanager.

Additional Resources