1st_noiz ([info]1st_noiz) wrote,
@ 2009-01-08 12:51:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
gentoo networkmanager
Ресурсы недоступны, взяты из кэша.
http://da.gentoo-wiki.com/HOWTO_NetworkManager





Это версия страницы http://da.gentoo-wiki.com/HOWTO_NetworkManager из кэша Google. Она представляет собой снимок страницы по состоянию на 10 окт 2008 23:54:12 GMT. Текущая страница за прошедшее время могла измениться. Подробнее


Эти поисковые термины были выделены: gentoo networkmanager howto  





































HOWTO NetworkManager



From Gentoo Linux Wiki



Jump to: navigation, search




This article is part of the HOWTO series.

Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Merge-arrows.gif
It has been suggested that this article be Merged into one article with Wireless/Managers.    (Discuss)

NetworkManager
is a networking addition aimed at simplifying connecting to computer
networks. Its goal is to allow Linux users to simplify connecting with
modern networking with less manual configuration, particularly wireless
networking. NetworkManager takes an opportunistic approach to network selection, attempting to use the best available connection.


Network Manager Logo

Contents






[edit] About NetworkManager


The NetworkManager service monitors the network interfaces and can connect various types of interfaces. NetworkManager may automatically switch to the best connection at any given time. If the network requires an encryption key, NetworkManager will prompt for one. NetworkManager supports most types of encrypted networks. Applications that include NetworkManager
support have the ability to automatically switch between on-line and
off-line modes when the system gains or loses network connectivity. NetworkManager also supports modem connections, and certain types of VPN.


[edit] Before installing NetworkManager


NetworkManager is desktop agnostic in that it runs on both Gnome and KDE and has an applet where it can be access from both.


[edit] Drivers Installed?


NetworkManager
requires Linux to have drivers for the wired and wireless cards on the
computer - some manufacturers of modems and wireless devices provide
limited support for Linux and newer devices can sometimes take awhile
to be developed. Research your card manufacturer and item number and
see if the driver is available in the kernel then check to see if the
driver is available separately in portage.


[edit] Installing NetworkManager


Installing and configuring NetworkManager.


[edit] Emerge and Add Runlevels


Network Manager is in the official Gentoo tree.

Emerge for Gnome:


emerge -av net-misc/networkmanager

  • If you want to use the nm-applet system tray tool the gnome USE flag is necessary.

Emerge for KDE:


emerge -av kde-misc/knetworkmanager

Add the Runlevels:


rc-update add NetworkManager default
rc-update add dhcdbd default


[edit] Hostname


NetworkManager reads the /etc/dhcp/dhclient.conf
to determine the hostname. If no value is assigned then an IP address
is set as a hostname which can cause problems opening new windows in
Gnome. To prevent this, add the following to /etc/dhcp/dhclient.conf:


File: /etc/dhcp/dhclient.conf


send host-name "YOUR_HOSTNAME";
supersede host-name "YOUR_HOSTNAME";



[edit] Baselayout Settings


Baselayout is Gentoo's system initialization system when Gentoo boots. If all goes well installing NetworkManager then disable any baselayout networking scripts.

Remove your current network devices from start up. If you don't,
you will have dueling dhcp clients fighting over your interfaces and
eating up CPU:


rc-update del net.eth0
rc-update del net.ath0
...

  • net.lo is needed for for a local loopback interface, leave this be.

If you are using udev,
you will also need to block it from attempting to automatically
initialize your network interfaces. This can be done by modifying the /etc/conf.d/rc file (or /etc/rc.conf on OpenRC). For example, to block eth0 from loading, add this:


File: /etc/conf.d/rc


RC_PLUG_SERVICES="!net.eth0"



The following line should block all Ethernet and wireless interfaces:


File: /etc/conf.d/rc


RC_PLUG_SERVICES="!net.eth* !net.wlan*"



[edit] Start NetworkManager


For the first run, restart the dbus and then start NetworkManager daemon. Restarting the dbus is not a good idea when the desktop is running. For Gnome, GDM will need to be stopped.


/etc/init.d/xdm stop 

Kill the desktop "ctrl-alt-backspace" first and restart the dbus in console.


/etc/init.d/dbus restart
/etc/init.d/NetworkManager start

Then start Gnome again and Network Manager applet will load in the notification area if everything is configured correctly.


  • If you get permission error from dbus, add yourself to the plugdev group!
  • If you are running Xfce, install nm-applet and
    xfce4-xfapplet. Then log out of Xfce. Delete the Xfce session file (in
    ~/.cache/sessions/). Log back into Xfce. You will see two computers in
    the Xfce panel. Use the icon for connecting to wireless networks. If
    you don't see it, reboot your computer and log back into Xfce.

[edit] Dependencies of Baselayouts Networking Script


Any dependencies of baselayouts networking script (ntp, samba...)
will require the use NetworkManagerDispatcher to start them. This is
needed since NetworkManager does not initialize the network till after the desktop is loaded. To start these scripts they will need to be identified to NetworkManager.


[edit] NetworkManagerDispatcher


NetworkManager offers a tool called NetworkManagerDispatcher, which executes files in /etc/Networkmanager/dispatcher.d
when changing the state of interfaces. Although, at the moment this
service isn't started we need to get this service started first. This
is done by an init-file:


File: /etc/init.d/NetworkManagerDispatcher


#!/sbin/runscript
#
# NetworkManagerDispatcher:   NetworkManagerDispatcher daemon
#
# chkconfig: 345 98 02
# description:  This is a daemon for automatically executing certain
#               actions, when switching networks
#
# processname: NetworkManagerDispatcher
# pidfile: /var/run/NetworkManagerDispatcher.pid

prefix=/usr
exec_prefix=/usr
sbindir=${exec_prefix}/sbin

NETWORKMANAGERDISPATCHER_BIN=${sbindir}/NetworkManagerDispatcher

# Sanity checks.
[ -x $NETWORKMANAGERDISPATCHER_BIN ] || exit 0

# so we can rearrange this easily
processname=$NETWORKMANAGERDISPATCHER_BIN
pidfile=/var/run/NetworkManagerDispatcher.pid

depend() {
        need NetworkManager
}

start()
{
        if [ -e ${pidfile} ]; then
                rm -f ${pidfile}
        fi
        ebegin "Starting NetworkManagerDispatcher"
        start-stop-daemon --start --quiet --exec ${processname}
        eend $?
        echo $(/bin/pidof NetworkManagerDispatcher) > ${pidfile}
}

stop()
{
        ebegin "Stopping NetworkManagerDispatcher"
        start-stop-daemon --stop --quiet --exec ${processname} --pidfile ${pidfile}
        eend $?
        if [ -e ${pidfile} ]; then
                rm -f $pidfile
        fi
}
 





chmod +x /etc/init.d/NetworkManagerDispatcher
rc-update add NetworkManagerDispatcher default
/etc/init.d/NetworkManagerDispatcher start

[edit] Dependent Scripts


Now follows the short but important script, which starts our dependent script when we're online for the first time. ntp-client is used and an example here:


File: /etc/NetworkManager/dispatcher.d/50-ntp-client


#!/bin/bash

/etc/init.d/ntp-client status | grep -q "started"

if test "$2" == "up" -a "$?" != "0" ; then
        rc-config start ntp-client
else
        rc-config stop ntp-client
fi
 



Make the script executable:


Code: Making it executable


chmod +x /etc/NetworkManager/dispatcher.d/50-ntp-client
rc-update add NetworkManagerDispatcher default



The above script for ntp should can be adapted for any baselayout network dependency. Anytime NetworkManager is initialized these scripts will be run.


[edit] Alternative: NetworkManagerDispatcher and a runlevel


Using a runlevel for the services to be managed by
NetworkManagerDispatcher makes adding, removing and showing the status
of the services easy. You will be able to use rc-update and rc-status
to manage these services; just like with any other runlevel.


Note: The runlevel in this example is network_services

Warning: Switching to this runlevel will cause other services to be stopped. Don't explicitly switch to this runlevel.

First, create a new runlevel.


mkdir /etc/runlevels/network_services

We also need a script for NetworkManagerDispatcher to properly
execute the service scripts in the runlevel. Create it and make it
executable.


File: /etc/NetworkManager/dispatcher.d/runlevel_wrapper.sh


#!/bin/sh
#
# Run the init.d scripts for services in our pseudo runlevel in ``${SERVICES_RUNLEVEL}''

source /etc/conf.d/NetworkManagerDispatcher

if [ -z "${SERVICES_RUNLEVEL}" ]; then
        echo "SERVICES_RUNLEVEL not set, cannot continue!"
        exit 1
fi

for name in $(find /etc/runlevels/${SERVICES_RUNLEVEL} -executable -type l); do
        $name status | grep -q "started"

        if test "$2" == "up" -a "$?" != "0"; then
                rc-config start $(basename $name)
        else
                rc-config stop $(basename $name)
        fi
done




chmod +x /etc/NetworkManager/dispatcher.d/runlevel_wrapper.sh

runlevel_wrapper.sh takes the variable
SERVICES_RUNLEVEL from /etc/conf.d/NetworkManagerDispatcher. We need to set this variable.


File: /etc/conf.d/NetworkManagerDispatcher


# This it the configuration file for NetworkManagerDispatcher.sh, the wrapper
# script for NetworkManagerDispatcher and the network service runlevel

SERVICES_RUNLEVEL="network_services"




Make sure to add any services that you want NetworkManagerDispacter to handle.


rc-update add ntp-client network_services

Note:
When adding, removing, or attempting to view the status of a service
for NetworkManagerDispatcher be sure you specify the network_services
runlevel. E.g. rc-status network_services

[edit] NM Applet


NM Applet
NM Applet

Network Manager includes an applet for both KDE and Gnome. It will allow the user to specify the network to connect to.


[edit] VPN


The networkmanager-vpn-plugins have made it to the official portage-tree.


emerge networkmanager-openvpn

[edit] Troubleshooting


Several Troubleshooting ideas.


[edit] Survive Suspend/Resume


Several methods may be able to help issues with suspend. NetworkManager includes built in support for suspend/resume and works very well, if NetworkManager
doesn't resume from suspend it is likely an issue with the driver.
Sometimes the network driver will not be unloaded and hence properly
reloaded.


[edit] Put the Driver in the Whitelist


Perhaps the simplest solution is adding the driver to the Whitelist:


  • Be sure you have HALD Device Manager

emerge -pv hal-device-manager

  • Identify the network module by starting System Tools > Device Manager.

  • Find your wireless/wired device and in the Advanced Tab look for "info.linux.driver" - mine was "ath_pci"

  • Edit the acpi-support file.

nano  /etc/default/acpi-support

  • Insert the driver/module into the WHITE_LIST ie.

MODULES_WHITELIST="ath_pci"

  • Is it necessary to restart??

[edit] A Script Loads the Driver


If the above method doesn't work, this may. The Linux power control
system - Advanced Configuration and Power Interface (ACPI) - can read
scripts before and after suspend. It uses two directories in /etc/acpi, create the directories if they doesn't exist yet.

nano /etc/acpi/suspend.d/07-networkmanager.sh


#!/bin/sh
rmmod some-driver

(Use your driver you found about above.)
And one for resume:

/etc/acpi/resume.d/63-networkmanager.sh


sleep 2
modprobe some-driver

and then make them executable:


sudo chmod +x /etc/acpi/suspend.d/07-networkmanager.sh
sudo chmod +x /etc/acpi/resume.d/63-networkmanager.sh

[edit] Failed emerge


If you get errors when emerging, like these:


/usr/include/linux/if.h:95: error: redefinition of `struct ifmap'
/usr/include/linux/if.h:131: error: redefinition of `struct ifreq'
usr/include/linux/if.h:181: error: redefinition of `struct ifconf'

This can be solved by updating to a newer version of linux-headers.


[edit] WPA won't work on my PowerPC based machine (e.g. iBook G4)


As of 12th November 07, this is a known bug: see https://bugs.launchpad.net/fedora/+source/network-manager/+bug/101857

Although it seems that it has been fixed upstream, this has not made it into the gentoo ebuild yet.


[edit] NetworkManager won't start


Error requesting name, org.freedesktop.DBus.Error.AccessDenied: Connection ":1.7" is not allowed to own the service "org.freedesktop.NetworkManagerInfo" due to security policies in the configuration file

Edit /etc/dbus-1/system.d/NetworkManager.conf or /etc/dbus-1/system.d/knetworkmanager.conf and add/modify either policies or user groups for your user to "own" the service.

You need something like this for knetworkmanager:


File: /etc/dbus-1/system.d/knetworkmanager.conf


<!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.NetworkManagerInfo"/>

                <allow send_destination="org.freedesktop.NetworkManagerInfo"/>
                <allow send_interface="org.freedesktop.NetworkManagerInfo"/>
        </policy>
        <policy group="plugdev">
                <allow own="org.freedesktop.NetworkManagerInfo"/>

                <allow send_destination="org.freedesktop.NetworkManagerInfo"/>
                <allow send_interface="org.freedesktop.NetworkManagerInfo"/>
        </policy>
        <policy context="default">
                <deny own="org.freedesktop.NetworkManagerInfo"/>

                <deny send_destination="org.freedesktop.NetworkManagerInfo"/>
                <deny send_interface="org.freedesktop.NetworkManagerInfo"/>
        </policy>
</busconfig>



make sure your user is in the plugdev group!


[edit] /etc/resolv.conf empty


If you have a static configuration for your network (no DHCP) and your /etc/resolv.conf stays empty (except for the NetworkManager comments) then you have to change the format of dns_servers in /etc/conf.d/net to use single quotes only. e.g.:


File: /etc/conf.d/net


dns_servers_eth0="192.168.3.1 215.170.93.234 210.145.254.170"



[edit] Links


  • Homepage

NetworkManager

  • An Article on Network Manager

Introducing NetworkManager

  • A Gentoo forum topic on Network Manager:

NetworkManager, netapplet, and ipw2200


















Powered by MediaWiki















Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…