home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / mini / Leased-Line < prev    next >
Text File  |  1998-10-14  |  10KB  |  278 lines

  1.  
  2.                             LEASED LINE MINI HOWTO
  3.                                        
  4.    Rob van der Putten, rob@sput.dsl.nl
  5.    v1.2, 3 March 1998
  6.    
  7. What is a leased line
  8.  
  9.    Any fixed, that is permanent, point to point data communications link,
  10.    which is leased from a telco or similar organisation.
  11.    The leased line involves cables, such as twisted pair, coax or FDDI,
  12.    and may involve all sorts of other hardware such as (pupin) coils,
  13.    transformers, amplifiers and regenerators.
  14.    
  15.    This document deals with:
  16.           Configuring your modem and pppd to use a 2 wire twisted pair
  17.           leased line.
  18.           
  19.    This document does _NOT_ deal with:
  20.           SLIP, getting or installing pppd, synchronous data
  21.           communication, baseband modems.
  22.           
  23. Assumptions
  24.  
  25.    You should already have a working pppd on your system.
  26.    You also need Minicom or a similar program to configure your modems.
  27.    
  28. Modem
  29.  
  30.    A leased line is not connected to a telephone exchange and does not
  31.    provide DC power, dial tone, busy tone or ring signal. This means that
  32.    your modems are on their own and have to be able to deal with this
  33.    situation.
  34.    
  35.    You should have 2 identical _external_ modems supporting both leased
  36.    line and dumb mode. Make sure your modems can actually do this! Also
  37.    make sure your modem is properly documented.
  38.    You also need:
  39.      * 2 fully wired shielded RS232 cables. The shield should be
  40.        connected to the connector shell (not pin 1) at both ends (not at
  41.        one end).
  42.      * A RS232 test plug may be handy for test purposes.
  43.      * 2 RJ11 cords, one for each end of the leased line.
  44.      * A basic understanding of 'AT' commands.
  45.        
  46.   Modem Configuration
  47.   
  48.    Configure your modem at the highest possible speed; 57600 bps for 14k4
  49.    and 115200 bps for 28k8 or faster modems. Once the modem is in dumb
  50.    mode it will use the speed at witch it was configured.
  51.    Configure both your modem software (Minicom) and your modem to use the
  52.    following settings:
  53.      * Fixed baud rate (no auto baud)
  54.      * Hardware bidirectional RTS-CTS flow control (no x-on/x-off)
  55.      * 8 Bits, no parity, 1 stopbit
  56.      * The modem should produce the _TRUE_ DCD status (&C1)
  57.      * The modem should _NOT_ ignore the DCD status (&D2 or &D3)
  58.        
  59.    Check this with AT&V or AT&Ix (consult your modem documentation)
  60.    
  61.    Find out how to put your modem into dumb mode and, more importantly,
  62.    how to get it out of dumb mode; The modem can only be reconfigured
  63.    when it is not in dumb mode.
  64.    
  65.    Now configure your modem as follows;
  66.      * Reset on DTR toggle (&D3, this is sometimes a S register)
  67.      * Leased line mode (&L1 or &L2, consult your modem documentation)
  68.      * The remote modem auto answer (S0=1), the local originate (S0=0)
  69.      * Disable result codes (Q1, sometimes the dumb does this for you)
  70.      * Dumb mode (\D1 or %D1, this is sometimes a jumper)
  71.        In dumb mode the modem will ignore all AT commands (sometimes you
  72.        need to disable the ESC char as well).
  73.        
  74.    Write the configuration to non-volatile memory (&W).
  75.    
  76.   Test
  77.   
  78.    Now connect the modems to 2 computers using the RS232 cables and
  79.    connect the modems to each other using a RJ11 lead. Use a modem
  80.    program such as Minicom (Linux), procom or telix (DOS) on both
  81.    computers to test the modems.
  82.    You should be able to type text from one computer to the other and
  83.    vice versa. If one of the screens produces garbage check your com port
  84.    speed and other settings.
  85.    Now disconnect and reconnect the RJ11 cord. Wait for the connection to
  86.    reestablish itself. Disconnect and reconnect the RS232 cables, switch
  87.    the modems on and off, stop and restart minicom.
  88.    The modems should always reconnect at the highest possible speed (some
  89.    modems have speed indicator leds).
  90.    Check whether the modems actually ignores the ESC (+++) character. If
  91.    necessary disable the ESC character.
  92.    
  93.    If all of this works you may want to reconfigure your modems;
  94.    Switch off the sound at the remote modem (M0) and put the local modem
  95.    at low volume (L1).
  96.    
  97.   Examples
  98.   
  99.     Hi-Tech
  100.     
  101.    Originate (local):
  102.           ATL1&C1&D3&L2%D1&W&W1
  103.           
  104.    Answer (remote):
  105.           ATM0&C1&D3&L2%D1S0=1&W&W1
  106.           
  107.     Tron DF
  108.     
  109.    The ESC char should be disabled by setting S2 > 127;
  110.    
  111.    Originate:
  112.           ATL1&L1Q1&C1&D3S2=171\D1&W
  113.           
  114.    Answer:
  115.           ATM0&L2Q1&C1&D3S0=1S2=171\D1&W
  116.           
  117. PPPD
  118.  
  119.    You need a pppd (Point to Point Protocol Daemon) and a reasonable
  120.    knowledge of how it works. Consult the relevant RFC's or the Linux PPP
  121.    HOWTO if necessary.
  122.    Since you are not going to use a login procedure, you don't use
  123.    (m)getty and you do not need a (fake) user associated with the pppd
  124.    controlling your link. You are not going to dial so you don't need any
  125.    chat scripts either.
  126.    In fact, the modem circuit and configuration you have just build, are
  127.    rather like a null modem cable. This means you have to configure your
  128.    pppd the same way as you would with a null modem cable.
  129.    
  130.    For a reliable link, your setup should meet the following criteria;
  131.      * Shortly after booting your system, pppd should raise the DTR
  132.        signal in your RS232 port, wait for DCD to go up, and negotiate
  133.        the link.
  134.      * If the remote system is down, pppd should wait until it is up
  135.        again.
  136.      * If the link is up and then goes down, pppd should reset the modem
  137.        (it does this by dropping and then raising DTR), and then try to
  138.        reconnect
  139.      * If the quality of the link deteriorates too much, pppd should
  140.        reset the modem and then reestablish the link.
  141.      * If the process controlling the link, that is the pppd, dies, a
  142.        watchdog should restart the pppd.
  143.        
  144.   Configuration
  145.   
  146.    Suppose the modem is connected to COM2, the local IP address is
  147.    'Loc_Ip' and the remote IP address is 'Rem_Ip'. We want to use 576 as
  148.    our MTU.
  149.    The /etc/ppp/options.ttyS1 would now be:
  150.  
  151. crtscts
  152. mru 576
  153. mtu 576
  154. passive
  155. Loc_Ip:Rem_Ip
  156. -chap
  157. modem
  158. -pap
  159. persist
  160.  
  161.    So, if the local system is 192.168.1.1 and the remote system is
  162.    10.1.1.1, then /etc/options.ttyS1 on the local system would be:
  163.  
  164. crtscts
  165. mru 576
  166. mtu 576
  167. passive
  168. 192.168.1.1:10.1.1.1
  169. -chap
  170. modem
  171. -pap
  172. persist
  173.  
  174.    The options.ttyS1 on the remote system would be:
  175.  
  176. crtscts
  177. mru 576
  178. mtu 576
  179. passive
  180. 10.1.1.1:192.168.1.1
  181. -chap
  182. modem
  183. -pap
  184. persist
  185.  
  186.    The passive option limits the number of (re)connection attempts.
  187.    The persist option will keep pppd alive in case of a disconnect or
  188.    when it can't connect in the first place.
  189.    If you telnet a lot while doing filetransfers (FTP or webbrowsing) at
  190.    the same time, you might want to use a smaller MTU and MRU such as
  191.    296. This will make the remote system more responsive.
  192.    If you don't care much about telnetting during FTP, you could set the
  193.    MTU and MRU to 1500.
  194.    
  195.   Scripts
  196.   
  197.    >From the script which configures your networkcard
  198.    (/etc/init.d/network on Debian systems) the script
  199.    /usr/local/sbin/test-Rem_Host-ppp is called (substitute 'Rem_Host'
  200.    with the remote hosts name). This script checks whether the remote
  201.    interface exists and will try to start the pppd if it doesn't. It
  202.    starts with a sleep, making sure the boot process configures the COM
  203.    ports first.
  204.  
  205. #!/bin/bash
  206. /usr/bin/sleep 30
  207.  
  208. while true
  209. do
  210.      if ! ( /sbin/ifconfig | grep Rem_Ip > /dev/null )
  211.      then
  212.           # PPP gone
  213.                logger "Rem_Host PPP gone ; restarted"
  214.                /usr/local/sbin/PRem_Host.sh &
  215.      fi
  216.      sleep 300
  217. done
  218.  
  219.    You could of course, remove the 'sleep 300' and the do-done loop and
  220.    start the whole thing from cron instead.
  221.    Some people run pppd from /etc/inittab, but I never tested this.
  222.    
  223.    The default route can be set with the defaultroute option or with a
  224.    /etc/ppp/ip-up script;
  225.  
  226. #!/bin/bash
  227. case $2 in
  228.      /dev/ttyS1)
  229.           /sbin/route add -net 0.0.0.0 gw Rem_Ip netmask 0.0.0.0
  230.           ;;
  231. esac
  232.  
  233.    Ip-up can also be used to sync your clock using netdate.
  234.    
  235.    Of course the route set in ip-up is not necessarily the default route.
  236.    Your ip-up sets the route to the remote network while the ip-up script
  237.    on the remote system sets the route to your network. If your network
  238.    is 192.168.1.0 and your ppp interface 192.168.1.1, the ip-up script on
  239.    the remote machine looks like this;
  240.  
  241. #!/bin/bash
  242. case $2 in
  243.    /dev/ttyS1)
  244.       /sbin/route add -net 192.168.1.0 gw 192.168.1.1 netmask 255.255.255.0
  245.       ;;
  246. esac
  247.  
  248.    The 'case $2' and '/dev/ttyS1)' bits are there in case you use more
  249.    than one ppp link. Ip-up will run each time a link comes up, but only
  250.    the part between '/dev/ttySx)' and ';;' will be executed, setting the
  251.    right route for the right ttyS.
  252.    You can find more about routing in the NET-3-HOWTO section on routing
  253.    
  254.    Though the persist option should make this superfluous, the pppd can
  255.    also be restarted using ip-down;
  256.  
  257. #!/bin/bash
  258. case $s in
  259.      /dev/ttyS1)
  260.           /usr/bin/sleep 30
  261.           /usr/local/sbin/PRem_Host.sh &
  262.           ;;
  263. esac
  264.  
  265.    The pppd is started using the /usr/local/sbin/PRem_Host.sh script
  266.  
  267. #!/bin/bash
  268. ( /usr/sbin/pppd /dev/ttyS1 115200 crtscts Loc_Ip:Rem_Ip persist ) &
  269.  
  270.    I suppose some of the command line options make some of the options
  271.    statements superfluous. Well, better safe then sorry.
  272.    
  273.   Test
  274.   
  275.    Test the whole thing just like the modem test.
  276.    If it works, get on your bike and bring the remote modem to the remote
  277.    side of your link.
  278.