Script to speed up mobile internet connexion in Linux

For people who use an USB stick or mobile phone to surf the internet on the go, it’s often reported that the connection is sloppy or unresponsive. Wireless features pings linux-logoover 200 ms as it is, however, it’s not that what causes this ‘lag’.

For example, if you open an audio stream from the internet and then decide to browse some pages, you’ll notice that your connection behaves in a much more responsive manner.

One way to fix this issue is having a ‘ping’ command running in the background which probes a host (eg. Google.com) continuously. This keeps the connection ‘active’ as it always sends a few packets of data.

We’re going to be creating a script that will keep the connexion active.

To begin, get your favorite text editor and open up a random file in your system. I’m going to choose /opt/stayonline.sh for this tutorial.

$ sudo nano /opt/stayonline.sh

Copy/ past the following onto the file.

 

# /bin/bash 
while [1] do 
/bin/ping -c 3 -s 1 google.com 
sleep 30 
done

Save it and close. We now need to make this file executeable. Just run the following.

$ sudo chmod +x /opt/stayonline.sh

All we need to do now is set it up in such a way where it gets called every time a network connection is established.

Open up your /etc/ppp/ip-up file for editing. Add ‘/opt/stayonline.sh’ at the very end of it (Be careful not to remove anything from the file). Here’s a screenshot if you’re confused –

That’s it. Now each time your connection is active, it’ll maintain a constant ping command with a remote host and hopefully, make your online experience more fluid and responsive.

Learn about high speed business DSL options that may be available.

Usefull links: lffl.org