[Previous] [Contents] [Index] [Next]

/etc/autoconnect

Automatic TCP/IP connection-configuration script

Name:

/etc/autoconnect

Description:

The /etc/autoconnect script is run when an application needs to establish a TCP/IP connection to a remote host. This file can be in any form (e.g. a shell script or an executable), and contains all of the necessary commands required to create the connection.

To activate the script, the environment variable AUTOCONNECT must be defined and set to 1.

If there's no route to a remote host (see route, ifconfig, netmanager, phlip or the options to npm-ttcpip.so), or there are no nameservers defined (see /etc/resolv.conf) and a hostname can't be resolved, the autoconnect script is run. The exit status of the script determines whether or not a retry is attempted:

Zero
The socket library attempts the action again.
Nonzero
It doesn't retry because the script failed.

One time you might use this feature is when you have a dialup ISP account for internet access. The ppp link is established only when an application needs to reach a host over the link. When the link is terminated depends on inactivity timeouts specified by the client or server, errors, or other events. The autoconnect script only launches commands to establish a connection; it doesn't terminate the connection.

Suppose that a host is configured with only the localhost interface, and no nameservers. You need to create a script:

pppd connect "/bin/chat -v -f /etc/chat" defaultroute \
+resconf 115200 updetach /dev/ser2

exit

The chat utility is used to dial the service provider. The important option here is the updetach option. This option daemonizes pppd after the PPP interface has been configured. This way, the script doesn't exit until the interface is configured. If an application attempts to resolve a hostname, the application blocks while a connection to an ISP is established, which provides a nameserver and a default route. When the script exits with a status of zero, the socket library retries and the application continues, assuming that the function succeeded. If an exit status of non-zero is returned, the socket library returns the original error to the application.

If you're using the Photon dialer to establish your connection, the script would look like this:

phdialer -a

exit

The -a option causes phdialer to autoconnect and daemonize itself when the interface is configured.

See also:

ifconfig, netmanager, npm-ttcpip.so, phdialer, phlip, pppd, route


[Previous] [Contents] [Index] [Next]