![]() |
Reference Manual |
HOW TO use fallback connections for non-stop Internet connectivity.
Introduction
Most Internet connection technologies are normally quite reliable, but in cases where 100% uptime is required, it may be useful to have NAT32 automatically switch to another connection whenever your main Internet connection goes down. Conversely, when the main connection is working again, NAT32 should automatically switch back to using that connection.
Many DSL service providers have a Dialup Modem service that can be used when the DSL service is down. Some users may even have two or more DSL or Cable Modem connections, and one of those connections can be designated as a fallback connection that is to be used only if and when the main Internet 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: TIMEOUT.
Dialing a Fallback Connection
A Tcl script can be used to check connectivity and dial a fallback connection if your main connection is down. When connectivity for your main connection is restored, the script can then hangup the backup connection.
A sample script is shown below:
#!tcl
#
# checki - check a specified interface for Internet connectivity.
# Dial a specified connection if no connectivity is available.
# Hangup the specified connection when connectivity is restored.
#
if {$argc != 2} {
error "Usage: checki ifn connection"
}
set ifn [lindex $argv 0]
set connection [lindex $argv 1]
set status [exec "checki $ifn"]
if {$status == "ICMP Type 11 Code 0"} {
set status [exec "hangup $connection"]
} else {
set status [exec "dial $connection"]
}
echon ""
Copy the above code to a file checki.tcl in your NAT32 directory.
Switching DSL Connections
A Tcl script can be used to check connectivity of a specified connection and switch to another connection if your main connection is down. When connectivity for your main connection is restored, the script can then switch back to the main connection.
A sample script is shown below:
#!tcl
#
# checkb - check a specified interface for Internet connectivity.
# Switch interfaces if the first one is down.
# Switch back when connectivity is restored.
#
if {$argc != 2} {
error "Usage: checkb ifn backup_ifn"
}
set ifn [lindex $argv 0]
set backup [lindex $argv 1]
set status [exec "checki $ifn"]
if {$status == "ICMP Type 11 Code 0"} {
set status [exec "setp $ifn"]
} else {
set status [exec "setp $backup"]
}
echon ""
Copy the above code to a file checkb.tcl in your NAT32 directory.
Regular Connectivity Checks
To make NAT32 run the script regularly, add this line to your crontab file:
* * * * * checki.tcl 1 MyConnection
The above command will check interface 1 every minute and dial MyConnection if the TIMEOUT response is received.
Alternatively, add this line to your crontab file:
* * * * * checkb.tcl 1 2
The above command will check interface 1 every minute and switch to interface 2 if the TIMEOUT response is received.
Be sure to start the CRON daemon in your user.txt file. Also include this command in that file:
set backup 1
Cron, Dial, Hangup, Set Primary, Tcl