Ppp

Aus Gentoo Linux Wiki

Wechseln zu: Navigation, Suche

Inhaltsverzeichnis

[Bearbeiten] Beschreibung

ppp dient zum einrichten einer Punkt-zu-Punkt-Einwahlverbindung. Das soll bedeuten, mittels ppp kann eine beliebige Wählverbindung zu einem anderen PC hergestellt werden.

Die meisten Benutzer verwenden ppp um sich ins Internet zu verbinden.

ppp ist die Basis für alle ppp-Programme: rp-pppoe, pppoed, usw...

Gentoo selbst kann mit ppp alleine dank des Baselayouts bereits eine Wählverbindung direkt einrichten und benötigt eigentlich keine weiteren Programme mehr.

<pppd mit >=Kernel 2.6.14, >=Baselayout-1.12.0 und >=ppp-2.4.3-r10

Generell erst einmal folgende Aussage: Gentoo ist ein modernes Linux, das extrem einfach auf neueste Versionen aktualisiert werden kann. Es wird deshalb hier nur der ppp ab dem Baselayout 1.12.0 beschrieben, die anderen Versionen existieren sowieso nicht mehr.

Ab Baselayout 1.12.0 wurde die Konfiguration vom ppp nach /etc/conf.d/net gelegt, die alten pppd-funktionen sind "obsolete".

Leider ist das example /etc/conf.d/net.example mit der Beschreibung von ppp etwas undeutlich, so funktioniert es:

[Bearbeiten] Installieren von ppp

unter Gentoo wird ppp wie üblich installiert mit:

emerge net-dialup/ppp

Es wird dringend geraten ppp mit dem USE-Flag "pam" zu kompilieren:

echo "net-dialup/ppp pam" >> /etc/portage/package.use

[Bearbeiten] Einrichten der Kernel-Optionen für PPP

Der Kernel muss die Option ppp bereitstellen, hier die Einträge für Gentoo-Sources, um sich einer Telefon-DSL-Leitung einzuwählen

Code: Gentoo-Sources-2.6.14-r4
Device Drivers ---->
   Network-Device-Support ---->
      <M>   PPP (point-to-point protocol) support
      [ ]     PPP multilink support (EXPERIMENTAL)
      [ ]     PPP filtering
      <M>     PPP support for async serial ports #erforderlich für ADSL
      < >     PPP support for sync tty ports     #erforderlich für SDSL, ISDN, ANALOG, WLAN
      <M>     PPP Deflate compression            #wird bei Telekom & Arcor unterstützt
      <M>     PPP BSD-Compress compression       #funktioniert hervorgand bei Kabelmodem
      <M>     PPP over Ethernet (EXPERIMENTAL)   #simuliert eine Netzwerkschnittstelle


bei einer klassischen Modemverbindung wird natürlich auch sync ppp benötigt.

Der Vorgang des Kernel-Kompilieren wird hier beschrieben.

[Bearbeiten] Einrichten von pppd für DSL

Für die Einrichtung einer DSL-Verbindung gibt es mindestens 3 Möglichkeiten:

  1. die scripte "pppoe-setup", "pppoe-start", "pppoe-connect", "pppoe-status", "pppoe-stop" (benötigt das Paket rp-pppoe)
  2. aus obigem und einem rp-pppoe-init-script wird daraus noch ein startfähiger Dienst (s. rp-pppoe Startscript)
  3. pppd im Kernel-Mode (das Paket rp-pppoe wird NICHT zusätzlich benötigt)

[Bearbeiten] rp-pppoe

Die beiden ersten Varianten werden sehr oft beschrieben, sind auch recht schnell nutzbar, aber zeigten bei mir mehrere Nachteile:

  1. es werden Dateien für die firewall basierend auf ipchains installiert (aktuell ist iptables)
  2. es wird eine zusätzliche Konfigurationsdatei installiert, welche der vorhandenen (in /etc/conf.d/net.ppp0) teilweise gleicht, aber sich auch unterscheidet, dies verwirrt den Linux-Konfigurierer schnell ;o)
  3. es wird ein Verzeichniss angelegt, welches man nicht benötigt (/etc/ppp/plugins mit Link)
  4. beim Verbinden und Trennen der Verbindung kommt es häufig zum "Hängen"
  5. ein Wiederverbinden nach Trennen ist unzuverlässig
  6. obiges führt bei Nutzung des Start-Stop-Scripts zu nervend langen Bootvorgängen
  7. die Verschachtelungstiefe ist hoch, was eine Fehlersuche erschwert (Startscript->adsl-start->(pppoe.conf,pap-secrets)->pppd->rp-pppoe)
  8. der debug-Modus lief bei mir nicht sauber

Die rp-pppoe-Variante ist sehr gut für die Zeit des System-Aufbaus geeignet (Gentoo neu aufsetzen), aber ich kann sie nicht für den Alltagsbetrieb empfehlen.

[Bearbeiten] pppd im Kernel-Mode

Für den Zugang muss man selbst dafür sorgen, dass Nutzername und Passwort bekannt sind:

nano -w /etc/ppp/pap-secrets

Datei: /etc/ppp/pap-secrets
"User@online.de" * "UserPassword"


Für die einmalige Initialisierung einer DSL-Verbindung reichen dann 2 Befehlszeilen im Terminal (nichts anderes produzieren die scripte). Die Eintragungen für ppp0 und eth1 sind nach Bedarf anzupassen. Es ist darauf zu achten, dass die Datei "options" nicht vorhanden oder leer ist. Die Option "debug" und "kdebug 1" kann hinzugefügt werden.

Code: Befehle zum DSL verbinden
ifconfig eth1 up mtu 1500
/usr/sbin/pppd plugin rp-pppoe.so persist holdoff 60 defaultroute mru 1492 mtu 1492 user "User@online.de" \
eth1 linkname ppp0 hide-password


Zum Stoppen der Verbindung reicht (die Init-Scripte machen das etwas eleganter über die PID):

killall pppd


So nun die DSL-optimierte Version des net.ppp0 scripts

Zunächst muss aber die Konfiguration angepasst werden:

(Entschuldigung für die vielen Zeilen, aber die Datei ist im Original wirklich viel zu spärlich kommentiert. Vielleicht gibt es irgendwie eine Möglichkeit eines Uploads, aber ich kenne mich noch zu wenig mit dem Wiki aus.)

nano -w /etc/conf.d/net.ppp0

Datei: /etc/conf.d/net.ppp0
# /etc/conf.d/net.ppp0:
#----added for description ------- begin -----
#060315 by Gentoo-Thomas
#using this file for configuration the commandline of pppd
#I suggest set AUTOCFGFILES to "no"
#I suggest don't set PASSWORD
#please make configuration by hand in "pap-secrets", it's more secure
#feel free to make a clean script for helping to configurations by
#setting the files automaticaly (a hint can give you adsl-setup)
#----added for description ------- end -------
# $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/confd.ppp0,v 1.3 2005/02/06 09:22:13 mrness Exp $
# Config file for /etc/init.d/net.ppp0
#################################################################
# switch for kernel-mode
# force to insert "plugin rp-pppoe.so"
#################################################################
KERNELMODE="yes"

 #################################################################
 # (ipparam), (call), (remotename)
 # Define peer, aka ISP
 # there must be a file with that name in directory /etc/ppp/peers/
 # not neccessary for DSL in my case
 #################################################################
 #PEER="MyPeer"

 #################################################################
 # used in script and (debug)
 # you can also set PPPOPTIONS="kdebug 1" below for kernel-mode
 # the connections will belogged into /var/log/messages
 # Turn on debugging yes/no
 #################################################################
 DEBUG="yes"

 #################################################################
 # (user)
 # The PAP/CHAP username
 #################################################################
 USERNAME="User@online.de"

 #################################################################
 # Your password/secret
 # please don't use it
 # must set if AUTOCFGFILES="yes"
 #################################################################
 #PASSWORD="pwd"

 #################################################################
 # (persist)
 # "yes" force re-dial after a connection was terminated
 # otherwise exit once a connection has been made and terminated
 # should be "yes" if "ONDEMAND" is "yes"
 #################################################################
 PERSIST="yes"

 #################################################################
 # (demand)
 # Only bring the interface up on demand? no/yes
 # set idle-time and holdoff is usefull
 #################################################################
 ONDEMAND="no"

 #################################################################
 # (idle)
 # after that period of "no data packets"
 # the connection will be disconnect
 # used when ONDEMAND="yes" (600)
 #################################################################
 IDLETIMEOUT="600"

 #################################################################
 # (holdoff)
 # Retry timeout when ONDEMAND="yes" or PERSIST="yes" (60)
 #################################################################
 RETRYTIMEOUT="60" 

 #################################################################
 # TTY device modem is connected to?
 # at the moment also the holder of interface-name for kernel-mode
 # set it to "/dev/ttyS1" or "eth1"
 #################################################################
 MODEMPORT="eth2"

 #################################################################
 # Must pppd set the default route? yes/no
 # if empty the default=yes is used
 #################################################################
 DEFROUTE="yes"

 #################################################################
 # Extra options for pppd
 # you can set to "ktune" (but also forced from DEMAND="yes")
 # that enables  pppd  to  alter  kernel settings as appropriate.
 #################################################################
 PPPOPTIONS=""

 #################################################################
 # The ip of the remote box for static IP's
 # (mostly dynamic -> leave blank)
 #################################################################
 REMIP=""

 #################################################################
 # Our IP if we have a static one
 # (mostly dynamic -> leave blank)
 #################################################################
 IPADDR=""

 #################################################################
 # Netmask
 # is used in init-script, but no word at man pppd?
 #################################################################
 #NETMASK=""

 #################################################################
 # Sets the MRU
 #  768 for analog modem
 # 1492 for DSL
 #################################################################
 MRU="1492"

 #################################################################
 # Sets the MTU
 # mostly the same as MRU
 #################################################################
 MTU="1492"

 #################################################################
 # Should pppd set the peer dns?
 # yes will store the DNS adresses of Peer (remote-box)
 # in /etc/ppp/resolv.conf
 # thats confusing, there is also the /etc/resolv.conf
 # but if you don't know which values to use in your case
 # take this option and switch to yes
 #################################################################
 PEERDNS="no"

 #################################################################
 # !!!!!!!! next lines only for analog-modems !!!!!!!!!!!
 ################################################################# 

 #################################################################
 # Speed pppd should try to connect at
 #################################################################
 #LINESPEED="115200"

 #################################################################
 # Extra init string for the modem
 #################################################################
 #INITSTRING=""

 #################################################################
 # Use hardware flow control? yes/no
 # RTS-CTS
 #################################################################
 #HARDFLOWCTL="yes"

 #################################################################
 # Use escape caracters ?
 #################################################################
 #ESCAPECHARS="yes" 

 #################################################################
 # The telephone number of your ISP
 # leave blank for leased-line operation.
 #################################################################
 #NUMBER="9180000"

 ################################################################# 
 # The init-script can generate the files:
 # /etc/ppp/chat-isp, /etc/ppp/chap-secrets,
 # /etc/ppp/pap-secrets and /etc/ppp/peers/isp
 # automatically if you set this to "yes"
 # otherwise you will have to create these files by hand
 # for DSL I only need the pap-secrets
 #################################################################
 AUTOCFGFILES="no"

 #################################################################
 # The init-script can generate the
 # /etc/ppp/chat-${PEER} automatically if set to "yes"
 # Otherwise you will have to create these files by hand
 # for DSL I don't need the files
 #################################################################
 AUTOCHATSCRIPT="no"

 #################################################################
 # Directory where the templates is stored
 #################################################################
 TEMPLATEDIR=/etc/ppp


Und nachfolgend das modifizierte Script (wesentliche Änderungem sind mit Kommentar markiert):

(Vielleicht kann jemand, der sich mehr auskennt, aus diesem und dem Original einen patch machen und dessen Anwendung dann hier näher erläutern)

nano -w /etc/init.d/net.ppp0

Datei: /etc/init.d/net.ppp0
 #!/sbin/runscript
 #added for discription ----begin ----
 # this script was modified to bring up a dsl connection
 # via ppd only in kernel mode
 # in the future there should be made modifications for compatibility
 # analog modem <--> dsl modem
 # configuration have to be done in /etc/conf.d/net.ppp0
 #added for discription ----end ------
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/net-dialup/ppp/files/net.ppp0,v 1.9 2005/04/16 10:10:42 mrness Exp $

 # Misc internal variables
 CMD_LINE=""
 FUNCT="$2"
 TEMPLATEDIR="/etc/ppp"

 checkconfig() {

        if [ -e "/var/run/ppp-${IFACE}.pid" -o -e "/var/run/${IFACE}.pid" ] && \
           [ "${FUNCT}" = "start" ]
        then
                eerror "${IFACE} is already up"
                return 1
        fi
 }

 start() {

        checkconfig || return 1

        setup_modules
        setup_cmd_line
        setup_cfg_files

        #---------- manual added for uncomlicated startup ---begin-----
        ifconfig ${MODEMPORT} up mtu 1500
        #---------- manual added for uncomlicated startup ---end-------

        #---------- manual added for debugging ---begin-----
        # Added hide-password here, can't be too sure...
        PPDCOMMAND="/usr/sbin/pppd ${CMD_LINE} ${MODEMPORT} ${LINESPEED} \
                    linkname ${IFACE} noauth ${PPPOPTIONS} hide-password"

        if [ "${DEBUG}" = "yes" ]
        then
                ebegin "complete command for ppd: $PPDCOMMAND"
        fi
        #---------- manual added for debugging ---end------

        ebegin "Bringing ${IFACE} up"
        if [ -x "$(which pppd)" ]
        then

                if [ "${DEFROUTE}" = "yes" ]
                then
                        [ -n "$(/sbin/route -n | egrep '^0.0.0.0')" ] && route del default
                fi

                #manual modified for debugging
                #next line will start ppd
                $PPDCOMMAND
        fi
        eend
 }

 stop() {

        checkconfig || return 1

        ebegin "Bringing ${IFACE} down"
        if [ -x "$(which ifconfig)" ]
        then

                # Obtain interface name from pid file (IFACE is actually linkname)
                if [ -e /var/run/ppp-${IFACE}.pid ]
                then
                        IFNAME=$(egrep "ppp" /var/run/ppp-${IFACE}.pid)
                fi
                if [ -z "${IFNAME}" ]
                then
                        IFNAME=${IFACE}
                fi

                if [ -z "$(/sbin/ifconfig | egrep "${IFNAME}")" ]
                then
                        # Link is not up but pppd may be running
                        ewarn "Interface seems to be down already"
                fi

                if [ -e /var/run/ppp-${IFACE}.pid ]
                then
                        PID=$(egrep -v "${IFNAME}" /var/run/ppp-${IFACE}.pid)
                elif [ -e /var/run/${IFACE}.pid ]
                then
                        PID=$(egrep -v "${IFNAME}" /var/run/${IFACE}.pid)
                fi

                if [ -n "${PID}" ]
                then
                        kill ${PID}
                                              sleep 1

                        # Try to kill pppd repeatedly (sometimes, (e.g. if connection
                        # is not established) pppd ignores SIGTERM for a while)
                        PID_TMP=`pstree -p ${PID}`
                        PID_TMP=`echo ${PID_TMP} | sed -e 's:^.*pppd(\|).*::g'`
                        COUNT=0
                        while [ -n "${PID_TMP}" ] && [ ${COUNT} -lt 10 ]
                        do
                                kill ${PID}
                                sleep 1
                                PID_TMP=`pstree -p ${PID}`
                                PID_TMP=`echo ${PID_TMP} | sed -e 's:^.*pppd(\|).*::g'`
                                let COUNT++
                        done
                fi

                if [ -n "${PID_TMP}" ]
                then
                        eend 1 "Error stopping pppd"
                #---------- manual added for clear shutdown ---begin-----
                else
                        ifconfig ${MODEMPORT} down
                #---------- manual added for clear shutdown ---end-------

                fi

        fi
        eend
 }
 setup_cmd_line() {

        CMD_LINE="lock"
        #---------- manual added for kernel-mode ---begin-----
        if [ "${KERNELMODE}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} plugin rp-pppoe.so"
        fi
        #---------- manual added for kernel-mode ---end-----
        if [ "${DEBUG}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} debug"
        fi

        if [ "${PERSIST}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} persist holdoff ${RETRYTIMEOUT}"
        fi

        if [ "${DEFROUTE}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} defaultroute"
        fi

        if [ "${HARDFLOWCTL}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} modem crtscts"
        fi

        if [ "${ESCAPECHARS}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} asyncmap 00000000"
        fi

        if [ "${PEERDNS}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} usepeerdns"
        fi

        if [ -n "${IPADDR}${REMIP}" ]
        then
                CMD_LINE="${CMD_LINE} ${IPADDR}:${REMIP}"
        fi

        if [ -n "${NETMASK}" ]
        then
                CMD_LINE="${CMD_LINE} netmask ${NETMASK}"
        fi

        if [ -n "${MRU}" ]
        then
                CMD_LINE="${CMD_LINE} mru ${MRU}"
        fi
        
        if [ -n "${MTU}" ]
        then
                CMD_LINE="${CMD_LINE} mtu ${MTU}"
        fi

        if [ -n "${USERNAME}" ]
        then
                CMD_LINE="${CMD_LINE} user ${USERNAME}"
        fi

        if [ "${ONDEMAND}" = "yes" ]
        then
                CMD_LINE="${CMD_LINE} demand ktune idle ${IDLETIMEOUT}"
                CMD_LINE="${CMD_LINE} holdoff ${RETRYTIMEOUT}"
        fi
        #---------- different changes also affected lines before ---begin-----
        # there was a problem without this changes, PEER now not neccessary
        if [ -n "${PEER}" ]
        then
                CMD_LINE="${CMD_LINE} ipparam ${PEER} remotename ${PEER} call ${PEER}"
        fi
        #---------- different changes also affected lines before ---end-----
 }
 setup_cfg_files() {

        if [ "${AUTOCFGFILES}" = "yes" ]
        then
                if [ -n "${NUMBER}" ]
                then
                        # Setup the peers file
                        echo "connect '/usr/sbin/chat -f /etc/ppp/chat-${PEER}'" \
                                >/etc/ppp/peers/${PEER}
                fi

                # Setup the secrets files
                echo "\"${USERNAME}\" * \"${PASSWORD}\"" >/etc/ppp/chap-secrets
                chmod 600 /etc/ppp/chap-secrets
                echo "\"${USERNAME}\" ${PEER} \"${PASSWORD}\"" >/etc/ppp/pap-secrets
                chmod 600 /etc/ppp/pap-secrets

                # Setup the chat file
                if [ "${AUTOCHATSCRIPT}" = "yes" ]
                then
                        if [ -n "${INITSTRING}" ]
                        then
                                if [ -n "${NUMBER}" ]; then
                                        sed -e "12i\\'OK\' \'${INITSTRING}\'" \
                                                -e "s:\$NUMBER:${NUMBER}:" \
                                                ${TEMPLATEDIR}/chat-default \
                                                >/etc/ppp/chat-${PEER}
                                else
                                        sed -e "12i\\'OK\' \'${INITSTRING}\'" \
                                                ${TEMPLATEDIR}/chat-default \
                                                >/etc/ppp/chat-${PEER}
                                fi
                        else
                                if [ -n "${NUMBER}" ]; then
                                        sed -e "s:\$NUMBER:${NUMBER}:" \
                                                ${TEMPLATEDIR}/chat-default \
                                                >/etc/ppp/chat-${PEER}
                                fi
                        fi
                fi
        fi
 }

 setup_modules() {
        if [ ! -c /dev/ppp ]; then
                modprobe /dev/ppp
        fi
 }
 


[Bearbeiten] Einrichten von pppd für ISDN mit CAPI

[Bearbeiten] Fehlersuche

Wenn du beim Einwählen mit pppd call isdn/meinprovider folgende Fehlermeldung bekommst,

pppd: /usr/lib/pppd/2.4.2/userpass.so: cannot open shared object file: No such file or directory
pppd: Couldn't load plugin userpass.so

dann über prüfe, ob du das Paket capi4k-utils mit pppd Unterstützung kompiliert hast:

hostname ~ # emerge -vp capi4k-utils

These are the packages that I would merge, in order:

Calculating dependencies .. done!
[ebuild   R   ] net-dialup/capi4k-utils-''Versionsnummer'' +fax -pcmcia +pppd +tcpd -usb

Total size of of downloads: 0 kB

Wenn du als USE Flag nicht +pppd stehen hast, sondern -pppd oder +pppd*, überprüfe, ob pppd (nicht -pppd) in den USE Flages in /etc/make.conf vorkommt und installiere das Paket durch emerge -va capi4k-utils neu.

[Bearbeiten] Einrichten von pppd für ISDN ohne CAPI

[Bearbeiten] Einrichten von pppd für analoges Modem

Man entscheide sich für ein noch nicht verwendetes pppX, in Folgenden ppp2. Das Modem ist am ersten seriellen Port angeschlossen, also /dev/ttyS0.

Nun mittels einem Link das zukünftige Start-Skrit erstellen:

ln -s /etc/init.d/net.lo /etc/init.d/net.ppp2

in der Datei /etc/conf.d/net folgendes eintragen (USERNAME, PASSWORT und TELEFONNUMMER sind Platzhalter):

config_ppp2=("ppp")
link_ppp2="/dev/ttyS0"
username_ppp2='USERNAME'
password_ppp2='PASSWORT'
pppd_ppp2=("ktune" "noauth" "defaultroute" "usepeerdns" "115200")
phone_number_ppp2=("TELEFONNUMMER")
chat_ppp2=(
       'ABORT' 'BUSY'
       'ABORT' 'ERROR'
       'ABORT' 'NO ANSWER'
       'ABORT' 'NO CARRIER'
       'ABORT' 'NO DIALTONE'
       'ABORT' 'Invalid Login'
       'ABORT' 'Login incorrect'
       '' 'ATZ'
       'OK' 'ATM0'
       'OK' 'ATDTTELEFONNUMMER'
       'CONNECT' ''
       'TIMEOUT' '5'
       '~--' 
)

Online gehen:

/etc/init.d/net.ppp2 start

[Bearbeiten] Weitere Infos und Fehlersuche

Wurden die Netzgeräte physisch erkannt (Karten, OnBoard, USB), d.h. gibt es bereits einen Treiber:

lspci
dmesg|grep eth
lsmod
cat /proc/interrupt

Hat ppp2 eine IP bekommen? Folgender Befehl gibt Auskunft:

ifconfig 

Die default-Route sollte automatisch gesetzt werden. Die default-Route anzeigen lassen:

route

Der DNS-Server, also der Eintrag in der /etc/resolv.conf (IP ist ein Platzhalter):

nameserver IP

sollte automatisch erfolgen. Testen, ob man online ist:

ping www.gentoo.org

Genau wie oben können weitere pppX erstellt werden.

Tipps zur Fehleranalyse:

Wurde die default-route bereits vorher von einem anderen Netz-Skript (z. B. /etc/init.d/net.eth0 oder /etc/init.d/net.ppp1) gesetzt? Dann wird sie möglicherweise nicht automatisch vom /etc/init.d/net.ppp2-Skript verändert. Man kann die Route auch per Hand setzen (IP ist ein Platzhalter):

route add default gw IP

oder löschen:

route del default gw    (?!)

Um die Netz-Sktripte als User ausführen zu können:

emerge app-admin/sudo

In der Datei /etc/sudoers folgendes ergänzen (rechnername, username1 und username2 sind Platzhalter):

Host_Alias      RECHNER = rechnername
User_Alias      NETZGRUPPE = username1, username2
Cmnd_Alias      NETZCOMMAND = /etc/init.d/net.ppp*
NETZGRUPPE      RECHNER = NOPASSWD: NETZCOMMAND

Nun kann man als username1 und username2 z. B. "/etc/init.d/net.ppp2 start" ausführen.

[Bearbeiten] Einrichten von pppd für WLAN

Dieser Artikel ist ein Kurz-Artikel - Du kannst uns helfen, diesen zu erweitern. Klicke dazu auf bearbeiten.



[Bearbeiten] Links

'Persönliche Werkzeuge