(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



PPP up and down scripts


What is this stuff?

If this isn't exactly what you wanted, please try our Search (there's a LOT of techy and non-techy stuff here about Linux, Unix, Mac OS X and just computers in general!):



From - Sat Oct  2 12:14:10 1999
Xref: world comp.unix.sco.misc:106571
Path: world!blanket.mitre.org!newsfeed.berkeley.edu!remarQ73!rQdQ!supernews.com!remarQ.com!corp.supernews.com!not-for-mail
From: "Brian K. White" <linut@squonk.net>
Newsgroups: comp.unix.sco.misc
Subject: Re: Help in configuring "simple" DNS on SCO OSR 5.0.4
Date: Sat, 02 Oct 1999 07:50:09 -0400
Organization: Albany Burner Control
Lines: 133
Message-ID: <37F5F171.8BFFE59F@squonk.net> 
References: <37f59992.776138@news.concentric.net> 
X-Complaints-To: newsabuse@supernews.com
X-Mailer: Mozilla 4.6 [en] (X11; I; SCO_SV 3.2 i386)
X-Accept-Language: en
MIME-Version: 1.0
Content-Type: multipart/mixed;   boundary="------------90B2C3B1A582735A860AE3CC"
Cache-Post-Path: firth.squonk.net!unknown@dialup-115.squonk.net
X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/)
X-Mozilla-Status: 8011

This is a multi-part message in MIME format.
--------------90B2C3B1A582735A860AE3CC
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

RP wrote:
> 
> Running SCO Open Server 5.0.4p on  a single IBM PC.  Have used Tony
> Lawrence's sample scripts "up," and "down" to establish dial-up PPP
> connection to my ISP (concentric.net DNS 207.155.184.72 and
> 206.173.119.72, local and host address assigned dynamically by ISP).
> The connection is fine, I can ping the ISP using the numeric host
> address, but cannot figure out how to use the ISP DNS servers, so I
> can browse with Netscape Navigator.
> I don't have or need any networking other than this WAN connection to
> the ISP, and therefore don't need DNS on my computer.
> 
> My /etc/resolv.conf file contains:
> domain concentric.net
> nameserver 207.155.184.72
> nameserver 206.173.119.72
> (Yes, the DNS addresses are correct.)
> 
> My /etc/hosts file contains:
> localhost 127.0.0.1
> (I don't know how to reference concentric.net, since this is assigned
> dynamically, after the connection is established.)
> 
> I don't use named.boot, since there is no DNS on my box.
> 
> Any help, other than "man ifconfig, routed, named, resolv.conf,
> gated,"  etc appreciated. I have tried making sense of the above "man"
> entries  repeatedly without success.
> 
> Thanks,
> 
> --Ray Petkus <rpetkus@ibm.net>



I added the following to my up/down script for ppp:

 route add default `ifconfig $PPP 2>/dev/null |grep inet |cut -d" " -f2
`
just after the connection test succeeds, and
 route flush >/dev/null
just after bringing the connection down

here is my whole script. I call it "isp up" or "isp down" and it prints
the most basic of status info while it's working, and you know it's done
when the prompt comes back. (whereas pppattach doesn't inform you of
it's success or failure)
It's basically Tony's up & down scripts combined and with an automatic
default route maker inserted

you may need to change the -f2 in the "defgate" function to -f4, I have
my default gateway set to the other end of my PPP connection, but I've
also seen references and tested it myself, where the default gateway
should be whatever own IP is after connection. I think it depends on
your ISP, their implementation of PPP, and probably 23 things about your
own box that I don't know enough to talk about :)

btw, if you do the math re: WAIT x RETRY in this script you will see I
have it set to a very long time, this is becaues pppattach or uucp
underneath it, redials automatically and invisibly at least for me when
it fails to connect, so I made the testing phase long enough to account
for 2 or three Busy signal / retry cycles. but it checks every 5
seconds, so the script completes and exits as soon as a connection is
up.  

--
Brian~
--------------90B2C3B1A582735A860AE3CC
Content-Type: text/plain; charset=us-ascii;
 name="isp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="isp"



#!/bin/sh
# isp - raises and lowers PPP connection to ISP. linut@squonk.net
# usage: isp up    - connects to ISP
#        isp down  _ disconnects from ISP
# Derived from  /Unixart/quickppp.html

ISPNAME=squonk          # connection name used in cu and uucp config files
GATEWAY=                # default gateway address (blank for auto) 
WAIT=5                  # delay in seconds between connection tests
RETRY=45                # number of times to test connection before giving up
PPP=ppp0                # interface to use
DEBUG=                  # diagnostic messages 1=on blank=off

###############################################################################

#find out the default gateway
defgate () { [ $GATEWAY ] && echo $GATEWAY || ifconfig $PPP 2>/dev/null |grep inet |cut -d" " -f2 ; }

case "$1" in
    up)
        TC=0
        # ifconfig $PPP >/dev/null 2>&1 && $0 down
        [ $DEBUG ] && echo "$0: Connecting to \"$ISPNAME\""
        pppattach $ISPNAME >/dev/null
        while [ $TC != $RETRY ]
        do
        ifconfig $PPP >/dev/null 2>&1 && {
            route add default `defgate` >/dev/null
            echo "$0: Connected to \"$ISPNAME\""
            [ $DEBUG ] && echo -n "$(($TC*$WAIT)) seconds.\n$0: "
            [ $DEBUG ] && netstat -r
            exit 0
        }
        TC=$(($TC+1))
        sleep $WAIT
        done
        echo "$0: Failed to connect to \"$ISPNAME\" after $(($TC*$WAIT)) seconds."
        exit 1
    ;;
    down)
        [ $DEBUG ] && echo "$0: Disconnecting from \"$ISPNAME\" (`defgate`) "
        ifconfig $PPP down 2>/dev/null
        route flush >/dev/null
        echo "$0: Disconneced from \"$ISPNAME\""
        [ $DEBUG ] && netstat -r
    ;;
    test)
        ifconfig $PPP >/dev/null 2>&1 && echo "Device $PPP is UP (`ifconfig $PPP 2>/dev/null |grep inet |cut -d" " -f2,3,4 `)" || echo "Device $PPP is DOWN"
    ;;
    *)
        echo "$0: usage: $0 up|down|test"
    ;;
esac




Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



/Bofcusm/110.html copyright 1997-2004 (various authors) All Rights Reserved

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.



More:
       - OSR5
       - Bofcusm


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress