Results 1 to 2 of 2

Thread: Unable to restore VPN connection

Threaded View

  1. #1
    Join Date
    Mar 2010

    Unable to restore VPN connection

    I am trying to keep a VPN connection open between two Ubuntu 8.04 LTS servers, one in Holland and one in China. Unfortunately, because the connection in China is not great, about 1 time a day the connection drops. I have therefore devised a script, to be started by crontab once every 5 minutes, that checks the connection and if necessary restores it.

    ping -c 2 -W 10 &> /dev/null;
    PING = $?;
    if [ "$PING"-ne 0]; then
      # Restart pptp connection
      killall pppd;
      sleep 30;
      /usr/sbin/pppd call pptpvpn;
    The script works fine when I start it from the shell but, unfortunately, when starting from cron it generates the following error messages in syslog:

    bluebuntu /USR/SBIN/CRON[29540]: (root) CMD (/usr/local/bin/checkvpn > /tmp/checkvpn.log 2>&1)
    bluebuntu pppd[29551]: pppd 2.4.4 started by root, uid 0
    bluebuntu pppd[29551]: Couldn't get channel number: Input/output error
    bluebuntu last message repeated 9 times
    bluebuntu pppd[29551]: Exit.

    In which bluebuntu is my server's name.

    Any ideas on why this is happening? I would help me a lot if someone would provide a solution for this issue.


    P. S. My script in /etc/init.d is:

    function routeadd {
       route add -net netmask dev ppp0
       route add -net netmask dev ppp0
    function makepptp {
      echo pty \"pptp --nolaunchpppd\" >> /etc/ppp/peers/pptpvpn;
      echo remotename PPTP >> /etc/ppp/peers/pptpvpn;
      echo require-mppe-128 >> /etc/ppp/peers/pptpvpn;
      echo file /etc/ppp/options.pptp >> /etc/ppp/peers/pptpvpn;
      echo ipparam pptpvpn >> /etc/ppp/peers/pptpvpn;
      echo persist >> /etc/ppp/peers/pptpvpn;
      echo usepeerdns >> /etc/ppp/peers/pptpvpn;
      pppd call pptpvpn > /tmp/pptpvpn.log 2>&1 &
    if [ -e /etc/ppp/peers/pptpvpn ]; then
      rm /etc/ppp/peers/pptpvpn;
      echo name myvpn >> /etc/ppp/peers/pptpvpn;
      sleep 12;
      echo name myvpn >> /etc/ppp/peers/pptpvpn;
      sleep 12;
    Last edited by ZuperB; March 4th, 2010 at 09:57 PM. Reason: removed URL

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts