How to stop and restart PPP from a script?



  • Hi,

    Is there a clean way, from a script, to make pfSense close and re-open PPP?

    For example, if I called /etc/rc.reload_interfaces , would that do the trick safely without messing up anything?

    I just ask because here in the UK, ADSL and FTTC circuits have an occasional problem, where PPP comes up but you can't see the Internet >:(.  The PPP link is established to a BT test network, not to your ISP's network, possibly because the ISP kit didn't respond in time.

    It would be good to make pfSense automatically detect the condition "PPP up but can't see Internet", and respond accordingly.  So for a year or two I've had a script that runs from a CRON job every 10 minutes, and does some tiny Pings.  If those fail, it reboots pfSense.  Latest version is pasted below.

    In summary then… I am just wondering if there is a cleaner way to solve the "PPP up but can't see Internet" problem.  It would be nice to avoid a full reboot, because my Soekris 5501 box just occasionally hangs when rebooting.

    Existing script is as follows...

    
    #!/bin/sh
    # First sleep for 6 mins so that we don't run this code if box has only just booted and PPPoE not up yet.
    /bin/sleep 360  
    
    # Try 12 mins worth of very short pings to googles DNS servers.
    # Quit immediately if we get a single frame back.
    # Don't reboot unless outage lasts more than 20 minutes.
    
    counting=$(/sbin/ping -o -s 0 -c 360 8.8.8.8 | /usr/bin/grep 'received' | /usr/bin/awk -F',' '{ print $2 }' | /usr/bin/awk '{ print $1 }' )
    if [ $counting -eq 0 ]; then
    
         counting=$(/sbin/ping -o -s 0 -c 360 8.8.4.4 | /usr/bin/grep 'received' | /usr/bin/awk -F',' '{ print $2 }' | /usr/bin/awk '{ print $1 }' )
         if [ $counting -eq 0 ]; then
    
            # network down
            # Try flipping WAN NIC in the hope that will trigger BT modem to reconnect properly ...
            /sbin/ifconfig vr3 down
            /bin/sleep 10 
            /sbin/ifconfig vr3 up
            /bin/sleep 60
    
            counting=$(/sbin/ping -o -s 0 -c 360 8.8.8.8 | /usr/bin/grep 'received' | /usr/bin/awk -F',' '{ print $2 }' | /usr/bin/awk '{ print $1 }' )
            if [ $counting -eq 0 ]; then
    
                counting=$(/sbin/ping -o -s 0 -c 360 8.8.4.4 | /usr/bin/grep 'received' | /usr/bin/awk -F',' '{ print $2 }' | /usr/bin/awk '{ print $1 }' )
                if [ $counting -eq 0 ]; then
    
                   # network STILL down
                   # Save RRD data
                   /etc/rc.stop_packages
    	       /etc/rc.reboot
                fi
            fi
        fi
    fi
    

Log in to reply