Results 1 to 2 of 2

Thread: Anyway to automaticaly refresh my ethenet conection every X hours?

  1. #1
    Join Date
    Apr 2007
    Beans
    Hidden!

    Anyway to automaticaly refresh my ethenet conection every X hours?

    My DSL modem is constantly loosing its signal every time i start a torent downloading,im not sure if its trying to connect to too many peers for DSL modem to handle or what. but it does this on both windows and linux,what id like is a way to have the computer ping a site like Google and if no signal is sent back then the script will automatically refresh my eth1 connection.

    Is this possible? If so id assume it would be easy to script but then again i know nothing about scripting.. If its something very simple could someone script it for me? I leave my computer untended for days on end and im not around to refresh my modem by hand so this would be a big help.

  2. #2
    Join Date
    Dec 2009
    Beans
    540
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Anyway to automaticaly refresh my ethenet conection every X hours?

    Ok, I've got something that may work if your eth1 is wired, but I'm having trouble making it work for wireless. This is assuming a dhcp connection ( but it can be modified for static ips). Try it in your /etc/crontab set to run every however many number of hours you want as root.


    Code:
    if ! ping -c 4 www.google.com; then ifup eth1; dhclient eth1; fi;
    Give it a try, it may need to be tweaked.

    OK, for wireless, you can try this:

    Code:
     if ! ping -c 4 www.google.com; then ifconfig eth1;
     iwconfig eth1 essid NETWORK_ID key WIRELESS_KEY;
     dhclient eth1;
    fi;

    from: http://www.ghacks.net/2009/04/14/con...-command-line/
    Last edited by patchwork; March 6th, 2010 at 07:50 PM. Reason: Added Wireless

Bookmarks

Posting Permissions

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