Difference between revisions of "NetworkManager"

From ArchWiki
Jump to navigation Jump to search
m (→‎Configuration: formatting)
Line 100: Line 100:
If you are not already a part of these groups, logout and back in for the changes to take effect.
If you are not already a part of these groups, logout and back in for the changes to take effect.
'''(What is the purpose of this networkmanager group? Everything is possible with the network group.)'''
''(What is the purpose of this networkmanager group? Everything is possible with the network group.)''
=== Disable current network setup ===
=== Disable current network setup ===

Revision as of 23:35, 10 September 2010

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary end

NetworkManager is a program for providing detection and configuration for systems to automatically connect to network. NetworkManager's functionality can be useful for both wireless and wired networks. For wireless networks, NetworkManager prefers known wireless networks and has the ability to be able to switch to the most reliable network. NetworkManager-aware applications can switch from online and offline mode. NetworkManager also prefers wired connections over wireless ones, has support for modem connections and certain types of VPN. NetworkManager was originally developed by RedHat and now is hosted by the GNOME project.

Base install

NetworkManager is available in the official repositories:

# pacman -S networkmanager

Optionally, if you want to share connections across your local network, also known as "Internet Connection Sharing (ICS)":

# pacman -S dnsmasq

Graphical Front-ends

To configure and have easy access to NetworkManager most people will want to install an applet. This GUI front-end usually resides in the system tray (or notification area) and allows network selection and configuration of NetworkManager. Various applets exist for different types of desktops.


GNOME's applet (formerly gnome-network-manager) is lightweight enough and works across all environments:

# pacman -S network-manager-applet

If you want to store authentication details (Wireless/DSL) and enable global connection settings, i.e "available to all users":

# pacman -S gnome-keyring


The KNetworkManager front-end has been made available in KDE version 4.4 as a plasma widget:

# pacman -S kdeplasma-applets-networkmanagement

The GNOME counterpart works just as nicely, or even better (has more features and detects more hardware).


Though no longer supported, Template:Package AUR is in the AUR. Package name:


Other Desktops and Window Managers

It is recommended to use the GNOME applet. You'll also need to be sure that the GNOME hicolor theme is installed to be able to display the applet:

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

Command line

cnetworkmanager, which is now available in the community repository, can be used to configure connections from the command line.

# pacman -S cnetworkmanager


NetworkManager will require some additional steps to be able run properly.

(Someone please verify how true this is. With just a pacman -S network-manager-applet everything works as expected. No hostname or networkmanager group set up.)

Set hostname

By default NetworkManager 0.7 will do a reverse lookup of your IP to determine your hostname to use to display to other networks. Because of how it handles it, generally this will result in a hostname of localhost or localhost.localdomain. Having such a hostname and NetworkManagers attempts to manipulate it can occasionally cause crashes of the Xorg server (citation needed).

To fix this, create a configuration that explicitly defines your hostname. Create the file Template:Filename and add:

plugins = keyfile
hostname = <your hostname>

Verify that your Template:Filename is correct before continuing. If you previously tried to connect before doing this step, NetworkManager may have altered it. An example hostname line in Template:Filename:

#<ip-address> <hostname.domain.org>           <hostname>                    localhost.localdomain localhost dell-latitude

Add user to network and networkmanager groups

To manipulate NetworkManager settings you will be required to be part of the network group OR the networkmanager group (you must create the networkmanager group first) (citation needed). Run the below commands after replacing USERNAME with your username.

# gpasswd -a USERNAME network


# groupadd networkmanager
# gpasswd -a USERNAME networkmanager

If you are not already a part of these groups, logout and back in for the changes to take effect.

(What is the purpose of this networkmanager group? Everything is possible with the network group.)

Disable current network setup

You'll want to disable your current network setup to be able to properly test NetworkManager. First (if using the Arch Linux network scripts) stop the network:

/etc/rc.d/network stop

Bring down your NIC's (Network Interface Controllers, i.e. network cards). For example:

ifconfig eth0  down
ifconfig wlan0 down

Edit Template:Filename and where you defined DHCP or a static IP address, comment them out:

INTERFACES=(!eth0 !wlan0)

Edit daemons

You must remove the default network daemon and add the hal (needs citation; only dbus is needed), and networkmanager daemons in this order:

DAEMONS=( ...hal networkmanager... )

Be sure that the package Template:Package Official is installed as NetworkManager will require it. The hal daemon also starts the dbus daemon, so you should not need to worry. Also, do not background hal as then the dependencies do not get loaded before (and in time for) networkmanager. To start other services (daemons) that require a network connection see the next section on how to set them up. Though the NetworkManager daemon has been started here, it will not (by default) connect onto a network until an applet is loaded and the applet specifies to do so. This means that networking services will need to be specified to NetworkManager on when to run.

Network Services with NetworkManager Dispatcher

There are quite a few network services that you will not want running until NetworkManager brings up an interface. Good examples are openntpd and network filesystem mounts of various types (e.g. netfs). NetworkManager has the ability to start these services when you connect to a network (interface up), and stop them when you are no longer using them (interface down).

To use this feature, scripts can be added to the Template:Filename directory. These scripts will need to have executable, user permissions. For security, it's good practice to make them owned by root:root and writable only by the owner. The scripts will be run in alphabetical order at connection time (with arguments interface up), and in reverse alphabetical order at disconnect time (interface down). To ensure what order they come up in, it is common to use numerical characters prior to the name of the script (e.g. Template:Filename or Template:Filename (which ensures that the portmapper is up before NFS mounts are attempted).

The following starts openntpd when an interface is brought up. Save the file as Template:Filename and make it executable.


INTERFACE=$1 # The interface which is brought up or down
STATUS=$2 # The new state of the interface

case "$STATUS" in
    'up') # $INTERFACE is up
	exec /etc/rc.d/openntpd start
    'down') # $INTERFACE is down
	exec /etc/rc.d/openntpd stop # Disable if having more than one active interface might bring openntpd down unnecessarily
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.

Use dispatcher to connect to a vpn after a network-connection is established

In this example we want to connect automatically to a vpn-connection we defined previously with NetworkManager. First thing to to is to create the dispatcher-script that defines what to do after we connected to the network.

1. Create the dispatcher script in Template:Filename

case "$2" in
               sudo -u username DISPLAY=:0 /usr/bin/python /etc/NetworkManager/vpn-up.py

Remember to make it executable with chmod +x and change username to the right one.

2. Create the Template:Filename and change network-ESSID to the desired one. You'll find the code here.

Now NetworkManager should try to connect to your vpn which you had defined in your profile.

Proxy settings

Network Manager does not directly handle proxy settings.

See: Proxy settings


NetworkManager applets are designed to load upon login so no further configuration should be necessary for most users. If you have already disabled your previous network settings and disconnected from your network, you can now test if NetworkManager will work. First start the daemon:

/etc/rc.d/networkmanager start

Some applets will provide you with a .desktop file so that the NetworkManager applet can be loaded through the application menu. If it doesn't, you're going to either have to discover the command to use or logout and login again to start the applet. Once the applet is started, it will likely begin polling network connections with for auto-configuration with a DHCP server.

To start the GNOME applet in non-xdg-compliant Window Managers like Awesome:

nm-applet --sm-disable &

For static IPs you will have to configure NetworkManager to understand them. The process usually involves right-clicking the applet and selecting something like 'Edit Connections'.


Some fixes to common problems.

Network Management Disabled

Sometimes when NM shuts down the pid (state) file does not get removed and you will get a 'Network management disabled' message. If this happens, you'l have to remove it manually:

rm /var/lib/NetworkManager/NetworkManager.state

If this happens upon reboot, you can add an action to your Template:Filename to have it removed upon bootup:

[ -f $nmpid ] && rm $nmpid

NetworkManager prevents DHCPCD from using resolv.conf.head and resolv.conf.tail

Sometimes it's problematic to add static items to resolv.conf when it's constantly rewritten by nm and dhcpcd. You can use networkmanager-dhclient package from AUR but a better solution is to use this simple script:

# /etc/NetworkManager/dispatcher.d/99-resolv.conf-head_and_tail
# Include /etc/resolv.conf.head and /etc/resolv.conf.tail to /etc/resolv.conf
# scripts in the /etc/NetworkManager/dispatcher.d/ directory
# are called alphabetically and are passed two parameters:
# $1 is the interface name, and $2 is “up” or “down” as the
# case may be.

cat "$resolvconf"{.head,,.tail} 2>/dev/null > "$resolvconf".tmp
mv -f "$resolvconf".tmp "$resolvconf"

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.

How to bypass Gnome keyring for normal users connecting with wireless

It's super simple! First, create a group called networkmanager with the following command (or any other method you prefer):

# groupadd networkmanager

Then add your user to that group using the following command (or any other preferred method):

# gpasswd -a username networkmanager

Replace username in the above command with your actual username.

Now, as root, launch nm-connection-editor and configure the connections:

# nm-connection-editor

Put a check mark next to "Available to all users" and apply the settings.

Now you won't be bothered by Gnome keyring! (citation needed) Also, if you additionally enable "connect automatically", your connection will be available and connected before you even log in to your desktop, making your whole startup process even faster!

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'

Or if you can see the nm-applet icon in xfce4's panel's notification area while login as root but can't see it if login as a normal user, it could indicate you need to modify the policy settings to get nm-applet started as normal user. (Try to start nm-applet in terminal as normal user will give you the error above.)

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

Add the following to your /etc/dbus-1/system.d/NetworkManager.conf

        <policy group="network">
                <allow send_destination="org.freedesktop.NetworkManager"

And to /etc/dbus-1/system.d/nm-applet.conf

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

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

Log out and once you log back in you should be able to run nm-applet and then in the panel be able to select any network, type the password for that network and then you are ready to go.

For OpenVpn you need to add following line in Template:Filename

<allow send_destination="org.freedesktop.NetworkManager"

in section Template:Codeline.

Missing default route

On at least one KDE4 system, no default route was created when establishing wireless connections with NetworkManager. Changing the route settings of the wireless connection to remove the default selection "Use only for resources on this connection" solved the issue.

3G modem not detected

If NetworkManager (from v0.7.999) does not detect your 3G modem, but you still can connect using wvdial, try installing modemmanager package using Template:Codeline and restart NetworkManager daemon with Template:Codeline. Replug your modem or restart. This utility provides support for hardware not in networkmanager's default database.

VPN problems in Networkmanager 0.7.999

If you get the error message "invalid secrets" when trying to connect to your VPN provider using the PPTP protocol, try installing the git versions instead: networkmanager, nm-applet and the pptp plugin.

PolicyKit issues

Note: Following is probably not need for KDE 4 anymore, as there should be PolicyKit integration as of KDE 4.3. At least with knetworkmanager from [kdemod-core], the author did not run into any troubles.

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.

While 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:

Switching off WLAN on laptops

Sometimes networkmanager won't work when you disable your Wifi-adapter with a switch on your laptop and try to enable it again afterwards. This is often a problem with rfkill. Install rfkill from the repo:

# pacman -S rfkill

and use

$ watch -n1 rfkill list all

to check if the driver notifies rfkill about the wireless adapter's status. If one identifier stays blocked after you switch on the adapter you could try to manually unblock it with (where X is the number of the identifier provided by the above output):

# rfkill event unblock X

Tips and tricks

Checking if networking is up inside 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

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


  1. Right click on the NM icon in your panel and select Edit Connections and open the Wireless tab
  2. Select the connection you want to work with and click the Edit button
  3. Check the boxes “Connect Automatically” and “Available to all users”

Log out and log back in to complete.

Note: The following method is dated and known not to work on at least one machine!

*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 do not exist already:

 auth            optional        pam_gnome_keyring.so
 session         optional        pam_gnome_keyring.so  auto_start
 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.


Note: See http://live.gnome.org/GnomeKeyring/Pam for reference, and if you are using kde / kdm, you can use pam-keyring-tool from the 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 was not 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 polkit:

Place the following in /etc/polkit-1/localauthority/50-local.d/10-org-freedesktop-network-manager-settings.pkla

[Allow user YOURUSERNAME to create wireless connections for all users]
Finally, in the connection-editor (of the gnome applet), 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.

Note: As per this bug report, knetworkmanager does not yet implement this feature. You will need to use the GNOME network applet (nm-applet). Install it as described above in this page, "killall knetworkmanager", then start nm-applet.
Please vote for the bug!

Ignore specific devices

Sometimes it is desired, that network manager ignores some devices and do not 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 semicolons:

You do not need to restart NetworkManager for the changes to take effect.