NetworkManager (Español)

From ArchWiki
Revision as of 05:38, 15 July 2012 by Gustawho (Talk | contribs)

Jump to: navigation, search

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:NetworkManager (Español)#)
Template:Article summary start

Template:Article summary text Template:Article summary heading Template:Article summary text Template:Article summary end


Introduccion

Network Manager es un set de herramientas co-operativas que hacen de la creación de redes simple y directa. Sea cableada o inalámbrica, Network Manager te permite mover rapidamente de una conexión a otra: una ves que NetworkManager se ha configurado y conectado a una red, esta puede ser detectada y re-conectada automáticamente a posteriori.

La versión 0.7 es una versión importante de Network Manager.

Algunas de las nuevas características incluyen:

   * Soporte para tarjetas de datos celulares
   * Diversos dispositivos activos
   * Configuración global del sistema
   * Interfaz de control dbus wpa_supplicant
   * Mas métodos de autenticación para redes cableadas/inalámbricas

Paso 1: Instalación

NetworkManager esta disponible en el repositorio [extra]:

# pacman -S networkmanager

Paso 2: GUIs

GNOME

network-manager-applet (anteriormente gnome-network-manager) también esta ahi:

# pacman -S network-manager-applet

Si ningún icono de nm-applet esta en uno de tus paneles en GNOME, y si embargo estas seguro de que se esta ejecutando, intenta agregando un "Área de notificación" al panel.

KDE

KNetworkManager proporciona un icono en la bandeja del sistema y la configuración:

# pacman -S kdeplasma-applets-networkmanagement

KDE3

Puedes intentar usar knetworkmanager el cual ya no es mantenido en ningún repositorio oficial de Arch. Puedes obtenerlo desde AUR.

Xfce

Xfce usa el mismo paquete que GNOME:

# pacman -S network-manager-applet 

También podes instalar el plugin xfapplet, el cual permite que los applets de GNOME sean visualizados en el panel de xfce4:

# pacman -S xfce4-xfapplet-plugin

Si después de la instalación tenes cuatro o más instancias de nm-applet ejecutándose cuando los servicios de gnome inician automáticamente y vos no estas usando un administrador de sesión, considera hacer lo siguiente:

  1. Matar todos los procesos de nm-applet
  2. Agregar nm-applet --sm-disable a la lista de aplicaciones al inicio
  3. Salir de Xfce
  4. Borrar el archivo de sesión de XFCE (en ~/.cache/sessions/)
  5. Ingresar en Xfce

Fluxbox y otros WMs

Necesitarás el tema hicolor para poder ejecutar nm-applet:

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

Después de configurar tu sistema para usarlo con NetworkManager, el inicio automático del applet se hace yendo a Configuración → Aplicaciones al inicio luego agrega, "nm-applet --sm-disable &". Esto deberia iniciar el network manager applet al inicio. La opción "--sm-disable" es usada para prevenir multiples instancias de el nm-applet, y solo lo necesitas si multiples instancias se estan ejecutando cuando inicias sesión.

  • NetworkManager parece tener problemas para cargar en varios box-environments y compiz. Usando el prefijo ck-launch-session, nm-applet parece trabajar bien.

Ex.,

exec ck-launch-session startlxde

Linea de Comandos

cnetworkmanager, disponible en AUR, puede ser usada para configurar conexiones desde la linea de comandos.

Paso 3: Configuración

Desactivar las interfaces

Si queres usar NetworkManager en una interfaz tendrás que desactivar las interfaces en /etc/rc.conf. Lo podes hacer poniendo un "!" al frente de la interfaz de tu elección, por ejemplo:

INTERFACES=(!eth0 !ath0)
Note: Tal vez necesites activar (es decir, quitar el "!") de eth0 de nuevo para que tu tarjeta funcione. Confirmado con el módulo ath_pci madwifi - también puede ser que tangas que volver a activar las tarjetas de red para que funcionen.

NetworkManager analiza /etc/rc.conf para ver si queres una IP estática o dinámica, entonces expresa tu configuración preferia ahí.

Ejemplo para IP estática:

 eth0="eth0 172.19.3.18 netmask 255.255.255.0 broadcast 172.19.3.255"

Ejemplo para Ip dinámica:

 eth0="dhcp"

Establecer hostname

Por defecto NetworkManager 0.7 hará una búsqueda inversa de tu IP para determinar tu hostname. Generalmente, esto dará "localhost" o "localhost.localdomain". También intentará manipular el hostname de el sistema sobre la marcha lo cual ocasionalmente romperá Xorg. La solución es crear el archivo /etc/NetworkManager/nm-system-settings.conf, y agregar lo siguiente:

[main]
plugins = keyfile
 
[keyfile]
hostname = <your hostname>

Asegurate de verificar que /etc/hosts esta bien antes de continuar porque NetworkManager puede haberlo alterado antes de que tuvieras la oportunidad de cambiar esta configuración.

Editar daemons

Debes deshabilitar el daemon network y agregar los daemons hal y networkmanager en este orden:

DAEMONS=( ... !network hal networkmanager ... )
Warning: No uses hal y networkmanager en segundo plano, ya que puede causar la congelación de las entradas de los dispositivos de entrada al inicio de Xorg.
Note: si te sucede que especificaste el daemon fam, este debe aparecer después de networkmanager. Lo mismo se aplica para portmap y netfs si se especifica.

Ingresar al grupo Network

Agregate al grupo network, reemplazando USUARIO con el nombre de usuario apropiado:

# gpasswd -a USUARIO network

Configurando los servicios de Red

Ahi unos cuanto sevicios de red que vos no querrás que se ejecuten hasta que aparezca la interfaz de NM. Algunos buenos ejemplos son ntpd y montaje de sistemas de archivos de red de varios tipos. NetworkManager puede empezar esos servicios cunado inicies la interfaz de NetworkManager, y detenerlos cuando la cierres.

Para usar esta característica, agrega scripts a /etc/NetworkManager/dispatcher.d y hacelos ejecutables para todos los usuarios. Por seguridad, hacelos propiedad de root:root y editables solo por el propietario. Los scripts serán ejecutados en orden alfabético en el momento en que la interfaz inicie(con los argunmentos interface up), y en orden alfabético inverso cunado la interfaz se cierra (con argumentos interface down). Para asegurarse en que orden inician, simplemente agrega un caracter alfabetico y una guión bajo al frente del nombre del script; por ejemplo, a_portmap y b_netfs (lo cual asegura que el asignador de puertos (portmapper) inicie antes de intentar montar NFS).

Un esquema de nombres útiles: a_portmap b_netfs c_ntpdate d_ntpd e_cups f_clamav. Typical usage for this is running a local NTP server on a system that does not connect to foreign wireless networks, and that also employs NFS mounts. There is no point in cups if you are not on the network. Clamav's freshclam signature updater requires networking to connect.

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 does not directly handle proxy settings.

See: Proxy settings

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:

  • Install Consolekit and add the following line to /etc/pam.d/kde:
 session       optional        pam_ck_connector.so
Warning: This may cause the malfunction of KDE PowerDevil.
  • Add the following lines to /etc/dbus-1/system.d/NetworkManager.conf:
       <policy group="users">
               <allow send_destination="org.freedesktop.NetworkManager"/>
               <allow send_interface="org.freedesktop.NetworkManager"/>
       </policy>
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:
 #!/bin/bash
 ck-launch-session

Troubleshooting

DHCP problems

If you have problems with getting an IP via DHCP try to add the following to your /etc/dhclient.conf:

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

Where aa:bb:cc:dd:ee:ff 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
service.
  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 behavior since version 0.7, ignoring the network group altogether and instead uses ConsoleKit, which seems to be problematic 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"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
        <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>
        <policy group="network">
                <allow send_destination="org.freedesktop.NetworkManager"/>
                <allow send_interface="org.freedesktop.NetworkManager"/>
        </policy>
        <policy at_console="true">
                <allow send_destination="org.freedesktop.NetworkManager"/>
                <allow send_interface="org.freedesktop.NetworkManager"/>
        </policy>
        <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"/>
        </policy>

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

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"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
    <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>
    <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>
    <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>
    <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"/>
    </policy>

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

For OpenVPN, you need to add the following lines to /etc/dbus-1/system.d/NetworkManager.conf

<allow send_destination="org.freedesktop.NetworkManager" />
<allow send_interface="org.freedesktop.NetworkManager.openvpn"/>

in the section <policy at_console="true">.

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.

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

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

  • 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:
 auth            optional        pam_gnome_keyring.so
 session         optional        pam_gnome_keyring.so  auto_start
  • In /etc/pam.d/passwd, 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.
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:
 $!/bin/sh
 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, 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; /etc/NetworkManager/nm-system-settings.conf should look like this:
 [main]
 plugins=keyfile
  • 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:
 $ sudo polkit-auth --grant org.freedesktop.network-manager-settings.system.modify --user "YOURUSERNAME"
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 NetworkManager should ignore some devices and not try to get an IP address.

  • 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:
 [keyfile]
   unmanaged-devices=/org/freedesktop/Hal/devices/net_00_1f_11_01_06_55
Multiple devices can be specified, delimited by a semi-colon:
 [keyfile]
   unmanaged-devices=/org/freedesktop/Hal/devices/net_00_1f_11_01_06_55;/org/freedesktop/Hal/devices/net_00_2c_6d_e2_08_af

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

See also