+---------------------------------------------+ ! ! ! modem USR Sportster Faxmodem 33.6 ! ! ! ! et acces a un provider internet en PPP ! ! ! ! ---un exemple de configuration--- ! ! ! ! ! ! version du : 01 jan 1998 ! ! révisé le : 06 mai 1998 ! ! ! ! Denis BRAUSSEN ! ! Denis BRAUSSEN ! ! ! +---------------------------------------------+ 0) CopyLeft : cette doc est pour tous, peut être utilisée, copiée, ------------ modifiés ou même dirigée vers /dev/null, qu'importe. Je n'ai fait que de m'inspirer d'exemples créés par d'autres personnes (que je remercie en passant). Toute ressemblance avec des scripts existants ne serait donc pas fortuite ! :-) j'espère juste qu'elle pourra vous être utile. 1) A qui s'adresse cette mini-doc ? ----------------------------------- 1.1) A tous ceux qui posent cette question : ------------------------------------------------------------------------ > Hello ! > > J'ai un problème ! > Je n'arrive pas à configurer mon modem USR Sporster 33.6 sous linux. > Est-ce que quelqu'un pourrait me donner la marche à suivre ? > > Merci. ----------------------------------------------------------------------- 1.2) A tous ceux qui posent la même question même s'ils n'utilisent pas un modem USR sporster. Il faudra cependant modifier les chaines d'initialisation du modem en conséquence. Se référer à la doc livrée avec le modem. 2) de quoi parle ce texte ? --------------------------- - configuration du port serie (/etc/rc.serial) - du script de connexion (/usr/local/sbin/ppp-hol) et de son script associé (/etc/ppp-on-dialer) - du script de deconnexion (/usr/local/sbin/ppp-off) 3) ma config ------------ - Linux : slackware 3.2 (kernel 2.0.30) en glibc5 - Modem : USR Sporster Faxmodem 33.6 - CPU : intel 486 DX4-100 - RAM : 32 Mo - chip : 16550A (port série) 4) /etc/rc.serial ----------------- infos: (1) man setserial (2) man stty but: (1) configurer le port série (vitesse, IRQ, chipset, ...) (2) mise en place du protocole RTS/CTS (Request To send/Clear to send) exécution: ce fichier est exécuté au boot. il est en général lancé par /etc/rc.S mise en garde : sur certaines machines le système peut se bloquer si les parametres de /etc/rc.serial sont erronés !! --> attention donc et prévoir une disquette boot de secours, au cas où... (mais personellement je n'ai jamais eu de problèmes) #!/bin/sh # ------------------------------------------------------------- # # /etc/rc.serial # Initializes the serial ports on your system # # Denis BRAUSSEN 01-01-1998. # autres infos : voir intmodem.txt dans doc.fr de la slackware # echo "entering /etc/rc.serial" #mise en place controle de flux par RTS CTS stty crtscts < /dev/ttyS0 # configuration pour un port serie rapide # --------------------------------------- # # ----------> sur mon PC, une vitesse supérieure # a 'spd_hi' (man setserial) provoque # des deconnexions intempestives... # setserial /dev/ttyS0 spd_hi echo "/etc/rc.serial is done." # affiche configuration # --------------------- # # c'est à dire --> /dev/ttyS0 at 0x03f8 (irq = 4) is a 16550A (spd_hi) # setserial -bg /dev/ttyS0 #------------------------------------------------- 5) le script de connexion (/usr/local/sbin/ppp-hol) -------------------------------------------------------- voila le mon 'ppp-hol' (je suis abonne chez hol :) ) qui demarre la connection. Ce script defini également les varuiables qui seront utilisées par /etc/ppp-on-dialer . #!/bin/sh #------------------------------------------------------------------- # # name: /usr/local/sbin/ppp-hol # # +------------------------------------------------------------+ # | CONNECTION A INTERNET en PPP avec IP dynamique chez HOL.FR | # +------------------------------------------------------------+ # # updated: 06 mai 1998 # ******* Denis BRAUSSEN # # ATTENTION: ce script doit etre lance sous root ou 'setuid' root # # # # Le script attend le modem sous /dev/ttyS0 (com1 sous dos) # a 38400 bauds. #------------------------------------------------------------------ # Script to initiate a ppp connection. This is the first part of the # pair of scripts. This is not a secure pair of scripts as the codes # are visible with the 'ps' command. However, it is simple. # # These are the parameters. Change as needed. #------------------------------------------------------------------ # new: Denis BRAUSSEN (MODEM_OPTION) see also /usr/local/sbin/ppp-off # and /etc/ppp/ppp-on-dialer #------------------------------------------------------------------ # # code modem signification #-------------+------------------------------------------------------------ # &H1 controle flux materiel ON # S40=7 blackList off (modem USRobotic Sportster) # &N16 33600 bps ATTENTION: si connection defaillante, mettre &N15 # &B1 vitesse fixe # M2 haut parleur ON # &G0 tonalite OFF # &K3 compression MNP5 desactivee # ATZ init modem # ------------------------------------------------------------------------ # # RAPPORTS : j'ai ajouté pour le plaisir quelques fichiers 'trace' ;-)) # -------- ainsi que le calcul du coût de la connexion (je n'ai cependant # pas inclus cette partie au présent texte. se référer # à la solution proposée sur # # # (pour ma part n'ai pas utilisé cette solution mais un simple # script bash qui fabique un fichier 'include' qui sera ensuite # utilisé par un module de calcul qui utilise # la commande 'bc' du projet GNU (man bc) # --> "bc - An arbitrary precision calculator language" # # # ----> /var/log/internet/chatlog (rapport) # ----> /var/lock/internet/chatlog.lock (verrou) # ----> calcul du cout de la connexion (non inclus à ce document) # --------------------- # voir dans /root/.scripts/calcul_prix # et dans /root/.scripts/prix_connection # ------------------------------------------------------------------ # # # -------======<<<<<<<<<*>>>>>>>>>>>======------ # # # ------------------------------------------------------------------- # verification : si chatlog.lock existe, alors le script bye (lien # sur ppp-off) n'a pas ete execute --> abort. # ------------------------------------------------------------------- if [ -e /var/lock/internet/chatlog.lock ]; then echo "-ERROR-----------------------------------------------------------------" echo "/user/local/sbin/ppp-hol script (internet) ACTIF. --USE FIRST bye--" echo "-----------------------------------------------------------------------" exit 1 fi # ----------------------------------------------------------- # creation verrou chatlog.lock # ----------------------------------------------------------- #echo "ppp-hol actif" | cat > /var/lock/internet/chatlog.lock # # correction de Nat Makarevitch : # echo "ppp-hol actif" > /var/lock/internet/chatlog.lock # ------------------------------------------------------ # options pour le modem (voir plus haut) # et definition des variables pour etc/ppp/ppp-on-dialer # ------------------------------------------------------ MODEM_OPTIONS="&N15S40=7M2&B1&G0&H1&K3" TELEPHONE=0387508180 # METZ (Moselle) --------> N° provider hol.fr ACCOUNT=******** # numero de compte (login) ---> a mettre en clair ! PASSWORD=******** # mot de passe --------> a mettre en clair ! LOCAL_IP=0.0.0.0 # adresse IP dynamique REMOTE_IP=0.0.0.0 # adresse IP attribue par le serveur NETMASK=255.255.255.0 # masque par defaut # # --- on exporte ces variables pour qu'elles soient visibles par # 'ppp-on-dialer' --- export TELEPHONE ACCOUNT PASSWORD MODEM_OPTIONS # --- This is the location of the script which dials the phone and logs # Please use the absolute file name as the $PATH variable is not # used on the connect option. (To do so on a 'root' account would be # a security hole so don't ask.)--- DIALER_SCRIPT=/etc/ppp/ppp-on-dialer # ------------------------------------------------------------------ # Initiate the connection (il s'agit d'une seule ligne de commande) # ======================= # # cette partie va appeler le daemon (Disk And External monitor) # 'pppd' avec toutes les options necessaires. le script # '/etc/ppp/ppp-on-dialer' sera utilise et la connexion etablie # # infos: man pppd # notes: possibilite d'ecrire un script # /etc/ppp/ip-up et /etc/ppp/ip-down pour effectuer # certaines taches (lancer par exemple la recuperation # des news ou du courrier, ... etc...) (man pppd) # # # I put most of the common options on this command. Please, don't # forget the 'lock' option or some programs such as mgetty will not # work. The asyncmap and escape will permit the PPP link to work with # a telnet or rlogin connection. You are welcome to make any changes # as desired. Don't use the 'defaultroute' option if you currently # have a default route to an ethernet gateway. # ------------------------------------------------------------------ exec /usr/sbin/pppd lock modem crtscts /dev/ttyS0 38400 \ kdebug 0 $LOCAL_IP:$REMOTE_IP \ noipdefault netmask $NETMASK defaultroute connect $DIALER_SCRIPT #-------------------------------------- 6) le fichier /etc/ppp-on-dialer --------------------------------- #!/bin/sh # ---------------------------------------------------------------- # # name: /etc/ppp-on-dialer # # updated: 06 mai 1998 # ******** Denis BRAUSSEN # # # ATTENTION: ce script doit etre lance sous root ou 'setuid' root # # This is part 2 of the ppp-on script. It will perform the connection # protocol for the desired connection. # #------------------------------------------------------------------ # new: - Denis BRAUSSEN (MODEM_OPTION) voir /usr/local/sbin/ppp-hol # le script cree aussi le rapport /var/log/internet/chatlog # ------------------------------------------------------------------ # ##### echo "DEBUG !! /etc/ppp/ppp-on-dialer" # exec /usr/sbin/chat -r /var/log/internet/chatlog -V \ TIMEOUT 3 \ ABORT '\nBUSY\r' \ ABORT '\nNO ANSWER\r' \ ABORT '\nRINGING\r\n\r\nRINGING\r' \ REPORT 'CONNECT' \ '' \rAT \ 'OK-+++\c-OK' ATH0 \ TIMEOUT 30 \ OK ATZ \ OK AT$MODEM_OPTIONS \ OK ATDT$TELEPHONE \ CONNECT '' \ ogin:--ogin: $ACCOUNT \ assword: $PASSWORD #------------------------------------------------------------ # Remarque de Nat Makarevitch : # # "tu ne tiens pas compte de VOICE et WAITING mais ce n'est # pas grave" # # #--------------------------------- 7) le script /usr/local/sbin/ppp-off (déconnexion) --------------------------------------------------- #!/bin/sh # # +--------------------------------+ # | DE-CONNEXION INTERNET (en PPP) | # +--------------------------------+ # # updated: 06 mai 1998 # ******** Denis BRAUSSEN # # #---------------------SCRIPT DE DECONNEXION-A INTERNET (hol.fr)-- # # # ATTENTION: ce script doit etre lance sous root ou 'setuid' root # # nom: /usr/local/sbin/ppp-off # # ***************************************************************** # Denis BRAUSSEN added: # ***************************************************************** # echo "bye :" `date` | cat >> /var/log/chatlog # /var/lock/internet/chatlog.lock +---------------------------+ # rm /var/log/internet/chatlog | message session en cours | # rm /var/lock/internet/chatlog.lock| verrou et calcul prix | # /root/.scripts/prix_connection +---------------------------+ # /root/.scripts/calcul_prix #----------------------------------------------------------------- # # -------======<<<<<<<<<*>>>>>>>>>>>======------ # # ------------------------------------------------------------------------- # verification : si chatlog.lock n'existe pas , alors le script 'internet' # (lien sur ppp-on) n'a pas ete execute --> abort. # ------------------------------------------------------------------------- if [ ! -e /var/lock/internet/chatlog.lock ]; then echo "-ERROR--------------------------------------------------------------------" echo "/user/local/sbin/ppp-hol script (internet) was not executed. aborting bye." echo "--------------------------------------------------------------------------" exit 1 fi # Determine the device to be terminated. # -------------------------------------- if [ "$1" = "" ]; then DEVICE=ppp0 else DEVICE=$1 fi # If the ppp0 pid file is present then the program is running. Stop it. # --------------------------------------------------------------------- if [ -r /var/run/$DEVICE.pid ]; then kill -INT `cat /var/run/$DEVICE.pid` # If the kill did not work then there is no process running for this # pid. It may also mean that the lock file will be left. You may wish # to delete the lock file at the same time. # -------------------------------------------------------------------- if [ ! "$?" = "0" ]; then rm -f /var/run/$DEVICE.pid echo "ERROR: Removed stale pid file" # ------------------------------------------------------------ # calcul prix connection et cleanup, meme si ppp non etablie: # il faut quand meme payer 1 unite france telecom :-( # # ATTENTION: ENLEVER CETTE LIGNES SI PAS DE CALCUL DE PRIX # ------------------------------------------------------------ /root/.scripts/prix_connection # rm /var/lock/internet/chatlog.lock rm /var/log/internet/chatlog exit 1 fi # Success. Let pppd clean up its own junk. # --------------------------------------- echo "PPP link to $DEVICE terminated." # # calcul prix connection et cleanup # # ATTENTION: ENLEVER CETTE LIGNES SI PAS DE CALCUL DE PRIX # ------------------------------------------------------------ /root/.scripts/prix_connection # rm /var/lock/internet/chatlog.lock rm /var/log/internet/chatlog exit 0 fi # The ppp process is not running for ppp0 # --------------------------------------- echo "ERROR: PPP link is not active on $DEVICE" # # calcul prix connection et cleanup, meme si ppp non etablie: # il faut quand meme payer 1 unite france telecom :-( # # ATTENTION: ENLEVER CETTE LIGNES SI PAS DE CALCUL DE PRIX # ------------------------------------------------------------ /root/.scripts/prix_connection # rm /var/lock/internet/chatlog.lock rm /var/log/internet/chatlog exit 1 #-------------------------------------- 8) conclusion ------------- - le script qui calcule le prix de la connexion n'est pas inclus à cette mini-doc : enlever les lignes correspondantes dans /usr/local/sbin/ppp-off - dans certains scripts /device/ttyS0 ('COM 1 sous DOS') est remplacé par /device/cua0 : cette dernière écriture est à proscrire, car elle est appelée à disparaître dans les prochaines versions de linuX. - bien sûr si votre modem est sur 'COM 2' il faudra mettre /device/ttyS1 dans les scripts ! - pour 'setuid' les script se procurer 'sudo' puis faire 'man sudo' pour plus d'infos (si on ne le fait pas on est forcé de se connecter sous 'root' :-( ! ) A titre d'exemple, voici mon /etc/sudoers # sudoers file. ---------------------------------------------------- # name: /etc/sudoers # # This file MUST be edited with the 'visudo' command as root. # See the man page for the details on how to write a sudoers file. # User privilege specification root ALL=(ALL) ALL # postman ALL=/usr/local/sbin/internet, /usr/local/sbin/bye, /etc/ppp/ppp-on-dialer # # attention: ci-dessus: tout sur une seule grande ligne # # '/home/postman/internet' est un lien sur /usr/local/sbin/ppp-hol # '/home/postman/bye' est un lien sur /usr/local/sbin/ppp-off # postman BatMan=(news) /usr/local/sbin/getnews postman BatMan=(news) /usr/bin/pine #--------------------------------------------------- - en te souhaitant bonne connexion ! - Merci à Nat Makarevitch pour ses conseils et ses corrections ! - ce document a été posté en premier sur - --- )\ ___ _ /\_('')/\ Bien Amicalement, | \ ___ _ _ (_)___ - -- \__ __/ Best regards, | |) / -_) ' \| (_-< _/ \ FidoNet 2:325/200 |___/\___|_||_|_/__/ --- \____/ --e-mail--> Denis BRAUSSEN AmicaLinuXement, .----------------------. Denis. ( POWERED BY GNU/LINUX )