dip - handle dialup IP connections
The first form interprets scriptfile to dial out and open an IP connection (see DIALOUT MODE below).
The -t option runs dip interactively (see COMMAND MODE below). This is most useful while gathering data to set up a chat script.
dip -i handles incoming connections (see DIALIN MODE below). diplogin is equivalent to dip -i, and diplogini is equivalent to dip -i -a. These are mainly for use with versions of login(1) that do not pass command line parameters to the shell program.
dip -k kills an existing dip process, closing the connection.
The following is a sample taken from a live session:
$dip -t DIP: Dialup IP Protocol Driver version 3.3.7n-uri (7 Mar 95) Written by Fred N. van Kempen, MicroWalt Corporation. DIP> _
The possible commands are listed below (see COMMANDS). Note particularly the help command. Each command displays a usage message if it is invoked incorrectly. Just experiment a little to get the feel of it, and have a look at the sample script file, which also uses this command language (see EXAMPLES).
suunet:ij/SMxiTlGVCo:1004:10:UUNET:/tmp:/usr/sbin/diplogin
When user suunet logs in, the login(1) program sets the home directory to /tmp and executes the diplogin program. diplogin should be a symbolic link to dip, which means that dip must run in input mode. dip then tries to locate the name of the logged in user (i.e. the name corresponding to its current user id, as returned by the getuid(2) system call) in its database file. An optional single argument to the dip program in this mode can be the username that must be used in this lookup, regardless the current user id.
dip now scans /etc/diphosts for an entry for the given user name. This file contains lines of text (much like the standard password file). Any line starting with # is a comment. Otherwise, each line has seven colon-separated items, in the format
user : password : remote host : local host : netmask :
comments : protocol,MTU
The first field of a line is the user name, which we must match.
The second field can contain an encrypted password. If this field is non-null, dip displays the prompt "External security password:", and the reply must match the password in this field. If this field is "s/key" (check the value of SKEY_TOKEN in dip.h) and dip was compiled with S/Key enabled, then S/Key authentication will take place (see README.SKEY in the dip source directory).
The third field contains the name (or raw IP address) of the remote host. If a host name is given, the usual address resolving process is started, using either a name server or a local hosts file.
The fourth field contains the name (or raw IP address) of the local host. If a host name is given, it's resolved, just like the remote host name in the third field.
The fifth field contains the netmask in decimal dotted notation (like 255.255.255.0). If empty, 255.255.255.0 is used by default.
The sixth field may contain any text; it is not used by dip.
Finally, the seventh field of a line contains a mixture of comma-separated flags. Possible flags are:
SLIP
to indicate we must use the SLIP protocol.
CSLIP
to indicate Compressed SLIP protocol.
PPP
to indicate we must use the PPP protocol.
number
which gives the MTU parameter of this connection.
Please note: my experience shows smaller blocks (i.e. smaller MTU) work better. You *can* define MTU 1500, but it won't vouch for your sanity.
After finding the correct line, dip puts the terminal line into RAW mode, and asks the system networking layer to allocate a channel of the desired protocol. Finally, if the channel is activated, it adds an entry to the system's routing table to make the connection work.
dip now goes into an endless loop of sleeping, which continues until the connection is physically aborted (i.e. the line is dropped). At that time, dip removes the entry it made in the system's routing table, and releases the protocol channel for re-use. It then exits, making room for another session.
chatkey CONNECT 1would duplicate one of the existing entries.
0 OK
1 CONNECT
2 ERROR
3 BUSY
4 NO CARRIER
5 NO DIALTONE
You can change or add to these with the chatkey command.
DIP> help
DIP knows about the following commands:
beep bootp break chatkey config databits
dec default dial echo flush get
goto help if inc init mode
modem netmask onexit parity password proxyarp
print port quit reset securidf securid
send shell sleep speed stopbits term
timeout wait
DIP> _
$variable op constantwhere op is one of: == != < > <= >=.
# # diphosts This file describes a number of name-to-address # mappings for the DIP program. It is used to determine # which host IP address to use for an incoming call of # some user. # # Version: @(#)diphosts 1.20 05/31/94 # # Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> # Modified: Uri Blumenthal <uri@watson.ibm.com> # # name : pwd : hostname : local server: netmask: comments : protocol,mtu #================================================== sbonjovi::bonjovi:server1:netmask:MicroWalt "bonjovi" SLIP:SLIP,296 sroxette::roxette:server2:netmask:MicroWalt "roxette" SLIP:CSLIP,296 stephen:s/key:tuin:server3:netmask:S/Key Authenticated login:CSLIP,296 # End of diphosts.
A chat script should look something like this:
# # sample.dip Dialup IP connection support program. # # Version: @(#)sample.dip 1.40 07/20/93 # # Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> # main: # First of all, set up our name for this connection. # I am called "uwalt.hacktic.nl" (== 193.78.33.238) get $local uwalt.hacktic.nl # Next, set up the other side's name and address. # My dialin machine is called 'xs4all.hacktic.nl' (== 193.78.33.42) get $remote xs4all.hacktic.nl # Set netmask on sl0 to 255.255.255.0 netmask 255.255.255.0 # Set the desired serial port and speed. port cua02 speed 38400 # Reset the modem and terminal line. # This seems to cause trouble for some people! reset # Note! "Standard" pre-defined "errlvl" values: # 0 - OK # 1 - CONNECT # 2 - ERROR # 3 - BUSY # 4 - NO CARRIER # 5 - NO DIALTONE # # You can change these with the chatkey command # Prepare for dialing. send ATQ0V1E1X4\r wait OK 2 if $errlvl != 0 goto modem_trouble dial 555-1234567 if $errlvl != 1 goto modem_trouble # We are connected. Login to the system. login: sleep 2 wait ogin: 20 if $errlvl != 0 goto login_error send MYLOGIN\n wait ord: 20 if $errlvl != 0 goto password_error send MYPASSWD\n loggedin: # We are now logged in. wait SOMETEXT 15 if $errlvl != 0 goto prompt_error # Set up the SLIP operating parameters. get $mtu 296 # Ensure "route add -net default xs4all.hacktic.nl" will be done default # Say hello and fire up! done: print CONNECTED $locip ---> $rmtip mode CSLIP goto exit prompt_error: print TIME-OUT waiting for SLIPlogin to fire up... goto error login_trouble: print Trouble waiting for the Login: prompt... goto error password_error: print Trouble waiting for the Password: prompt... goto error modem_trouble: print Trouble occurred with the modem... error: print CONNECT FAILED to $remote quit 1 exit: exit
This script causes dip to dial up a host, log in, and get a SLIP interface channel going (in the same manner as with incoming connections). When all is set up, it simply goes into the background and waits for a hangup (or just a lethal signal), at which it hangs up and exits.
/etc/passwd /etc/diphosts /etc/rc.dip (for example)
Fred N. van Kempen <waltje@uwalt.nl.mugnet.org>,
Uri Blumenthal <uri@watson.ibm.com>,
Paul Cadach <paul@paul.east.alma-ata.su>,
John Edwards <pje120@cs.usask.ca>,
Olaf Kirch <okir@monad.sub.de>,
Pauline Middelink <middelin@calvin.iaf.nl>,
Paul Mossip <mossip@vizlab.rutgers.edu>,
Bill Reynolds,
Jim Seagrave <jes@grendel.demon.co.uk>,
Stephen Shortland <stephen@cork.cig.mot.com>,
Daniel Suman,
Jeff Uphoff <juphoff@aoc.nrao.edu>
|
Закладки на сайте Проследить за страницей |
Created 1996-2025 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |