This commit is contained in:
gferg 2001-07-20 18:04:51 +00:00
parent e6902d7c1b
commit 7468a02307
1 changed files with 53 additions and 53 deletions

View File

@ -8,21 +8,21 @@
Serial Laplink HOWTO
</title>
<date>
July 2001
July 2001
</date>
<author>
<firstname>Willem J.</firstname><surname>Atsma</surname>
</author>
<revhistory>
<revision>
<revnumber>v2.0</revnumber>
<date>2001-07-01</date>
<authorinitials>wa</authorinitials>
</revision>
</revhistory>
<revhistory>
<revision>
<revnumber>v2.1</revnumber>
<date>2001-07-20</date>
<authorinitials>wja</authorinitials>
</revision>
</revhistory>
<abstract>
<para>
How to create a serial connection between two computers? This document details how to setup a &ldquo;laplink&rdquo; connection between two computers. Having had a bit of trouble getting the information to get this to work myself, this document should make it easy for you.
How to create a serial connection between two computers? This document details how to setup a <quote>laplink</quote> connection between two computers. Having had a bit of trouble getting the information to get this to work myself, this document should make it easy for you.
</para>
</abstract>
</artheader>
@ -31,7 +31,7 @@
Introduction
</title>
<para>
This very brief document describes how to set up a serial &ldquo;laplink&rdquo; connection between two Linux machines or a Linux and a Windows machine. The serial link consists of a &ldquo;null-modem&rdquo; cable and a communication protocol: PPP. I use such a setup to send files to and from my laptop; it can also quite nicely be used to install new software from a cd-rom when a laptop doesn't have one. I had more trouble than I should have had when setting up my serial laplink. Hopefully this document will solve your problems in one go (the ones to do with the serial cable at any rate).
This very brief document describes how to set up a serial <quote>laplink</quote> connection between two Linux machines or a Linux and a Windows machine. The serial link consists of a <quote>null-modem</quote> cable and a communication protocol: PPP. I use such a setup to send files to and from my laptop; it can also quite nicely be used to install new software from a cd-rom when a laptop doesn't have one. I had more trouble than I should have had when setting up my serial laplink. Hopefully this document will solve your problems in one go (the ones to do with the serial cable at any rate).
</para>
<para>
Both server and client side of the setup I will describe could be either a Linux machine or a different operating system, as long as it supports the PPP protocol on a null-modem. The MS Windows implementation, as it turns out, is slightly different from standard, requiring some special attention. This document has two main sections. The first describes how to setup the server side. This is the main station with a serial port dedicated to a PPP connection. Alternatively the connection can be started when needed from the command line. The second part describes the configuration of the client that connects to the server to retrieve or upload files.
@ -52,10 +52,10 @@
Configure pppd
</title>
<para>
The communication will be through a serial port. On the server we will connect through the &ldquo;/dev/ttyS1&rdquo; (COM2 in DOS/Windows) device. On your computer this may be different and you should modify the examples below accordingly. I force authentication because I use the configuration to provide a way to access files on a file server for a group of people. After logon they can use the Samba file shares to copy files to and from a laptop. If you are not concerned with security you can comment out the relevant options.
The communication will be through a serial port. On the server we will connect through the <quote>/dev/ttyS1</quote> (COM2 in DOS/Windows) device. On your computer this may be different and you should modify the examples below accordingly. I force authentication because I use the configuration to provide a way to access files on a file server for a group of people. After logon they can use the Samba file shares to copy files to and from a laptop. If you are not concerned with security you can comment out the relevant options.
</para>
<para>
PPP (Point-to-Point Protocol) communication provides TCP/IP across a serial link. In other words: when you want to do internet-based browsing through a modem, you are likely to be using it. In Linux PPP is implemented by the PPP daemon &ldquo;pppd&rdquo;. Its configuration is done through files in the &ldquo;/etc/ppp/&rdquo; directory. We will be using the following files:
PPP (Point-to-Point Protocol) communication provides TCP/IP across a serial link. In other words: when you want to do internet-based browsing through a modem, you are likely to be using it. In Linux PPP is implemented by the PPP daemon <quote>pppd</quote>. Its configuration is done through files in the <quote>/etc/ppp/</quote> directory. We will be using the following files:
</para>
<para>
/etc/ppp/options contains all general options for PPP connections
@ -64,7 +64,7 @@
<varlistentry>
<term>
/etc/ppp/options.ttyS1
</term><listitem><para>contains PPP options specific to connections through &ldquo;/dev/ttyS1&rdquo;
</term><listitem><para>contains PPP options specific to connections through <quote>/dev/ttyS1</quote>
</para>
</listitem>
</varlistentry>
@ -84,7 +84,7 @@
</varlistentry>
</variablelist>
<para>
The &ldquo;/etc/ppp/options&rdquo; file should look more or less like this:
The <quote>/etc/ppp/options</quote> file should look more or less like this:
</para>
<programlisting>
@ -97,26 +97,26 @@
]]><![ CDATA [# as well, then comment auth and login out and move them to
]]><![ CDATA [# /etc/options.ttySn
]]><![ CDATA [auth
]]><![ CDATA [login
]]><![ CDATA [login
]]> </programlisting>
<para>
The lines starting with a &ldquo;&num;&rdquo; are comments. The &ldquo;lock&rdquo; parameter indicates that a lock file will be created to ensure exclusive access to the serial device, the &ldquo;auth&rdquo; parameter indicates that the client will need to authenticate itself, and &ldquo;login&rdquo; tells pppd to use the system user names and passwords for authentication.
The lines starting with a <quote>&num;</quote> are comments. The <quote>lock</quote> parameter indicates that a lock file will be created to ensure exclusive access to the serial device, the <quote>auth</quote> parameter indicates that the client will need to authenticate itself, and <quote>login</quote> tells pppd to use the system user names and passwords for authentication.
</para>
<para>
Note that pppd will still check the &ldquo;/etc/ppp/pap-secrets&rdquo; file for user name and password information. A special, single line entry makes that pppd will only use the system's user information. The &ldquo;/etc/ppp/pap-secrets&rdquo; file looks as follows:
Note that pppd will still check the <quote>/etc/ppp/pap-secrets</quote> file for user name and password information. A special, single line entry makes that pppd will only use the system's user information. The <quote>/etc/ppp/pap-secrets</quote> file looks as follows:
</para>
<programlisting>
<![ CDATA [#/etc/ppp/pap-secrets
]]><![ CDATA [# Secrets for authentication using PAP
]]><![ CDATA [# client server secret IP addresses
]]><![ CDATA [* * &ldquo;&rdquo; ppp_laplink_client
]]><![ CDATA [* * "" ppp_laplink_client
]]> </programlisting>
<para>
This allows any machine with the IP address &ldquo;ppp_laplink_client&rdquo; to connect to the server, without using a password (you can see why it is handy to have the ppp_laplink entries in your /etc/hosts file). The &ldquo;login&rdquo; parameter in the &ldquo;/etc/ppp/options&rdquo; file, however, makes that the user name and password supplied by the client for authorization have to match the &ldquo;/etc/ppp/pap-secrets&rdquo; file <emphasis>as well as</emphasis> the system user name and password, so the connection will only succeed after a valid user name and password are provided.
This allows any machine with the IP address <quote>ppp_laplink_client</quote> to connect to the server, without using a password (you can see why it is handy to have the ppp_laplink entries in your /etc/hosts file). The <quote>login</quote> parameter in the <quote>/etc/ppp/options</quote> file, however, makes that the user name and password supplied by the client for authorization have to match the <quote>/etc/ppp/pap-secrets</quote> file <emphasis>as well as</emphasis> the system user name and password, so the connection will only succeed after a valid user name and password are provided.
</para>
<para>
Options specific to the serial line you are connecting with are placed in &ldquo;/etc/ppp/options.ttySn&rdquo;, where n is the number of the serial device. My server uses &ldquo;/dev/ttyS1&rdquo;, so the options go into... &ldquo;/etc/ppp/options.ttyS1&rdquo;.
Options specific to the serial line you are connecting with are placed in <quote>/etc/ppp/options.ttySn</quote>, where n is the number of the serial device. My server uses <quote>/dev/ttyS1</quote>, so the options go into... <quote>/etc/ppp/options.ttyS1</quote>.
</para>
<programlisting>
@ -139,19 +139,19 @@
]]><![ CDATA [#login
]]><![ CDATA [#use PAP, not CHAP for authentication
]]><![ CDATA [require-pap
]]><![ CDATA [115200
]]><![ CDATA [115200
]]> </programlisting>
<para>
All these options are well described in the pppd man page; a few of the key ones are explained with comments in the file. The &ldquo;crtscts&rdquo; parameter tells pppd to use hardware flow control. This is recommended because it is the fastest. Alternatively you could specify &ldquo;xonxoff&rdquo; to use software-based flow control - you would specify this if your null modem cable doesn't connect the RTS/CTS lines (unlikely if you bought your cable in the store). &ldquo;115200&rdquo; specifies the data transmission rate - if you have trouble connecting you might want to try with a lower speed. You can find valid speed settings in the termios manual page, although your hardware will limit the baud rate. Choosing an invalid speed setting will elicit an error message from the pppd daemon and apparently it then reverts to some default value.
All these options are well described in the pppd man page; a few of the key ones are explained with comments in the file. The <quote>crtscts</quote> parameter tells pppd to use hardware flow control. This is recommended because it is the fastest. Alternatively you could specify <quote>xonxoff</quote> to use software-based flow control - you would specify this if your null modem cable doesn't connect the RTS/CTS lines (unlikely if you bought your cable in the store). <quote>115200</quote> specifies the data transmission rate - if you have trouble connecting you might want to try with a lower speed. You can find valid speed settings in the termios manual page, although your hardware will limit the baud rate. Choosing an invalid speed setting will elicit an error message from the pppd daemon and apparently it then reverts to some default value.
</para>
<para>
Note that &ldquo;auth&rdquo; and &ldquo;login&rdquo; options are commented out here, because they were specified in the general options file. If you also use your computer to dial into an ISP, you will want to specify them here rather than in &ldquo;/etc/ppp/options&rdquo;, or you will be asking your ISP to authorize itself when you dial in and that probably won't succeed. The reason why they are not specified in this file by default is because if you have other incoming PPP connections now or in the future, you want to make sure they are always authenticated. Remember that the &ldquo;pap-secrets&rdquo; as presented here gives zero protection.
Note that <quote>auth</quote> and <quote>login</quote> options are commented out here, because they were specified in the general options file. If you also use your computer to dial into an ISP, you will want to specify them here rather than in <quote>/etc/ppp/options</quote>, or you will be asking your ISP to authorize itself when you dial in and that probably won't succeed. The reason why they are not specified in this file by default is because if you have other incoming PPP connections now or in the future, you want to make sure they are always authenticated. Remember that the <quote>pap-secrets</quote> as presented here gives zero protection.
</para>
<para>
Finally, the &ldquo;ppp_laplink_server:ppp_laplink_client&rdquo; entry specifies the local and remote IP address after the link is up. You can use actual IP numbers here (e.g. 192.168.0.1:192.168.1.1), or entries from the &ldquo;/etc/hosts&rdquo; file, like I have done. The nice thing of doing the latter is that you can use the names to refer to these links later. I also recommend you use IP numbers like the ones I used (192.168.0.1:192.168.1.1). These addresses are set aside for local networks and don't exist on the internet, so you are avoiding possible conflicts. After the link is up, the client can refer to the server with the IP address of ppp_laplink_server (192.168.0.1) and the server refers to the client with ppp_laplink_client (192.168.1.1).
Finally, the <quote>ppp_laplink_server:ppp_laplink_client</quote> entry specifies the local and remote IP address after the link is up. You can use actual IP numbers here (e.g. 192.168.0.1:192.168.1.1), or entries from the <quote>/etc/hosts</quote> file, like I have done. The nice thing of doing the latter is that you can use the names to refer to these links later. I also recommend you use IP numbers like the ones I used (192.168.0.1:192.168.1.1). These addresses are set aside for local networks and don't exist on the internet, so you are avoiding possible conflicts. After the link is up, the client can refer to the server with the IP address of ppp_laplink_server (192.168.0.1) and the server refers to the client with ppp_laplink_client (192.168.1.1).
</para>
<para>
You could use different entries in &ldquo;/etc/ppp/pap-secrets&rdquo; to only allow select users access. I am using the PAP protocol for authentication; you could use CHAP if you'd like - the setup is much the same, using the &ldquo;chap-secrets&rdquo; file. For these and other options you can consult the man pages and the documentation mentioned at the bottom.
You could use different entries in <quote>/etc/ppp/pap-secrets</quote> to only allow select users access. I am using the PAP protocol for authentication; you could use CHAP if you'd like - the setup is much the same, using the <quote>chap-secrets</quote> file. For these and other options you can consult the man pages and the documentation mentioned at the bottom.
</para>
</sect2>
<sect2>
@ -159,21 +159,21 @@
A getty-like installation of pppd
</title>
<para>
You can have the PPP daemon (pppd) start when you boot the system and have it monitor the serial line of your choice. An elegant way of achieving this is to edit the &ldquo;/etc/inittab&rdquo; file. This file contains information for initializing the system. Add the following to this file:
You can have the PPP daemon (pppd) start when you boot the system and have it monitor the serial line of your choice. An elegant way of achieving this is to edit the <quote>/etc/inittab</quote> file. This file contains information for initializing the system. Add the following to this file:
</para>
<programlisting>
<![ CDATA [# Start pppd for the serial laplink.
]]><![ CDATA [pd:2345:respawn:/usr/sbin/pppd /dev/ttyS1 nodetach
]]><![ CDATA [pd:2345:respawn:/usr/sbin/pppd /dev/ttyS1 nodetach
]]> </programlisting>
<para>
This reads as follows: for runlevels 2, 3, 4 and 5 start &ldquo;/usr/sbin/pppd /dev/ttyS1 nodetach&rdquo; and if it dies (at the end of a connection) respawn (start a new one). The &ldquo;nodetach&rdquo; option makes that pppd stays connected to the terminal that started it, rather than forking and exiting. This option is necessary because the &ldquo;init&rdquo; process would respawn a new one immediately otherwise. Other entries in the inittab file specify getty processes to run on serial terminals (tty's); their initialization looks a lot like this one.
This reads as follows: for runlevels 2, 3, 4 and 5 start <quote>/usr/sbin/pppd /dev/ttyS1 nodetach</quote> and if it dies (at the end of a connection) respawn (start a new one). The <quote>nodetach</quote> option makes that pppd stays connected to the terminal that started it, rather than forking and exiting. This option is necessary because the <quote>init</quote> process would respawn a new one immediately otherwise. Other entries in the inittab file specify getty processes to run on serial terminals (tty's); their initialization looks a lot like this one.
</para>
<para>
To activate this new configuration type:
</para>
<programlisting>
<![ CDATA [[root@griis /root]# /sbin/init q
<![ CDATA [[root@griis /root]# /sbin/init q
]]> </programlisting>
</sect2>
<sect2>
@ -187,7 +187,7 @@
<![ CDATA [/usr/sbin/pppd /dev/ttyS1 nodetach
]]> </programlisting>
<para>
at the command line. The &ldquo;nodetach&rdquo; option is not really necessary, but it makes it easy to kill the connection by pressing &ldquo;ctrl-c&rdquo;.
at the command line. The <quote>nodetach</quote> option is not really necessary, but it makes it easy to kill the connection by pressing <quote>ctrl-c</quote>.
</para>
</sect2>
<sect2>
@ -195,21 +195,21 @@
Serving MS Windows clients
</title>
<para>
Unfortunately the MS Windows implementation is not quite standard. Before initiating the PPP connection it requires the exchange of the text strings &ldquo;CLIENT&rdquo; (from the client) and &ldquo;CLIENTSERVER&rdquo; (from the server). To accommodate a Windows client the following line has to be added to the &ldquo;/etc/ppp/options.ttyS1&rdquo; file:
Unfortunately the MS Windows implementation is not quite standard. Before initiating the PPP connection it requires the exchange of the text strings <quote>CLIENT</quote> (from the client) and <quote>CLIENTSERVER</quote> (from the server). To accommodate a Windows client the following line has to be added to the <quote>/etc/ppp/options.ttyS1</quote> file:
</para>
<programlisting>
<![ CDATA [connect 'chat -v -f /etc/ppp/scripts/winclient.chat'
<![ CDATA [connect 'chat -v -f /etc/ppp/scripts/winclient.chat'
]]> </programlisting>
<para>
Then create the scripts directory and the chat file &ldquo;/etc/ppp/scripts/winclient.chat&rdquo;:
Then create the scripts directory and the chat file <quote>/etc/ppp/scripts/winclient.chat</quote>:
</para>
<programlisting>
<![ CDATA [TIMEOUT 3600
]]><![ CDATA [CLIENT CLIENTSERVER\c
]]><![ CDATA [CLIENT CLIENTSERVER\c
]]> </programlisting>
<para>
The connect option allows you to specify a program to deal with the string exchange before the connection. Usually the &ldquo;chat&rdquo; program is used for this; check the manual for more details. The given script deals with the Windows connection issue. You don't need it when connecting a Linux box.
The connect option allows you to specify a program to deal with the string exchange before the connection. Usually the <quote>chat</quote> program is used for this; check the manual for more details. The given script deals with the Windows connection issue. You don't need it when connecting a Linux box.
</para>
</sect2>
</sect1>
@ -218,15 +218,15 @@
On the client side
</title>
<para>
After having configured the server, the client is easy. The &ldquo;/etc/ppp/options&rdquo; file has a single entry:
After having configured the server, the client is easy. The <quote>/etc/ppp/options</quote> file has a single entry:
</para>
<programlisting>
<![ CDATA [#/etc/ppp/options
]]><![ CDATA [lock
]]><![ CDATA [lock
]]> </programlisting>
<para>
The serial port on my client is &ldquo;/dev/ttyS0&rdquo; (COM1), so I also have to create a &ldquo;/etc/ppp/options.ttyS0&rdquo; file:
The serial port on my client is <quote>/dev/ttyS0</quote> (COM1), so I also have to create a <quote>/etc/ppp/options.ttyS0</quote> file:
</para>
<programlisting>
@ -235,23 +235,23 @@
]]><![ CDATA [crtscts
]]><![ CDATA [local
]]><![ CDATA [user zaphod
]]><![ CDATA [noauth
]]><![ CDATA [noauth
]]> </programlisting>
<para>
Only a few new options in this file. Note that the speed on server and client has to be the same (here it is 115200). With &ldquo;user zaphod&rdquo; the client user name is specified. This user name has to correspond to an entry in the &ldquo;/etc/ppp/pap-secrets&rdquo; file of the client and has to be a valid user name on the server. The &ldquo;noauth&rdquo; option specifies that the peer (server) does not have to authenticate itself to the client.
Only a few new options in this file. Note that the speed on server and client has to be the same (here it is 115200). With <quote>user zaphod</quote> the client user name is specified. This user name has to correspond to an entry in the <quote>/etc/ppp/pap-secrets</quote> file of the client and has to be a valid user name on the server. The <quote>noauth</quote> option specifies that the peer (server) does not have to authenticate itself to the client.
</para>
<para>
The last bit: setting the client name (user name) and its secret (password) in the &ldquo;/etc/ppp/pap-secrets&rdquo; file:
The last bit: setting the client name (user name) and its secret (password) in the <quote>/etc/ppp/pap-secrets</quote> file:
</para>
<programlisting>
<![ CDATA [#/etc/ppp/pap-secrets
]]><![ CDATA [# Secrets for authentication using PAP
]]><![ CDATA [# client server secret IP addresses
]]><![ CDATA [zaphod * gargleBlaster
]]><![ CDATA [# client server secret IP addresses
]]><![ CDATA [zaphod * gargleBlaster
]]> </programlisting>
<para>
So user &ldquo;zaphod&rdquo; uses a password &ldquo;gargleBlaster&rdquo;, which should get him into the system. Note that these files contain sensitive information, make sure you set the permissions on them correctly.
So user <quote>zaphod</quote> uses a password <quote>gargleBlaster</quote>, which should get him into the system. Note that these files contain sensitive information, make sure you set the permissions on them correctly.
</para>
<sect2>
<title>
@ -269,22 +269,22 @@
Connecting to an MS Windows server
</title>
<para>
What if you want to make a connection to a Windows server? Again we'll need the &ldquo;connect&rdquo; option and a chat script. Add the following line to your &ldquo;/etc/ppp/options.ttyS0&rdquo; file:
What if you want to make a connection to a Windows server? Again we'll need the <quote>connect</quote> option and a chat script. Add the following line to your <quote>/etc/ppp/options.ttyS0</quote> file:
</para>
<programlisting>
<![ CDATA [connect chat -v -f /etc/ppp/scripts/winserver.chat
<![ CDATA [connect chat -v -f /etc/ppp/scripts/winserver.chat
]]> </programlisting>
<para>
Also create the chat script &ldquo;/etc/ppp/script/winserver.chat&rdquo;:
Also create the chat script <quote>/etc/ppp/script/winserver.chat</quote>:
</para>
<programlisting>
<![ CDATA [TIMEOUT 10
]]><![ CDATA ['' CLIENT\c
]]><![ CDATA ['' CLIENT\c
]]> </programlisting>
<para>
This makes the client send the &ldquo;CLIENT&rdquo; string before trying to start the PPP connection.
This makes the client send the <quote>CLIENT</quote> string before trying to start the PPP connection.
</para>
</sect2>
<sect2>
@ -292,7 +292,7 @@
Setting up an MS Windows (95) client
</title>
<para>
To connect to the server using windows, you use the Direct Cable Connection program, and set it up as &ldquo;guest&rdquo;. In order for the windows client to connect at full speed (or at all), you will have to change the communication speed of direct cable connection. To do this, go to Control Panel-&gt;System-&gt;Device Manager-&gt;Modems and select the serial cable. Proceed to the 'modem' option and select a maximum speed of 115200 or whatever your linux computer is set to. Now, it is important that you reboot at this stage, or it WILL NOT WORK (at least with Microsoft windows 95 version A), I am not sure about others.
To connect to the server using windows, you use the Direct Cable Connection program, and set it up as <quote>guest</quote>. In order for the windows client to connect at full speed (or at all), you will have to change the communication speed of direct cable connection. To do this, go to Control Panel-&gt;System-&gt;Device Manager-&gt;Modems and select the serial cable. Proceed to the 'modem' option and select a maximum speed of 115200 or whatever your linux computer is set to. Now, it is important that you reboot at this stage, or it WILL NOT WORK (at least with Microsoft windows 95 version A), I am not sure about others.
</para>
</sect2>
<sect2>
@ -309,7 +309,7 @@
Connecting...
</title>
<para>
The moment of truth: connect the computers with the null modem cable, first start the server side (if you are using the &ldquo;/etc/inittab&rdquo; approach it should be up already), then start the client side. You should see something like this on the server:
The moment of truth: connect the computers with the null modem cable, first start the server side (if you are using the <quote>/etc/inittab</quote> approach it should be up already), then start the client side. You should see something like this on the server:
</para>
<programlisting>
@ -319,10 +319,10 @@
]]><![ CDATA [user zaphod logged in
]]><![ CDATA [Deflate (15) compression enabled
]]><![ CDATA [local IP address 192.168.0.1
]]><![ CDATA [remote IP address 192.168.1.1
]]><![ CDATA [remote IP address 192.168.1.1
]]> </programlisting>
<para>
Note that if you started pppd from the &ldquo;/etc/inittab&rdquo; file these messages will appear in &ldquo;/var/log/messages&rdquo;. On the client side you should see something like this:
Note that if you started pppd from the <quote>/etc/inittab</quote> file these messages will appear in <quote>/var/log/messages</quote>. On the client side you should see something like this:
</para>
<programlisting>