autmaticky start pevne linky
Miroslav Kes
mira at rockwell.cz
Mon Jan 12 11:38:44 CET 1998
Jiri Hudak wrote:
>
> Miroslav Kes wrote:
>
> > Jiri Hudak wrote:
> > > muze mi nekdo poradit jak osetrit automaticky start pevne linky ve
> > > freebsd. Ja jsem pouzil ttys ,ale zlobi nahazuje prakticky porad .
> > > Potrebuji aby, zjistil ,ze linka spadla a nahodil ji.
> > Mohl bys to nejak upresnit. Co vlastne pada?
> > Bud se rozpadne spojeni mezi modemy (ztrati nosnou apod.) nebo prestane
> > fungovat pppd. Pokud to druhe jake ppp pozivas? Kernel level nebo to
> > interaktivni (Toshiharu Ohno)?
> Ahoj,
> o modemy se nejedna ty spoji samy, ale o pppd i kdyz zustane nahozeny
> nevytvori
> se ppp0 zarizeni. Pouzivam ppp0 v jadre ne tun0. Ted to resim pomoci
> cronu,
> ze co 5 min se pokousi nahodit pppd., ale lip by bylo kdyby to slo pomoci
> scriptu
> mam to vymyslene tak ze by se hlidal ve /var/run/ppp0.pid ,a pokud
> neexistuje
> tak by se spustil znovu pppd,ale scriptovaci jazyk moc neznam.
Na podobny problem jsem s pppd taky narazil a reseni, ktere pouzivam
vypada takto:
pppd je spousten ze scriptu a to vlastni volani je
/usr/sbin/pppd file /etc/ppp/options
soubor /etc/ppp/options :
> more /etc/ppp/options
cuaa2
57600
crtscts
modem
lock
passive
domain MYDOMAIN
netmask MYNETMASK
LOCAL_IP_ADDRESS:
kde MYDOMAINMYDOMAINLOCAL_IP_ADDRESS jsou doplneny podle dane site.
Krome toho pouzivam take soubory ip-up a ip-down (viz man pppd), ktere
vypadaji takto:
> more /etc/ppp/ip-up
#!/bin/csh
if( $#argv < 5 ) then
logger -i -s "ip-up: Issuficient number of parameters passed"
exit 1
endif
if( $1 == "ppp0" ) then
route -n add default REMOTE_IP_ADDRESS
route -n add -host REMOTE_IP_ADDRESS LOCAL_IP_ADDRESS -interface
$4
endif
> more /etc/ppp/ip-down
#!/bin/csh
if( $#argv < 5 ) then
logger -i -s "ip-down: Issuficient number of parameters passed"
exit 1
endif
if( $1 == "ppp0" ) then
route -n delete default
route -n delete REMOTE_IP_ADDRESS
endif
Opet REMOTE_IP_ADDRESS a LOCAL_IP_ADDRESS jsou doplneny podle nasi site.
Ten script z ktery se o pppd stara je napsan takhle:
> more /usr/sbin/pppstart
#!/bin/csh
set conffile = "/etc/ppp/options"
if( $#argv > 0 ) goto usage
# leased line to the research center
if( ! -r $conffile ) then
echo "pppstart: Configuration file $conffile missing!"
echo "pppstart: Exiting!"
exit 1
endif
# loop restarting pppd if it eventualy terminates
while( 1 )
set ppp_procs = `ps -ax | grep pppd | grep -v grep`
if( $#ppp_procs == 0 ) then
logger -i -s -t pppstart " Starting pppd using
$conffile"
/usr/sbin/pppd file $conffile
logger -i -s -t pppstart " pppd exited ! "
else
set def_route = `netstat -rn | grep default`
if( $#def_route == 0 ) then
kill -9 $ppp_procs[1]
endif
endif
sleep 30
end
exit 0
# ...and the usage stuff
usage:
echo "Usage: pppstart"
echo ""
echo "pppstart ifconfigs ppp interface and starts pppd for it"
echo "using configuration from $conffile"
echo "It restarts pppd if it eventually terminates."
Funguje to nasledovne:
pokud zadny pppd nebezi tak je spusten
pri ziskani IP konektivity nahodi ip-up (mimo jine) default route
pri jeji ztrate ip-down defaut route zrusi
po spusteni pppd se za 30 vterin zkontroluje jestli mame
IP konektivitu (default route existuje)
pokud ne pppd se zastreli pocka se 30 vterin a vse se znovu opakuje.
Tak snad ti to pomuze prip.doda nejakou inspiraci.
Mira
--
-----------------------------------------------------------
| Miroslav Kes |
|---------------------------------------------------------|
| Rockwell Automation Ltd. | tel.: (+420) 2 2425 6913 |
| Research Center Prague | fax: (+420) 2 250467 |
| Americka 22 | e-mail: mira at rockwell.cz |
| 120 00 Praha 2 - Vinohrady | |
| Czech Republic | |
-----------------------------------------------------------
More information about the Users-l
mailing list