Network Manager VPN support is based on a plug-in system. If you need VPN support via network manager you have to install one of the following packages in [[official repositories]]:

+

Network Manager VPN support is based on a plug-in system. If you need VPN support via network manager you have to install one of the following packages from the [[official repositories]]:

−

networkmanager-openvpn

+

* {{Pkg|networkmanager-openvpn}}

−

networkmanager-pptp

+

* {{Pkg|networkmanager-pptp}}

−

networkmanager-vpnc

+

* {{Pkg|networkmanager-vpnc}}

== Graphical front-ends ==

== Graphical front-ends ==

Line 35:

Line 36:

=== GNOME ===

=== GNOME ===

−

GNOME's {{Pkg|network-manager-applet}} (formerly gnome-network-manager) is lightweight enough and works across all environments.

+

GNOME's {{Pkg|network-manager-applet}} is lightweight enough and works across all environments.

If you want to store authentication details (Wireless/DSL) and enable global connection settings, i.e "available to all users" install and configure [[GNOME Keyring]].

If you want to store authentication details (Wireless/DSL) and enable global connection settings, i.e "available to all users" install and configure [[GNOME Keyring]].

−

=== KDE4 ===

+

=== KDE ===

−

The KNetworkManager front-end has been made available since KDE 4.4 as a Plasma widget available in the official repositories:

+

The KNetworkManager front-end is a Plasma widget available in the official repositories as package {{Pkg|kdeplasma-applets-networkmanagement}}.

−

{{Pkg|kdeplasma-applets-networkmanagement}}.

−

−

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

{{Note|If you are changing from another network managing tool like [[Wicd]], do not forget to set the default 'Network Management Backend' in

{{Note|If you are changing from another network managing tool like [[Wicd]], do not forget to set the default 'Network Management Backend' in

Line 52:

Line 50:

NotShowIn=KDE

NotShowIn=KDE

−

=== KDE3 ===

+

See [http://userbase.kde.org/NetworkManagement Userbase page] for more info.

−

Though no longer supported, {{AUR|kdemod3-knetworkmanager}} can be found in the [[AUR]]. This is a modified version of KNetworkManager for the [[Trinity]] DE and requires NetworkManager 0.8.

=== XFCE ===

=== XFCE ===

Line 61:

Line 58:

(nm-applet:24209): libnotify-WARNING **: Failed to connect to proxy

(nm-applet:24209): libnotify-WARNING **: Failed to connect to proxy

−

** (nm-applet:24209): WARNING **: get_all_cb: couldn't retrieve

** (nm-applet:24209): WARNING **: get_all_cb: couldn't retrieve

system settings properties: (25) Launch helper exited with unknown

system settings properties: (25) Launch helper exited with unknown

return code 1.

return code 1.

−

** (nm-applet:24209): WARNING **: fetch_connections_done: error

** (nm-applet:24209): WARNING **: fetch_connections_done: error

fetching connections: (25) Launch helper exited with unknown return

fetching connections: (25) Launch helper exited with unknown return

code 1.

code 1.

−

** (nm-applet:24209): WARNING **: Failed to register as an agent:

** (nm-applet:24209): WARNING **: Failed to register as an agent:

(25) Launch helper exited with unknown return code 1

(25) Launch helper exited with unknown return code 1

Line 117:

Line 111:

Verify that your {{ic|/etc/hosts}} is correct before continuing. If you previously tried to connect before doing this step, NetworkManager may have altered it. An example hostname line in {{ic|/etc/hosts}}:

Verify that your {{ic|/etc/hosts}} is correct before continuing. If you previously tried to connect before doing this step, NetworkManager may have altered it. An example hostname line in {{ic|/etc/hosts}}:

−

{{bc|

+

{{hc|/etc/hosts|

−

#<ip-address> <hostname.domain.org> <hostname>

+

127.0.0.1 localhost

−

127.0.0.1 localhost.localdomain localhost dell-latitude

+

::1 localhost

+

}}

+

+

In case you have nss-myhostname turned off, the line would look like:

+

+

{{hc|/etc/hosts|

+

127.0.0.1 my-laptop localhost

+

::1 my-laptop localhost

}}

}}

=== Disable current network setup ===

=== Disable current network setup ===

+

You will want to disable your current network setup to be able to properly test NetworkManager

+

+

First, [[Daemon|stop]] the network daemon:

+

+

# systemctl stop net-auto-wireless.service

−

You will want to disable your current network setup to be able to properly test NetworkManager:

+

Then, disable currently running network daemons.

−

# If using the Arch Linux network scripts, [[Daemon|stop]] the network daemon.

# Finally, edit {{ic|/etc/rc.conf}} to '''remove''' the default ''network'' daemon or any other network management daemons you may be using.

+

# ip link set eth0 down

+

# ip link set wlan0 down

=== Enable NetworkManager ===

=== Enable NetworkManager ===

−

−

How you enable NetworkManager depends on how your system is configured. New installations now use [[systemd]] by default. Many users have transitioned to systemd, which will become the default in the future.

Once the NetworkManager daemon is started, it will automatically connect to any available "system connections" that have already been configured. Any "user connections" or unconfigured connections will need {{ic|nmcli}} or an applet to configure and connect.

Once the NetworkManager daemon is started, it will automatically connect to any available "system connections" that have already been configured. Any "user connections" or unconfigured connections will need {{ic|nmcli}} or an applet to configure and connect.

−

−

==== Enable NetworkManager with systemd ====

You can enable NetworkManager at startup with the following command:

You can enable NetworkManager at startup with the following command:

−

{{bc|# systemctl enable NetworkManager.service}}

+

{{bc|# systemctl enable NetworkManager}}

You can start the NetworkManager daemon immediately with the following command:

You can start the NetworkManager daemon immediately with the following command:

−

{{bc|# systemctl start NetworkManager.service}}

+

{{bc|# systemctl start NetworkManager}}

−

{{Note|If you have services which fail if they are started before the network is up, you have to use {{ic|NetworkManager-wait-online.service}} instead. This is however hardly ever necessary since most network daemons start up fine, even if the network has not been configured yet.}}

+

=== Enable NetworkManager Wait Online ===

+

If you have services which fail if they are started before the network is up, you have to use {{ic|NetworkManager-wait-online.service}} in addition to the NetworkManager service. This is however hardly ever necessary since most network daemons start up fine, even if the network has not been configured yet.

−

==== Enable NetworkManager with legacy initscripts ====

+

You can enable NetworkManager Wait Online at startup with the following command:

−

To enable NetworkManager at startup, edit the ''DAEMONS'' line in {{ic|/etc/rc.conf}} by '''adding''' the ''networkmanager'' daemon, after the dbus daemon:

+

{{bc|# systemctl enable NetworkManager-wait-online}}

−

DAEMONS=( ...'''dbus networkmanager'''... )

+

In some cases the service will still fail to start sucessfully on boot:

−

Be sure that the package {{Pkg|dbus}} is installed as NetworkManager will require it. To start other services (daemons) that require a network connection see the next section on how to set them up.

All users in the {{ic|network}} group will be able to add and remove networks without a password. This will not work under systemd if you do not have an active session with [[Systemd#Using_systemd-logind|systemd-logind]].

All users in the {{ic|network}} group will be able to add and remove networks without a password. This will not work under systemd if you do not have an active session with [[Systemd#Using_systemd-logind|systemd-logind]].

Line 207:

Line 202:

The following example starts the OpenNTPD daemon when an interface is brought up. Save the file as {{ic|/etc/NetworkManager/dispatcher.d/20_openntpd}} and make it executable.

The following example starts the OpenNTPD daemon when an interface is brought up. Save the file as {{ic|/etc/NetworkManager/dispatcher.d/20_openntpd}} and make it executable.

+

{{bc|<nowiki>

{{bc|<nowiki>

#!/bin/sh

#!/bin/sh

−

+

interface=$1 status=$2

−

INTERFACE=$1 # The interface which is brought up or down

+

case $status in

−

STATUS=$2 # The new state of the interface

+

up)

−

+

systemctl start openntpd

−

case "$STATUS" in

+

;;

−

'up') # $INTERFACE is up

+

down)

−

exec rc.d start openntpd

+

if ! nm-tool | awk '/State:/{print $2}' | grep -qs connected; then

−

;;

+

systemctl stop openntpd

−

'down') # $INTERFACE is down

+

fi

−

# Check for active interface and down if no one active

+

;;

−

if [ ! `nm-tool|grep State|cut -f2 -d' '` = "connected" ]; then

−

exec rc.d stop openntpd

−

fi

−

;;

esac

esac

</nowiki>}}

</nowiki>}}

Line 228:

Line 220:

==== Mount remote folder with sshfs ====

==== Mount remote folder with sshfs ====

−

As the script is run in a very restrictive environment, you have to export {{ic|SSH_AUTH_SOCK}} in order to connect to your SSH agent. There are different ways to accomplish this, see [https://bbs.archlinux.org/viewtopic.php?pid=1042030#p1042030 this link] for more information. The example below works with [[gnome-keyring]], and will ask you for the password if not unlocked already. In case NetworkManager connects automatically on login, it is likely gnome-keyring has not yet started and the export will fail (hence the sleep). The {{ic|UUID}} to match can be found in {{ic|/etc/NetworkManager/system-connections/}}).

+

As the script is run in a very restrictive environment, you have to export {{ic|SSH_AUTH_SOCK}} in order to connect to your SSH agent. There are different ways to accomplish this, see [https://bbs.archlinux.org/viewtopic.php?pid=1042030#p1042030 this link] for more information. The example below works with [[gnome-keyring]], and will ask you for the password if not unlocked already. In case NetworkManager connects automatically on login, it is likely gnome-keyring has not yet started and the export will fail (hence the sleep). The {{ic|UUID}} to match can be found with the command {{ic|nmcli con status}} or {{ic|nmcli con list}}.

if [ "$(iwgetid | grep ':"'$ESSID'"')" ]; then # check for ESSID match and that VPN is actually connected

+

down)

−

if [ $(nmcli con status id "$VPN_NAME" | grep -c activated) ]; then

+

if iwgetid | grep -qs ":\"$ESSID\""; then

−

nmcli con down id "$VPN_NAME";

+

if nmcli con status id "$VPN_NAME" | grep -qs activated; then

+

nmcli con down id "$VPN_NAME"

fi

fi

fi

fi

−

fi

+

;;

+

esac

</nowiki>}}

</nowiki>}}

Remember to make it executable with {{ic|chmod +x}} and to make the VPN connection available to all users.

Remember to make it executable with {{ic|chmod +x}} and to make the VPN connection available to all users.

Line 274:

Line 275:

{{Note|It may now be necessary to re-open the NetworkManager connection editor and re-enter the VPN passwords/secrets.}}

{{Note|It may now be necessary to re-open the NetworkManager connection editor and re-enter the VPN passwords/secrets.}}

−

−

==== Use /etc/rc.conf to control services started by networkmanager ====

−

−

Some Arch users may dislike having two places where the launching of daemons is configured. Using this method, network services started by NetworkManager are controlled from {{ic|rc.conf}} by the use of a {{ic|NET_DAEMONS}} array in the same fashion as the typical {{ic|DAEMONS}} array

−

−

# Install {{AUR|networkmanager-dispatcher-net_daemons}} from the [[AUR]].

−

# Ensure ''dbus'' and ''networkmanager'' are both in the {{ic|DAEMONS}} line in {{ic|rc.conf}}.

−

# Add a {{ic|NET_DAEMONS}} line to rc.conf which includes all services you do not want started until after the network connection is established.

−

−

Example {{ic|DAEMONS}} and {{ic|NET_DAEMONS}} in {{ic|rc.conf}} are shown below:

NetworkManager will attempt to write DNS information from DHCP into {{ic|/etc/resolv.conf}}, overwriting the existing contents. To prevent this, you can set the immutable bit on the file:

+

See [[Resolv.conf]].

−

# chattr +i /etc/resolv.conf

−

−

To modify the file in the future, first remove the immutable bit:

−

# chattr -i /etc/resolv.conf

=== DHCP problems ===

=== DHCP problems ===

Line 377:

Line 356:

in {{ic|/etc/dhcpcd.conf}} (note that this file is distinct from {{ic|dhcpd.conf}}). This should not cause issues unless you have multiple DHCP servers on your network (not typical); see [http://technet.microsoft.com/en-us/library/cc977442.aspx this page] for more information.

in {{ic|/etc/dhcpcd.conf}} (note that this file is distinct from {{ic|dhcpd.conf}}). This should not cause issues unless you have multiple DHCP servers on your network (not typical); see [http://technet.microsoft.com/en-us/library/cc977442.aspx this page] for more information.

+

=== Hostname problems ===

+

Add the following line to /etc/NetworkManager/NetworkManager.conf:

+

dhcp=dhcpcd

+

then restart.

+

systemctl restart NetworkManager

+

source https://bbs.archlinux.org/viewtopic.php?id=152376

=== Missing default route ===

=== Missing default route ===

Line 384:

Line 369:

If NetworkManager (from v0.7.999) does not detect your 3G modem, but you still can connect using [[wvdial]], try installing

If NetworkManager (from v0.7.999) does not detect your 3G modem, but you still can connect using [[wvdial]], try installing

−

{{Pkg|modemmanager}} and restart NetworkManager daemon with {{ic|rc.d restart networkmanager}}. It may also be necessary to replug or restart your modem. This utility provides support for hardware not in NetworkManager's default database.

+

{{Pkg|modemmanager}} and restart NetworkManager daemon with {{ic|systemctl restart NetworkManager}}. It may also be necessary to replug or restart your modem. This utility provides support for hardware not in NetworkManager's default database.

=== Switching off WLAN on laptops ===

=== Switching off WLAN on laptops ===

Line 403:

Line 388:

To work around this issue you have to edit the default connection (e.g. "Auto eth0") in {{ic|nm-applet}}, change the connection name (e.g. "my eth0"), uncheck the "Available to all users" checkbox, change your static IP settings as desired, and click '''Apply'''. This will save a new connection with the given name.

To work around this issue you have to edit the default connection (e.g. "Auto eth0") in {{ic|nm-applet}}, change the connection name (e.g. "my eth0"), uncheck the "Available to all users" checkbox, change your static IP settings as desired, and click '''Apply'''. This will save a new connection with the given name.

−

Next, you will want to make the default connection not connect automatically. To do so, run

+

Next, you will want to make the default connection not connect automatically. To do so, run {{ic|nm-connection-editor}} (''not'' as root). In the connection editor, edit the default connection (eg "Auto eth0") and uncheck "Connect automatically". Click '''Apply''' and close the connection editor.

−

−

$ sudo nm-connection-editor # you must use sudo, not su

−

−

In the connection editor, edit the default connection (eg "Auto eth0") and uncheck "Connect automatically". Click '''Apply''' and close the connection editor.

This may need to be done for any other NM VPN plugins as well, but these are the two most common.

== Tips and tricks ==

== Tips and tricks ==

+

+

=== Sharing internet connection over wifi ===

+

+

You can share your internet connection (eg.: 3G or wired) by few clicks using nm. You will need supported wifi card (Cards based on Atheros AR9xx or at least AR5xx are probably best choice)

+

+

==== Ad-hoc ====

+

+

* pacman -S dnsmasq

+

* custom dnsmasq.conf may interfere with nm (not sure about this, but i think so)

+

* Click on nm-applet -> Create new wireless network

+

* Follow wizard (if using WEP be sure to use 5 or 13 charactes long password, different lengths will fail)

+

* Settings will remain stored for next time you'll need it

+

+

==== Real AP ====

+

+

Support of infrastructure mode (which is needed by Andoid phones as they don't intentionally support ad-hoc) is not currently supported by NetworkManager, but is in active development...

+

+

See: http://fedoraproject.org/wiki/Features/RealHotspot

=== Checking if networking is up inside a cron job or script ===

=== Checking if networking is up inside a cron job or script ===

Line 463:

Line 478:

==== SLiM login manager ====

==== SLiM login manager ====

−

+

See [[Slim#SLiM and Gnome Keyring]].

−

*In {{ic|/etc/pam.d/slim}}, 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

−

−

*In {{ic|/etc/pam.d/passwd}}, use this line for the 'password' block:

−

password optional pam_gnome_keyring.so

−

−

*In {{ic|~/.xinitrc}}, add this at the very top, before launching your window manager and other applications:

−

# test for an existing bus daemon, just to be safe

−

if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then

−

# if not found, launch a new one

−

eval `dbus-launch --sh-syntax --exit-with-session`

−

echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS"

−

fi

−

−

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

=== Ignore specific devices ===

=== Ignore specific devices ===

−

Sometimes it may be desired that NetworkManager ignores specific devices and does not try to configure addresses and routes for them.

+

Sometimes it may be desired that NetworkManager ignores specific devices and does not try to configure addresses and routes for them.You can quickly and easily ignore devices by MAC by using the following in {{ic|/etc/NetworkManager/NetworkManager.conf}} :

−

−

:1. You can quickly and easily ignore devices by MAC by using the following in {{ic|/etc/NetworkManager/NetworkManager.conf}} :

[keyfile]

[keyfile]

unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4

unmanaged-devices=mac:00:22:68:1c:59:b1;mac:00:1E:65:30:D1:C4

−

:After you have put this in, [[Daemon|restart]] NetworkManager, and you should be able to configure interfaces without NetworkManager altering what you have set.

+

After you have put this in, [[Daemon|restart]] NetworkManager, and you should be able to configure interfaces without NetworkManager altering what you have set.

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

−

−

:3. Devices could also be ignored at boot time by using following script (change {{ic|NetworkManager.conf}} with {{ic|nm-system-settings.conf}} if using a version of NetworkManager smaller than 0.8.1):

Revision as of 17:57, 4 April 2013

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 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 Red Hat and now is hosted by the GNOME project.

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.

XFCE

network-manager-applet will work fine in XFCE, but in order to see notifications, including error messages, nm-applet needs an implementation of the Freedesktop desktop notifications specification (see the Galapago Project) to display them. To enable notifications install xfce4-notifyd, a package that provides an implementation for the specification.

Without such a notification daemon, nm-applet outputs the following errors to stdout/stderr:

Openbox

To function properly in Openbox, the GNOME applet requires the xfce4-notifyd notification daemon for the same reason as in XFCE and the gnome-icon-theme package to be able to display the applet in the systray.

If you want to store authentication details (Wireless/DSL) install and configure gnome-keyring.

Note: If the networkmanager daemon is in rc.conf, the following settings are obsolete or the applet will be started twice.

To have Openbox's autostart start nm-applet properly, you may need to delete the file /etc/xdg/autostart/nm-applet.desktop (You may need to delete this file again after every update to network-manager-applet).

Then in autostart, start nm-applet with this line:

(sleep 3 && /usr/bin/nm-applet --sm-disable) &

If you experience errors connecting, make sure you have your D-Bus user session started.

Other desktops and window managers

In all other scenarios it is recommended to use the GNOME applet. You will also need to be sure that the gnome-icon-theme package is installed to be able to display the applet.

Enable NetworkManager

Once the NetworkManager daemon is started, it will automatically connect to any available "system connections" that have already been configured. Any "user connections" or unconfigured connections will need nmcli or an applet to configure and connect.

You can enable NetworkManager at startup with the following command:

# systemctl enable NetworkManager

You can start the NetworkManager daemon immediately with the following command:

# systemctl start NetworkManager

Enable NetworkManager Wait Online

If you have services which fail if they are started before the network is up, you have to use NetworkManager-wait-online.service in addition to the NetworkManager service. This is however hardly ever necessary since most network daemons start up fine, even if the network has not been configured yet.

You can enable NetworkManager Wait Online at startup with the following command:

# systemctl enable NetworkManager-wait-online

In some cases the service will still fail to start sucessfully on boot:

Set up PolicyKit permissions

With a working session, you have several options for granting the necessary privileges to NetworkManager:

Option 1. Run a PolicyKit authentication agent when you log in, such as /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 (part of polkit-gnome). You will be prompted for your password whenever you add or remove a network connection.

Option 2. Add yourself to the wheel group. You will not have to enter your password, but your user account may be granted other permissions as well, such as the ability to use sudo without entering the root password.

Option 3. Add yourself to the network group and create the following file:

All users in the network group will be able to add and remove networks without a password. This will not work under systemd if you do not have an active session with systemd-logind.

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 and stop them when you disconnect.

To use this feature, scripts can be added to the /etc/NetworkManager/dispatcher.d directory. These scripts will need to have executable, user permissions. For security, it is 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, and in reverse alphabetical order at disconnect time. They receive two arguments: the name of the interface (e.g. eth0) and the status (up or 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. 10_portmap or 30_netfs (which ensures that the portmapper is up before NFS mounts are attempted).

Warning: For security reason. You should disable write access for group and other. For example use 755 mask.
In other case it can refuse to execute script, with error message "nm-dispatcher.action: Script could not be executed: writable by group or other, or set-UID." in /var/log/messages.log

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.

Start OpenNTPD

The following example starts the OpenNTPD daemon when an interface is brought up. Save the file as /etc/NetworkManager/dispatcher.d/20_openntpd and make it executable.

Mount remote folder with sshfs

As the script is run in a very restrictive environment, you have to export SSH_AUTH_SOCK in order to connect to your SSH agent. There are different ways to accomplish this, see this link for more information. The example below works with gnome-keyring, and will ask you for the password if not unlocked already. In case NetworkManager connects automatically on login, it is likely gnome-keyring has not yet started and the export will fail (hence the sleep). The UUID to match can be found with the command nmcli con status or nmcli con list.

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

In this example we want to connect automatically to a previously defined VPN connection after connecting to a specific WiFi network. First thing to do is to create the dispatcher script that defines what to do after we are connected to the network.

Remember to make it executable with chmod +x and to make the VPN connection available to all users.

Trying to connect using this setup will fail and NetworkManager will complain about 'no valid VPN secrets', because of the way VPN secrets are stored which brings us to step 2:

2. Edit your VPN connection configuration file to make NetworkManager store the secrets by itself rather than inside a keyring that will be inaccessible for root: open up /etc/NetworkManager/system-connections/<name of your VPN connection> and change the password-flags and secret-flags form 1 to 0.

Note: It may now be necessary to re-open the NetworkManager connection editor and re-enter the VPN passwords/secrets.

Proxy settings

NetworkManager does not directly handle proxy settings, but if you are using GNOME, you could use proxydriver wich handles proxy settings using NetworkManager's informations. You can find the package for proxydriverAUR in the AUR.

In order for proxydriver to be able to change the proxy settings, you would need to execute this command, as part of the GNOME startup process (System -> Preferences -> Startup Applications):

Testing

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. The first step is to start the networkmanager daemon.

Some applets will provide you with a .desktop file so that the NetworkManager applet can be loaded through the application menu. If it does not, you are 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'.

Troubleshooting

Some fixes to common problems.

No traffic via PPTP tunnel

PPTP connection logins successfully, you see ppp0 interface with correct VPN IP, but you cannot even ping remote IP. It is due to lack of MPPE (Microsoft Point-to-Point Encryption) support in stock Arch pppd. It is recommended to first try with the stock Arch ppp as it may work as intended.

To solve the problem it should be sufficient to install ppp-mppeAUR from the AUR.

Network management disabled

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

# rm /var/lib/NetworkManager/NetworkManager.state

If this happens upon reboot, you can add an action to your /etc/rc.local to have it removed upon bootup:

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

Sometimes it is problematic to add static items to resolv.conf when it is constantly rewritten by NetworkManager and dhcpcd. A simple solution is using the following script:

#!/bin/bash
#
# /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.
resolvconf='/etc/resolv.conf';
cat "$resolvconf"{.head,,.tail} 2>/dev/null > "$resolvconf".tmp
mv -f "$resolvconf".tmp "$resolvconf"

DHCP problems

Where aa:bb:cc:dd:ee:ff is the MAC address of this NIC. The MAC address can be found using the ip link show eth0 command from the iproute2 package.

For some (incompliant) routers, you will not be able to connect properly unless you comment the line

require dhcp_server_identifier

in /etc/dhcpcd.conf (note that this file is distinct from dhcpd.conf). This should not cause issues unless you have multiple DHCP servers on your network (not typical); see this page for more information.

Hostname problems

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 and restart NetworkManager daemon with systemctl restart NetworkManager. It may also be necessary to replug or restart your modem. This utility provides support for hardware not in NetworkManager's default database.

Switching off WLAN on laptops

Sometimes NetworkManager will not 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 official repositories 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

Static IP settings revert to DHCP

Due to an unresolved bug, when changing default connections to static IP, nm-applet may not properly store the configuration change, and will revert to automatic DHCP.

To work around this issue you have to edit the default connection (e.g. "Auto eth0") in nm-applet, change the connection name (e.g. "my eth0"), uncheck the "Available to all users" checkbox, change your static IP settings as desired, and click Apply. This will save a new connection with the given name.

Next, you will want to make the default connection not connect automatically. To do so, run nm-connection-editor (not as root). In the connection editor, edit the default connection (eg "Auto eth0") and uncheck "Connect automatically". Click Apply and close the connection editor.

Cannot edit connections as normal user

Forget hidden wireless network

Since hidden network are not displayed in the selection list of the Wireless view, they cannot be forgotten (removed) with the GUI. You can delete one with the following command:

# rm /etc/NetworkManager/system-connections/[SSID]

This works for any other connection.

VPN not working in Gnome

When setting up openconnect or vpnc connections in NetworkManager while using Gnome, you'll sometimes never see the dialog box pop up and the following error appears in /var/log/errors.log:

localhost NetworkManager[399]: <error> [1361719690.10506] [nm-vpn-connection.c:1405] get_secrets_cb(): Failed to request VPN secrets #3: (6) No agents were available for this request.

This is caused by the Gnome NM Applet expecting dialog scripts to be at /usr/lib/gnome-shell, when NetworkManager's packages put them in /usr/lib/networkmanager.
As a "temporary" fix (this bug has been around for a while now), make the following symlink(s):

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
else
#Whatever you want to do if the network is offline - note, this and the else above are optional
fi

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

GNOME

Right click on the nm-applet icon in your panel and select Edit Connections and open the Wireless tab

Select the connection you want to work with and click the Edit button

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 /etc/pam.d/gdm (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:

SLiM login manager

Ignore specific devices

Sometimes it may be desired that NetworkManager ignores specific devices and does not try to configure addresses and routes for them.You can quickly and easily ignore devices by MAC by using the following in /etc/NetworkManager/NetworkManager.conf :

After you have put this in, restart NetworkManager, and you should be able to configure interfaces without NetworkManager altering what you have set.

Connect faster

Disabling IPv6

Slow connection or reconnection to the network may be due to superfluous IPv6 queries in NetworkManager. If there is no IPv6 support on the local network, connecting to a network may take longer than normal while NetworkManager tries to establish an IPv6 connection that eventually times out. The solution is to disable IPv6 within NetworkManager which will make network connection faster. This has to be done once for every network you connect to.

Right-click on the network status icon.

Click on "Edit Connections".

Go to the "Wired" or "Wireless" tab, as appropriate.

Select the name of the network.

Click on "Edit".

Go to the "IPv6 Settings" tab.

In the "Method" dropdown, choose "Ignore/Disabled".

Click on "Save".

Speed up DHCP by disabling ARP probing in DHCPCD

dhcpcd contains an implementation of a recommendation of the DHCP standard (RFC2131 section 2.2) to check via ARP if the assigned IP address is really not taken. This seems mostly useless in home networks, so you can save about 5 seconds on every connect by adding the following line to /etc/dhcpcd.conf:

noarp

This is equivalent to passing --noarp to dhcpcd, and disables the described ARP probing, speeding up connections to networks with DHCP.

Use OpenDNS servers

Create /etc/resolv.conf.opendns with the nameservers:

nameserver 208.67.222.222
nameserver 208.67.220.220

or use Google DNS servers, because people have been getting ads via the OpenDNS servers lately

nameserver 8.8.8.8
nameserver 8.8.4.4

And have the dispatcher replace the discovered DHCP servers with the OpenDNS ones: