Purpose
This is a little script which keeps the Internet connection up using 2 alternate and independant ISPs/connections.
Because the main Internet connection (ISP, local line, backbone, peering, whatever) might fail, it will
- dial a backup connection in case the main link goes down,
- constantly try to re-establish the main connection while the backup connection is up,
- close the backup, after the main connection came back online.
It tries to be careful while doing that, to allow unattended operation.
It is intended for a computer at home, which must stay connected automatically, to be accessible remotely during a travel of its owner, even in the case of problems with the (main) ISP.
Assumptions
I wrote it for my case, and it thus assumes the following:
- Unix/Linux operating system (
ifconfig
, route
, ping
, scripts)
- There is a preferred (price, speed, whatever) ISP/link and a backup ISP/link.
The backup is likely to be working even in case of the failure of the main link, i.e. they are fairly independant.
(T-Online over ADSL vs. Arcor over ISDN in my case.)
- Each link is represented by its own OS network interface (
ppp0
, ippp0
, ippp1
, etc.) and can be brought online/offline by a single command.
- The main link is usually up and working before J-Offline is started.
In case of a failure, the script for the main link might try by itself for a certain time to reconnect and if that fails, the link goes down permanently unless brought up e.g. manually or by J-Offline.
- There are only 2 alternate Internet connections: in case the backup fails as well, I accept downtime and just try to bring the main link back online. I don't try to redial the backup using J-Offline (maybe the backup link scripts do that by themselves, though), nor do I try tertiary connections.
- The user/admin of J-Offline is moderately comfortable with changing simple values like the amount of seconds to wait and the servers to ping right in the source code.
There is no configuration file.
However, I think I wrote it so that changing the logic of the program is faily easy, so changing most of the above assumptions should be possible for anybody knowing the basics of Java (or any language roughly like C).
If somebody wants to adopt / extend / generalize the program, feel free to ask me.
Usage
- You need a Java VM, compatible with JRE 1.4. (Maybe only 1.1, if you hack the source by reducing functionality.)
- Download the source
- Edit
- the network interface names (at the top of
JOffline.java
)
- the link start/shurtdown scripts to call (in
ifaceDialClose()
)
- the commands to invoke after the IP changed (in
ipChanged()
)
- the amount of time to wait at various points (in
JOffline.java
)
- the servers to ping (in
internetWorks()
)
- Compile it using
javac org/bucksch/tools/joffline/JOffline.java
- Run it using
java org.bucksch.tools.joffline.JOffline
under a user account allowed to run the link start/shutdown scripts
Name
Why is it called J-Offline? 2 reasons:
- T-Online, owning almost all of the German DSL market, is dubbed T-Offline, and its unreliability is the major reason for the existance of this program.
To avoid confusion of their marketdroids and others, I replaced "T" with "J".
- It prevents going offline, and is written in "J"ava. (Ops, should I have said "the Java language"? Hm, no, thanks.)