Draytek Vigor 2800 reboot script

After years of great service, our Draytek Vigor 2800 seems to be having problems after running for a few days of allowing HTTPS in to our network, which is only solved by rebooting the router. For the life of me I can’t upgrade the firmware using either the TFTP or FTP approach. So giving up, I’ve adopted the brute force approach of scheduling a reboot every night. To do this I considered scripting the appropriate Telnet commands to the router, but that would involve some custom or third party code. (Telnet, being a duplex protocol means you can’t simply pipe commands to telnet.exe from a batch file, you have to use something like expect to script a Telnet session.)

The simplest, lowest-tech approach (and they’re always the best, right?) I found was merely to mimic the reboot page on the router web management UI with the following Windows Scripting Host script:

////// RebootRouter.js ////////
// Change these for your environment
var ROUTER_IP = "";
var ROUTER_USER = "admin";
var ROUTER_PASSWORD = "pA55w0rd";

var http = new ActiveXObject("Microsoft.XMLHTTP");
http.open("POST", "http://" + ROUTER_IP
    + "/cgi-bin/reboot.cgi", false,

// For debugging/logging un-comment the following lines:
// WScript.Echo(http.status + " " + http.statusText);
// WScript.Echo(http.responseText);

Save this as RebootRouter.js, update the values accordingly and schedule for a appropriate time using Control Panel > Scheduled Tasks.

31 thoughts on “Draytek Vigor 2800 reboot script

  1. Total noob at Java. We have a Draytek 2910 and this script worked great for me. I might have been doing something wrong but I couldn’t get it to work unless I moved the URL/username/pass into the open command.

  2. @Jason: actually there was a typo in the code, the “+” that was before ROUTER_USER shouldn’t have been there. Fixed now.

  3. Just what i was looking for, i too have a 2800.
    Because I’m a total noob in java, how can i do for the script first to check if the internet is online, for exemple:

    if ( ping google.com == true ) { do nothing, internet is ok } else { reboot draytek }

    would appreciate very much the help.


    1. Hi,

      I’ve just come across this thread and was wondering if there was a fix for this problem as we are suffering from this at my work.

      The connection just drops out, and i’d like to run a script that would check the connection, periodically, and if down, reboot the router. My scripting skills are pretty basic, so looking for a little help.

      The original script doesn’t reboot, at the mo….


      1. Sorry, we don’t have this router any more so I can’t really help you! Try the Draytek forums.

      2. Hi,
        I don’t know if this bash script can help you or not, it will only restart the router if it can’t get a ping response:


        if ping -c 1 > /dev/null || ping -c 1 > /dev/null
        : # colon is a null and is required
        wget http://admin:@/cgi-bin/reboot.cgi –post-data=”sReboot=Current&submit=OK”
        echo “Ping failed, router has been restarted” | mail -s “Router Restart”

  4. Same sort of problem here, every so often, connection just drops, then it gets stuck on

    “Message [ starting PPP]”

    Its driving me up the wall, as I can’t connect back in from outside, and have to wait until I get home to reset the damn thing.

    Next step is to be able to run the scrips on the router its self, maybe draytek are reading……?

  5. Excellent solution, My router seems to have gone to having to be restarted every 24 hours so I can use the internet. It connection just drops out after this time. So I now set the schedule command to restart the router when the pc is started. excellent script just what I was looking for.

  6. Having a vpn between a 2700 and a 2600 i wanted both routers to reboot.The script worked with the 2700 but it didnt work with the 2600.After some digging i found that you have to replace the “OK” with ” OK ” for instance :
    (“sReboot=Current&submit= OK “)
    This made the script work with the 2600, but for other draytek routers one must check the source code on the routers reboot web page to see if there are any differencies with the script.
    Nice one btw thanks

  7. Hi,
    Thanks for the script but much easier using wget:

    wget http://«username»:«password»@«routerip»/cgi-bin/reboot.cgi --post-data="sReboot=Current&submit=OK"

    And to automatically restart the router, whack it into monit

  8. Hi, i can’t seem to get it to work on the 2820vn. What would the script be for the following pls?

    function TR(str){return str;}parent.printTitle(document);parent.printLogo(document,9,TR('Reboot System'));<b>Reboot System</b><b>Do you want to reboot your router ?</b> Using current configuration Using factory default configuration <b>Auto Reboot Time Schedule</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Index(1-15) in&nbsp; <a href="../cgi-bin/v2x00.cgi?fid=2056" rel="nofollow">Schedule</a>&nbsp;Setup:&nbsp; ,&nbsp; ,&nbsp; ,&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>Note</b>:&nbsp;Action and Idle Timeout settings will be ignored.&nbsp;&nbsp; top.ACTION_STATUS=-1;top.iActionStatusFlag='-2';top.iFwUpgradeState='0';top.act_sta.damage_alert();var bg=parent;var f=document.frm1;var aryTimeSch=['0', '0', '0', '0'];initPage();initParameter();function initParameter(){if(bg.SHOW_APP_SCHEDULE){bg.showElmtByClass(document,"table","scdul");bg.showElmtByClass(document,"br","scdul");}if(aryTimeSch[0]!='0')bg.setVle2Elmt(f.nSch1,aryTimeSch[0]);if(aryTimeSch[1]!='0')bg.setVle2Elmt(f.nSch2,aryTimeSch[1]);if(aryTimeSch[2]!='0')bg.setVle2Elmt(f.nSch3,aryTimeSch[2]);if(aryTimeSch[3]!='0')bg.setVle2Elmt(f.nSch4,aryTimeSch[3]);}function onClkBtnOk(){bg.setVle2Elmt(f.fid,2);f.submit();}function onClkBtnCcl(){document.location="../cgi-bin/reboot.cgi?fid=1";}function initPage(){if(bg.SHOW_SYS_ADMIN){bg.showElmtByClass(document,"span","admin");}}

      1. Sorry, I just looked over my first post and realised it used some of the commands within the text rather than show just the text. I’ll have another go. BAsically I was wondering if the “OK” response is the same for this?

        ” function TR(str){return str;}parent.printTitle(document);parent.printLogo(document,9,TR(‘Reboot System’));Reboot SystemDo you want to reboot your router ? Using current configuration Using factory default configuration Auto Reboot Time Schedule       Index(1-15) in  Schedule Setup:  ,  ,  ,         Note: Action and Idle Timeout settings will be ignored.   top.ACTION_STATUS=-1;top.iActionStatusFlag=’-2′;top.iFwUpgradeState=’0′;top.act_sta.damage_alert();var bg=parent;var f=document.frm1;var aryTimeSch=[‘0’, ‘0’, ‘0’, ‘0’];initPage();initParameter();function initParameter(){if(bg.SHOW_APP_SCHEDULE){bg.showElmtByClass(document,”table”,”scdul”);bg.showElmtByClass(document,”br”,”scdul”);}if(aryTimeSch[0]!=’0′)bg.setVle2Elmt(f.nSch1,aryTimeSch[0]);if(aryTimeSch[1]!=’0′)bg.setVle2Elmt(f.nSch2,aryTimeSch[1]);if(aryTimeSch[2]!=’0′)bg.setVle2Elmt(f.nSch3,aryTimeSch[2]);if(aryTimeSch[3]!=’0′)bg.setVle2Elmt(f.nSch4,aryTimeSch[3]);}function onClkBtnOk(){bg.setVle2Elmt(f.fid,2);f.submit();}function onClkBtnCcl(){document.location=”../cgi-bin/reboot.cgi?fid=1″;}function initPage(){if(bg.SHOW_SYS_ADMIN){bg.showElmtByClass(document,”span”,”admin”);}}”

    1. Hi,
      Yes my wget command works on a 2820 router, I can’t imagine that the 2820vn would use a different reboot procedure, and looking from what you have pasted it doesn’t seem to. If it really doesn’t work try changing submit to submitbnt and OK to Reboot Now, so the command would be:

      wget http://«username»:«password»@«routerip»/cgi-bin/reboot.cgi –post-data=”sReboot=Current&submitbnt=Reboot Now”

      Be aware that’s submitbnt not submitbtn.

  9. Any idea how I can switch on/off PPTP access on a Vigor 2910?

    Should be something like

    wget http://username:password@ –post-data=”sDiUserOnShow=On&iIdleTimeOutShow=999&iDInPPTP=1&iDInIPSec=0&sPeerNShow=&txtPeerId=&sDiUserShow=pptpuser&sDiPwShow=********&txtDinPskey=&sltXPID=0&txtLocalId=&sCallBackNShow=&iCallBackBudgetShow=0&sAct=saveitem&iPageIdx=1&iProfileIdx=1&submit=OK”

    It’s something I got from Wireshark, but it says it’s unauthorized….

    1. Sorry, I don’t have the 2800 anymore so I can’t investigate. Perhaps you need to visit the logon form and save the authentication cookie somehow?

    2. Hi,
      Ok you are authenticating for the first request, but I believe it redirects you to the reboot page, which you then don’t pass authentication. So to get round that put your username and password into the http parameters for this which are –http-user and –http-password so your command would be:

      wget –http-user username –http-password password –post-data=”sDiUserOnShow=On&iIdleTimeOutShow=999&iDInPPTP=1&iDInIPSec=0&sPeerNShow=&txtPeerId=&sDiUserShow=pptpuser&sDiPwShow=********&txtDinPskey=&sltXPID=0&txtLocalId=&sCallBackNShow=&iCallBackBudgetShow=0&sAct=saveitem&iPageIdx=1&iProfileIdx=1&submit=OK”

      However when looking at my 2820 I could turn PPTP on and off using the following:

      Turn on:
      wget –http-user username –http-password password “”
      Turn off:
      wget –http-user username –http-password password “”

      However note you will need to call the reboot command afterwards for this to take effect I think.

      1. Well, meanwhile I found something that works. I get many auth errors, but it works. 🙂

        You’re turning on and off PPTP dial-in in general. That’s something I can’t do as there are still roadwarriors out there who’d like to get in. I just want to turn on/off a certain user account. This works without a reboot, by the way!

    3. Ok Well it looks like each request will have to be specific to the VPN setup, here is some kind of reference so that you can pull together the post data which I pulled from my 2820 to try and help:

      sDiUserOnShow:On Enable this account
      iIdleTimeOutShow:300 Idle Timeout
      iDInPPTP:1 PPTP Setting
      iDInIPTunnel IPSec Tunnel
      iDInL2TP L2TP
      iDInIPSec:0 IPSec Tunnel Policy
      sPeerNShow: Remote Client IP or Peer ISDN Number
      txtPeerId: Peer ID
      sDInNetNamPkt:0 Netbios Naming Packet
      sDInMultiCasePkt:0 Multicast via VPN
      sDiUserShow:test Username
      sDiPwShow:test Password
      iMOTPEnable Enable Mobile One-TimePasswords(mOTP)
      sPin: PIN Code
      sSecret: Secret
      chkDinPSK:1 Pre-SHared Key
      txtDinPskey: IKE Pre-Shared Key
      chkDinSIG Digital Signature(X.509)
      sltXPID:0 Digital Signature(X.509) select list
      chkDinAH:1 Medium(AH)
      chkDinDES:1 High(ESP)
      chkDin3DES:1 3DES
      chkDinAES:1 AES
      txtLocalId: Local ID
      iProfileIdx:1 Profile Index (which remote user’s settings to edit)

  10. That’s what I was afraid of.

    BUT it’s much simpler!

    I now have a script for every site that logs on to the web interface, allows the PPTP dial-in, dials in, sets the route to the network, starts an inifinite ping for keep-alive and disallows further PPTP log-ons.

    A second script can run ALL site’s scripts, so I’ve got connection to all sites wth one click, now. Great! REALLY GREAT!! 🙂 Thank you for your help concerning submission of credentials!

Leave a Reply to Duncan Smart Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s