Aditya Kavoor’s Blog

HowTo: Automate start and stop BSNL router in Linux

with 9 comments

BSNL is the culprit of spreading insomnia(sleeplessness) among young India. In other words, the happy hours of BSNL free download is scheduled from 0200 hrs to 0800 hrs which results in people staying awake early in the morning and missing out on the essential sleep. This is when automation tools and schedulers come to picture.

This guide basically does you want to do at 0200 hrs and 0800 hrs with a BSNL broadband connection. This works only if your modem is configured in the bridge mode and not in the PPPoE mode, assuming most of you have port-forwarding enabled for higher download speeds which by default needs bridge mode.

OK, here we go. At 0200 hrs -

  • You want to start the internet connection
  • You want to reset your IP
  • You want to start your torrent client

and at 0800 hrs -

  • You want to stop the internet connection
  • You want to stop your torrent client

At a point when you are about to sleep, turn off the internet connection with this command in the terminal:

sudo /etc/init.d/networking stop


Now, start your torrent client and enable all downloads. The downloads will not begin since your internet is off. Remember your modem is still ON.

The main task here is to switch on the internet connection at 0200 hrs, and stop the connection at 0800 hrs and close all torrent clients and download managers. For this we use the inbuilt automation tool in Linux, cron. Open up the terminal and -

sudo crontab -e

Note that if you are running cron for the first time, it asks you to choose an editor. I strongly recommend you to use nano. Enter the following lines into the file -

05 02 * * * /etc/init.d/networking restart
55 07 * * * killall ktorrent deluge
55 07 * * * /etc/init.d/networking stop

Save and close the file. Here replace ktorrent or deluge with your favorite torrent client. Once this is done, your internet automatically restarts at 5 past 2 early morning, starts all your downloads and turns down the internet at 5 minutes to 8 and also closes down the torrent clients.

Now, you may ask how do I initially configure my internet connection in Bridge mode. Thats simple as well.

Open the terminal -

sudo pppoeconf

Follow on screen instructions, enter your BSNL username and password when asked and done, your connection is up and running and activates at every boot.

With this, you can now sleep tight. Good night.

PS: To automate stuff in the PPPoE mode, follow Madhusudan’s Guide.

Written by Aditya Kavoor

June 30, 2009 at 12:10 am

9 Responses

Subscribe to comments with RSS.

  1. That’s a nice post, there. But this will only make insomnia worse. People will stay up at night watching the free movies and porn they download. :D

    Adarsh Bhat

    June 30, 2009 at 12:59 am

  2. thanks for the guide bro, i actually switch off my comp at night, hav set my BIOS to auto boot at 2am, so i wanna kno in my case if there is any change of procedure required thanks again..

    Ashish

    July 17, 2009 at 7:42 pm

  3. thanks for the guide bro, i actually switch off my comp at night, hav set my BIOS to auto boot at 2am, so i wanna kno in my case if there is any change of procedure required ….also i use transmission as my torrent client , n how do i change from pppoe to bridge plz do help me out thank u..

    Ashish

    July 17, 2009 at 10:11 pm

    • This guide should still work in your case. Be sure to give sufficient time in the cron for the system to boot.

      Unless you specify what modem you have I cannot tell you how to switch over to bridge mode.

      Aditya Kavoor

      July 20, 2009 at 3:34 pm

  4. thanks for de reply, i use UT300R2U ADSL2+ MODEM , i am confused weather to switch over to bridge mode or remain in pppoe mode(shedulde using Madusudan’s guide)
    plz do guide me as to how to go about it..

    Ashish

    July 26, 2009 at 12:07 am

    • This modem should work fine in bridge mode. Just enter into your modem page – 192.168.1.1 and select bridge mode in your WAN Settings.

      Once that is done, type – sudo pppoeconf and follow onscreen instruction with YES for everything. Your bridge mode should be up and running in no time.

      Bridge mode is always better because it opens up ports and increases your download speed. Happy downloading :)

      Aditya Kavoor

      July 26, 2009 at 12:14 am

  5. thanks for the info bro i got it working, may i ask u 1 more thing.. since i wake up my comp using BIOS i need to know how to launch my torrent client-transmmision at 2am automatically, is ther any command i cud include in crontab -e ..i appreciate all ur help..

    Ashish

    July 27, 2009 at 2:16 pm

  6. 05 02 * * * export DISPLAY=:0 && transmission

    For this command to run use crontab -e without the sudo

    Aditya Kavoor

    July 28, 2009 at 12:44 am


Leave a Reply