Reference Manual

HOW TO use a backup connection for non-stop Internet connectivity.

Introduction

Most Internet connection technologies are normally quite reliable, but in cases where maximum uptime is required, it may be useful to have NAT32 automatically switch to a backup Internet connection whenever the main Internet connection goes down. Conversely, when the main connection is working again, NAT32 should automatically switch back to using that connection.

Some users might have a DSL connection as their main connection and a Mobile Broadband adapter for backup purposes. The mobile connection can be designated as a backup connection that is to be used only if and when the DSL connection is down.

Checking Internet Connectivity

NAT32 can check Internet connectivity on a specified interface with the command:

checki ifn [ttl [ip]]

Argument ifn stands for the desired interface number to check, and the optional arguments are normally not needed.

The checki command determines connectivity by sending an ICMP Echo Request via interface ifn to machine ip on the Internet. However, because the TTL of that packet defaults to 2, the second gateway on the path to the destination will drop the packet and respond with an ICMP Time Exceeded packet. If your Internet connection is down, no such response will be received, and so the checki command will print the string ERROR: TIMEOUT.

Switching the Internet Connection

A fallback daemon can be started using the command:

startd fallback

The daemon will check the main Internet connection each minute, and if connectivity is lost, the backup connection is checked. If it is responding, the daemon switches the current Internet connection to the backup connection via the command:

setis b

It then continues checking the main connection and switches back to it when it is again operational.

Switching between Gateways

For networks with two gateways, a Tcl script can be used to check connectivity of the main gateway and switch to the auxiliary gateway if the main gateway is not functional. When connectivity for the main gateway is restored, the script can then switch back to the main gateway.

A sample script checkg.tcl is shown below:

#!tcl

#
# checkg.tcl - check the main gateway on the Primary interface.
#              Switch to aux  gateway if no response.
#              Switch to main gateway if response received.
#

set p [exec "get p"]

set r1 [exec "get router1"]
if {$r1 == "0.0.0.0"} {exit}

set r2 [exec "get router2"]
if {$r2 == "0.0.0.0"} {exit}

set status [exec "checki $p 1 $r1"]

if {$status == "ICMP Type 0 Code 0"} {
    exec "setgs $p main"
} else {
    exec "setgs $p aux"
}

To make NAT32 run the script regularly, add this line to your crontab file:

* * * * * checkg.tcl

The above command will check the main gateway on the Primary Internet interface p every minute and switch to the auxiliary gateway if the TIMEOUT response is received. Note how the script uses the setgs command to set the desired gateway.

SEE ALSO

Cron, Set Primary, Set Auxiliary, Set Backup, Set Gateway Select, Tcl
[Back]