IMPORTANT: Per accedir als fitxer de subversion: http://acacha.org/svn (sense password). Poc a poc s'aniran migrant els enllaços. Encara però funciona el subversion de la farga però no se sap fins quan... (usuari: prova i la paraula de pas 123456)

Introducció

Network Manager és una aplicació l'objectiu de la qual és proporcionar una eina gràfica que permeti configurar la xarxa amb el mínim esforç i sense que els usuaris hagin de tocar res de la terminal.

Network Manager només gestiona les interfícies de xarxa que no tinguin instàncies existents de configuració (entrades al fitxer /etc/network/interfaces). Veieu la documentació dels paquets Debian.

Reiniciar Network Manager

$ sudo service network-manager restart

NOTA: No reinicia el servidor esclau dnsmasq per lo que si heu aplicat canvis a dnsmasq heu de matar el procés i executar el restart

Docs obsolets?:

Network Manager utilitza DBus. Sempre que fem canvis a Network Manager i els vulguem aplicar és necessari executar:

$ sudo /etc/dbus-1/event.d/25NetworkManager restart

Configuració

ls -la /etc/NetworkManager
total 40
drwxr-xr-x   7 root root  4096 set 27 09:04 .
drwxr-xr-x 164 root root 12288 gen 19 11:51 ..
drwxr-xr-x   2 root root  4096 abr 17  2015 conf.d
drwxr-xr-x   4 root root  4096 set 27 09:04 dispatcher.d
drwxr-xr-x   2 root root  4096 gen 19 09:38 dnsmasq.d
-rw-r--r--   1 root root    76 abr 17  2015 NetworkManager.conf
drwxr-xr-x   2 root root  4096 gen 12 16:19 system-connections
drwxr-xr-x   2 root root  4096 abr 22  2015 VPN


Connexions

Exemple de connexió wifi

$  sudo cat /etc/NetworkManager/system-connections/aula-202
[connection]
id=aula-202
uuid=d2b28194-9c29-4d47-bc37-e1ef6dbd11ed
type=wifi

[wifi]
ssid=aula-202 
mode=infrastructure 
mac-address=00:1B:11:12:67:07

[wifi-security]
key-mgmt=wpa-psk
auth-alg=open
psk=PASSWORD_HERE

[ipv4]
method=auto

[ipv6]
method=auto

Network Manager a Debian

A Debian per poder utilitzar Network Manager s'ha de pertànyer a un grup (normalment ja és així) anomenat netdev:

$ groups
sergi dialout cdrom floppy audio video plugdev netdev powerdev admin vboxusers

Si no hi pertanyeu heu d'afegir-vos amb la comanda:

$ sudo addgroup -G -a netdev user

I reiniciar Dbus:

$ sudo /etc/init.d/dbus reload

Documentació del paquet Debian a Ubuntu

$ cat /usr/share/doc/network-manager/README.Debian
NetworkManager consists of two parts: one is on the system level daemon that
manages the connections and gathers information about new networks. The other 
is a systray applet that users can use to interact with the NetworkManager 
daemon. 

Configuration of wireless and ethernet interfaces
13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)acacha 13:05, 17 gen 2008 (CET)
Only devices that are *not* listed in /etc/network/interfaces are managed by NM.

After modifying /etc/network/interfaces you may want to restart NM with the
command "/etc/dbus-1/event.d/25NetworkManager restart".

Dial-up configuration
13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)13:05, 17 gen 2008 (CET)~
After configuring your PPP interface (either manually or by using a tool like
"pppconfig") to work with a peer called "myisp" you should edit 
/etc/network/interfaces and add a stanza like this: 

iface ppp0 inet ppp
        provider myisp

NM will then make it possible to dial this connection.
If you want to set up multiple internet service providers simply create a new 
stanza as listed above specifying the provider and a different iface, e.g. ppp1. 

After modifying /etc/network/interfaces you have to restart NM with the
command "/etc/dbus-1/event.d/25NetworkManager restart".

Please read the "Debian Reference Manual", section 10.6.1.4 or the "interfaces"
man page for further information.

-- Tollef Fog Heen <tfheen@debian.org>, Fri, 15 Dec 2006 15:00:30 +0100 
$ cat /usr/share/do c/network-manager/README
THEORY OF OPERATION: 

NetworkManager attempts to keep an active network connection available at all
times.  The point of NetworkManager is to make networking configuration and
setup as painless and automatic as possible.  If using DHCP, NetworkManager is
_intended_ to replace default routes, obtain IP addresses from a DHCP server,
and change nameservers whenever it sees fit.  In effect, the goal of
NetworkManager is to make networking Just Work.  If you have special needs,
we'd like to hear about them, but understand that NetworkManager is not
intended to serve the needs of all users.
 
From a list of all adapters currently installed on the system, NetworkManager
will first try a wired and then a wireless adapter.  Wireless adapters that
support wireless scanning are preferred over ones that cannot.  NetworkManager
does not try to keep a connection up as long as possible, meaning that plugging
into a wired network will switch the connection to the wired network away from
the wireless one.

For wireless networking support, NetworkManager keeps a list of wireless
networks, the preferred list.  Preferred Networks are wireless networks that
the user has explicitly made NetworkManager associate with at some previous
time.  So if the user walks into a Starbucks and explicitly asks NetworkManager to associate with that Starbucks network, NetworkManager will remember  
the  Starbucks network information from that point on.  Upon returning to that
Starbucks, NetworkManager will attempt to associate _automatically_ with the
Starbucks network since it is now in the Preferred Networks list.  The point of
this is to ensure that only the user can determine which wireless networks to
associate with, and that the user is aware which networks are security risks
and which are not. 


STRUCTURE:

NetworkManager runs as a root-user system level daemon, since it
must manipulate hardware directly.  It communicates over DBUS with a
desktop-level per-user process, nm-applet.  Since Preferred Networks are
user-specific, there must be some mechanism of getting this information
per-user.  NetworkManager cannot store that information as it is user-specific,
and therefore communicates over DBUS to the user daemon which provides those
lists.  NetworkManager also provides an API over DBUS for any DBUS-aware
application to determine the current state of the network, including available
wireless networks the computer is aware of and specific details about those
networks.  This API also provides the means for forcing NetworkManager to 
associate with a specific wireless network.  Use of DBUS allows separation of
NetworkManager, which requires no user-interface, and the parts of the user
interface which might be desktop environment specific.

The nm-applet provides a DBUS service called NetworkManagerInfo, which should
provide to NetworkManager the Preferred Networks lists upon request.  It also
should be able to display a dialog to retrieve a WEP/WPA key or passphrase from
the user when NetworkManager requests it.  The GNOME version of
NetworkManagerInfo, for example, stores Preferred Networks in GConf and
WEP/WPA keys in gnome-keyring, and proxies that information to NetworkManager
upon request.

Documentació del paquet Debian a Debian

$ cat /usr/share/doc/network-manager/README.Debian
NetworkManager consists of two parts: one is on the system level daemon that
manages the connections and gathers information about new networks. The other 
is a systray applet that users can use to interact with the NetworkManager 
daemon. 

Security
13:04, 17 gen 2008 (CET)acacha
To allow users to connect to the NetworkManager daemon they have to be in the
group "netdev". If you want to add a user to group "netdev" use the command
"adduser username netdev" or one of the graphical user management frontends.
After that you have to reload D-Bus with the command "/etc/init.d/dbus reload".  

Configuration of wireless and ethernet interfaces
13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)acacha 13:04, 17 gen 2008 (CET)
Only devices that are *not* listed in /etc/network/interfaces or which have 
been configured "auto" and "dhcp" (with no other options) are managed by NM.  

This way you can setup a custom (static) configuration for a device and NM 
will not try to override this setting.  

After modifying /etc/network/interfaces you have to restart NM with the
command "/etc/dbus-1/event.d/25NetworkManager restart".   

Examples: 

1.)
auto wlan0
iface wlan0 inet dhcp
- > This device is managed by NM.

1.a)
allow-hotplug eth0
iface eth0 inet dhcp
-> This device is managed by NM

2.)
auto wlan0
iface wlan0 inet dhcp
        wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
-> This devices is *not* managed by NM because it has additional options. 

3.)
iface wlan0 inet dhcp
-> This device is *not* managed by NM because it is not set to "auto".  

4.)
iface eth0 inet static
        address 192.168.1.10
        netmask 255.255.255.0
        gateway 192.168.1.1
->This device is *not* managed by NM because it is configured as "static" and
   has additional options. 

5.)
Device is not listed in /etc/network/interfaces.
-> Device is managed by NM. 

Dial-up configuration
13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)13:04, 17 gen 2008 (CET)~
After configuring your PPP interface (either manually or by using a tool like
"pppconfig") to work with a peer called "myisp" you should edit 
/etc/network/interfaces and add a stanza like this: 

iface ppp0 inet ppp 
        provider myisp

NM will then make it possible to dial this connection.
If you want to set up multiple internet service providers simply create a new 
stanza as listed above specifying the provider and a different iface, e.g. ppp1. 

After modifying /etc/network/interfaces you have to restart NM with the
command "/etc/dbus-1/event.d/25NetworkManager restart".

Please read the "Debian Reference Manual", section 10.6.1.4 or the "interfaces"
man page for further information.

/etc/NetworkManager/dispatcher.d/01ifupdown

$ cat /etc/NetworkManager/dispatcher.d/01ifupdown
#!/bin/sh -e
# Script to dispatch NetworkManager events
#
# Runs ifupdown scripts when NetworkManager fiddles with interfaces. 

if [ -z "$1" ]; then
    echo "$0: called with no interface" 1>&2
    exit 1;
fi

# Fake ifupdown environment
export IFACE="$1"
export LOGICAL="$1"
export ADDRFAM="NetworkManager"
export METHOD="NetworkManager"
export VERBOSITY="0" 

# Run the right scripts
case "$2" in
    up)
        export MODE="start"
        export PHASE="up"
        exec run-parts /etc/network/if-up.d
        ;;
    down)
        export MODE="stop"
        export PHASE="down"
        exec run-parts /etc/network/if-down.d
        ;;
    pre-up)
        export MODE="start"
        export PHASE="pre-up"
        exec run-parts /etc/network/if-pre-up.d
        ;;
    post-down)
        export MODE="stop"
        export PHASE="post-down"
        exec run-parts /etc/network/if-post-down.d
        ;;
    *)
        echo "$0: called with unknown action \`$2'" 1>&2
        exit 1
        ;;
esac

Sembla doncs, que amb Netowrk manager els scripts de les carpetes /etc/network/if-x.d també s'executen

Comanda nm-tool

$ nm-tool
NetworkManager Tool

State: connected

- Device: eth1 ----------------------------------------------------------------
 NM Path:           /org/freedesktop/NetworkManager/Devices/eth1
 Type:              Wired
 Driver:            pcnet32
 Active:            yes
 HW Address:        08:00:27:09:1A:88

 Capabilities:
   Supported:       yes
   Carrier Detect:  yes
   Speed:           100 Mb/s

 Wired Settings
   Hardware Link:   yes

 IP Settings:
   IP Address:      192.168.1.6
   Subnet Mask:     255.255.255.0
   Broadcast:       192.168.1.255
   Gateway:         192.168.1.1
   Primary DNS:     192.168.1.3
   Secondary DNS:   192.168.1.1

nm-applet

És l'applet de network-manager i no s'ha de confondre amb l'applet de gnome (totes dues icones són molt similars però la de network-manager és una mica més gran i no parpadeja amb l'activitat de les interfícies). A Debian (Etch) les icones són clarament diferents.

L'applet network manager apareix a l'area de notificació del quadre de gnome

NMApplet.png

Si no us apreix potser és que no teniu instal·lat o que no teniu barra de notificació. La barra de notificació es pot afegir al quadre des de el menú contextual (botó dret/Afegeix al quadre).

Per comprovar si teniu el applet funcionant, poder executar:

$ ps aux | grep nm-applet
sergi     7191  0.0  1.2  69516 12440 ?        S    07:19   0:00 nm-applet --sm-disable
sergi    29212  0.0  0.0   2988   760 pts/2    R+   10:59   0:00 grep nm-applet

VPN

Network Manager té diversos plugins disponibles, executeu:

 $ sudo apt-get install network-manager             <-- tabuleu dos cops!
network-manager                    network-manager-openconnect-gnome  network-manager-pptp-gnome         network-manager-vpnc-gnome
network-manager-dev                network-manager-openvpn            network-manager-pptp-kde           network-manager-vpnc-kde
network-manager-gnome              network-manager-openvpn-gnome      network-manager-strongswan         
network-manager-kde                network-manager-openvpn-kde        network-manager-strongswan-kde     
network-manager-openconnect        network-manager-pptp               network-manager-vpnc  

Podeu consultar quins plugins teniu instal·lats amb:

$ dpkg -l | grep network-manager
ii  network-manager                       0.8.1+git.20100810t184654.ab580f4-0ubuntu2        network management framework daemon
ii  network-manager-gnome                 0.8.1+git.20100809t190028.290dc70-0ubuntu3        network management framework (GNOME frontend)
ii  network-manager-pptp                  0.8.1+git.20100810t192516.1e6db5a-0ubuntu1        network management framework (PPTP plugin)
ii  network-manager-pptp-gnome            0.8.1+git.20100810t192516.1e6db5a-0ubuntu1        network management framework (PPTP plugin, GNOME UI)


Vegeu que podeu realitzar connexions de diferents tipus:

Per exemple per instal·lar el plugin de openVPN:

$ sudo apt-get install network-manager-openvpn

Per no tenir que reiniciar la sessió podeu fer:

$ sudo service network-manager restart

ara si aneu a:

Menú Sistema > Preferències > Connexions de xarxa

A la pestanya VPN podeu crear un nou tipus (abans només teniu PPTP) de xarxa VPN: openVPN

Consulteu també VPN

Configurar una VPN amb PPTP

Cal comprovar que teniu el plugin instal·lat:

$ dpkg -l | grep pptp
ii  network-manager-pptp                  0.8.1+git.20100810t192516.1e6db5a-0ubuntu1        network management framework (PPTP plugin)
ii  network-manager-pptp-gnome            0.8.1+git.20100810t192516.1e6db5a-0ubuntu1        network management framework (PPTP plugin, GNOME UI)
ii  pptp-linux                            1.7.2-5                                           Point-to-Point Tunneling Protocol (PPTP) Client

si no l'instal·leu amb apt-get install.

Aneu a:

Menú Sistema > Preferències > Connexions de xarxa

Aneu a la pestanya VPN i creeu una nova connexió VPN, escolliu tipus PPTP. Només cal que poseu el servidor PPTP, l'usuari i la paraula de pas.

IMPORTANT: Per tal que funcioni Network-Manager, la interfície de xarxa que té connexió a la IP remota del PPTP server no ha d'estar configurada al fitxer /etc/network/interfaces, recordeu que les interfícies configurades en aquest fitxer són ignorades per network-manager

Un cop configurada la connexió us hi podeu connectar anant al applet de gestió de xarxa de network-manager (nm-applet), fer i clic i seleccionar la connexió VPN.

Monitor de la xarxa

NO s'ha de confondre l'applet de network manager amb l'applet de mointorització de la xarxa de gnome (gnome-netstatus-applet):

MonitorDeLaXarxa.png

Aquest applet es pot afegir als quadre, mitjançant botó dret/Afegeix al quadre:

MonitorDeLaXarxa1.png

Aquest applet et dona informació sobre les interfícies de xarxa que controla el fitxer /etc/network/interfaces.

Vegeu també


Enllaços externs