?? dialup.html
字號:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Dial-in Service</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手冊" href="index.html" /><link rel="UP" title="Serial Communications" href="serialcomms.html" /><link rel="PREVIOUS" title="Terminals" href="term.html" /><link rel="NEXT" title="Dial-out Service" href="dialout.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD 使用手冊</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="term.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 17. Serial Communications</td><td width="10%" align="right" valign="bottom"><a href="dialout.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="DIALUP" name="DIALUP">17.4. Dial-in Service</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Guy Helmer.</i> <iclass="AUTHORGROUP"><span class="CONTRIB">Additions by</span> Sean Kelly.</i> <p>Configuring your FreeBSD system for dial-in service is very similar to connectingterminals except that you are dealing with modems instead of terminals.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN22447" name="AEN22447">17.4.1. External vs. InternalModems</a></h2><p>External modems seem to be more convenient for dial-up, because external modems oftencan be semi-permanently configured via parameters stored in non-volatile RAM and theyusually provide lighted indicators that display the state of important RS-232 signals.Blinking lights impress visitors, but lights are also very useful to see whether a modemis operating properly.</p><p>Internal modems usually lack non-volatile RAM, so their configuration may be limitedonly to setting DIP switches. If your internal modem has any signal indicator lights, itis probably difficult to view the lights when the system's cover is in place.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN22451" name="AEN22451">17.4.1.1. Modems and Cables</a></h3><p>If you are using an external modem, then you will of course need the proper cable. Astandard RS-232C serial cable should suffice as long as all of the normal signals arewired:</p><ul><li><p>Transmitted Data (<acronym class="ACRONYM">SD</acronym>)</p></li><li><p>Received Data (<acronym class="ACRONYM">RD</acronym>)</p></li><li><p>Request to Send (<acronym class="ACRONYM">RTS</acronym>)</p></li><li><p>Clear to Send (<acronym class="ACRONYM">CTS</acronym>)</p></li><li><p>Data Set Ready (<acronym class="ACRONYM">DSR</acronym>)</p></li><li><p>Data Terminal Ready (<acronym class="ACRONYM">DTR</acronym>)</p></li><li><p>Carrier Detect (<acronym class="ACRONYM">CD</acronym>)</p></li><li><p>Signal Ground (<acronym class="ACRONYM">SG</acronym>)</p></li></ul><p>FreeBSD needs the <acronym class="ACRONYM">RTS</acronym> and <acronymclass="ACRONYM">CTS</acronym> signals for flow-control at speeds above 2400 bps, the<acronym class="ACRONYM">CD</acronym> signal to detect when a call has been answered orthe line has been hung up, and the <acronym class="ACRONYM">DTR</acronym> signal to resetthe modem after a session is complete. Some cables are wired without all of the neededsignals, so if you have problems, such as a login session not going away when the linehangs up, you may have a problem with your cable.</p><p>Like other <span class="TRADEMARK">UNIX</span>® like operating systems, FreeBSDuses the hardware signals to find out when a call has been answered or a line has beenhung up and to hangup and reset the modem after a call. FreeBSD avoids sending commandsto the modem or watching for status reports from the modem. If you are familiar withconnecting modems to PC-based bulletin board systems, this may seem awkward.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN22488" name="AEN22488">17.4.2. Serial InterfaceConsiderations</a></h2><p>FreeBSD supports NS8250-, NS16450-, NS16550-, and NS16550A-based EIA RS-232C (CCITTV.24) communications interfaces. The 8250 and 16450 devices have single-characterbuffers. The 16550 device provides a 16-character buffer, which allows for better systemperformance. (Bugs in plain 16550's prevent the use of the 16-character buffer, so use16550A's if possible). Because single-character-buffer devices require more work by theoperating system than the 16-character-buffer devices, 16550A-based serial interfacecards are much preferred. If the system has many active serial ports or will have a heavyload, 16550A-based cards are better for low-error-rate communications.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN22491" name="AEN22491">17.4.3. Quick Overview</a></h2><p>As with terminals, <tt class="COMMAND">init</tt> spawns a <ttclass="COMMAND">getty</tt> process for each configured serial port for dial-inconnections. For example, if a modem is attached to <tt class="FILENAME">/dev/ttyd0</tt>,the command <tt class="COMMAND">ps ax</tt> might show this:</p><pre class="SCREEN"> 4850 ?? I 0:00.09 /usr/libexec/getty V19200 ttyd0</pre><p>When a user dials the modem's line and the modems connect, the <acronymclass="ACRONYM">CD</acronym> (Carrier Detect) line is reported by the modem. The kernelnotices that carrier has been detected and completes <tt class="COMMAND">getty</tt>'sopen of the port. <tt class="COMMAND">getty</tt> sends a <sampclass="PROMPT">login:</samp> prompt at the specified initial line speed. <ttclass="COMMAND">getty</tt> watches to see if legitimate characters are received, and, ina typical configuration, if it finds junk (probably due to the modem's connection speedbeing different than <tt class="COMMAND">getty</tt>'s speed), <ttclass="COMMAND">getty</tt> tries adjusting the line speeds until it receives reasonablecharacters.</p><p>After the user enters his/her login name, <tt class="COMMAND">getty</tt> executes <ttclass="FILENAME">/usr/bin/login</tt>, which completes the login by asking for the user'spassword and then starting the user's shell.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN22515" name="AEN22515">17.4.4. Configuration Files</a></h2><p>There are three system configuration files in the <tt class="FILENAME">/etc</tt>directory that you will probably need to edit to allow dial-up access to your FreeBSDsystem. The first, <tt class="FILENAME">/etc/gettytab</tt>, contains configurationinformation for the <tt class="FILENAME">/usr/libexec/getty</tt> daemon. Second, <ttclass="FILENAME">/etc/ttys</tt> holds information that tells <ttclass="FILENAME">/sbin/init</tt> what <tt class="FILENAME">tty</tt> devices should have<tt class="COMMAND">getty</tt> processes running on them. Lastly, you can place portinitialization commands in the <tt class="FILENAME">/etc/rc.serial</tt> script.</p><p>There are two schools of thought regarding dial-up modems on <spanclass="TRADEMARK">UNIX</span>. One group likes to configure their modems and systems sothat no matter at what speed a remote user dials in, the local computer-to-modem RS-232interface runs at a locked speed. The benefit of this configuration is that the remoteuser always sees a system login prompt immediately. The downside is that the system doesnot know what a user's true data rate is, so full-screen programs like Emacs will notadjust their screen-painting methods to make their response better for slowerconnections.</p><p>The other school configures their modems' RS-232 interface to vary its speed based onthe remote user's connection speed. For example, V.32bis (14.4 Kbps) connections tothe modem might make the modem run its RS-232 interface at 19.2 Kbps, while2400 bps connections make the modem's RS-232 interface run at 2400 bps. Because<tt class="COMMAND">getty</tt> does not understand any particular modem's connectionspeed reporting, <tt class="COMMAND">getty</tt> gives a <sampclass="PROMPT">login:</samp> message at an initial speed and watches the characters thatcome back in response. If the user sees junk, it is assumed that they know they shouldpress the <span class="KEYCODE">Enter</span> key until they see a recognizable prompt. Ifthe data rates do not match, <tt class="COMMAND">getty</tt> sees anything the user typesas ``junk'', tries going to the next speed and gives the <sampclass="PROMPT">login:</samp> prompt again. This procedure can continue ad nauseam, butnormally only takes a keystroke or two before the user sees a good prompt. Obviously,this login sequence does not look as clean as the former ``locked-speed'' method, but auser on a low-speed connection should receive better interactive response fromfull-screen programs.</p><p>This section will try to give balanced configuration information, but is biasedtowards having the modem's data rate follow the connection rate.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN22538" name="AEN22538">17.4.4.1. <ttclass="FILENAME">/etc/gettytab</tt></a></h3><p><tt class="FILENAME">/etc/gettytab</tt> is a <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">termcap</span>(5)</span>-style file of configuration informationfor <span class="CITEREFENTRY"><span class="REFENTRYTITLE">getty</span>(8)</span>. Pleasesee the <span class="CITEREFENTRY"><span class="REFENTRYTITLE">gettytab</span>(5)</span>manual page for complete information on the format of the file and the list ofcapabilities.</p><div class="SECT4"><h4 class="SECT4"><a id="AEN22555" name="AEN22555">17.4.4.1.1. Locked-speedConfig</a></h4><p>If you are locking your modem's data communications rate at a particular speed, youprobably will not need to make any changes to <ttclass="FILENAME">/etc/gettytab</tt>.</p></div><div class="SECT4"><h4 class="SECT4"><a id="AEN22559" name="AEN22559">17.4.4.1.2. Matching-speedConfig</a></h4><p>You will need to setup an entry in <tt class="FILENAME">/etc/gettytab</tt> to give <ttclass="COMMAND">getty</tt> information about the speeds you wish to use for your modem.If you have a 2400 bps modem, you can probably use the existing <varclass="LITERAL">D2400</var> entry.</p><pre class="PROGRAMLISTING">## Fast dialup terminals, 2400/1200/300 rotary (can start either way)#D2400|d2400|Fast-Dial-2400:\ :nx=D1200:tc=2400-baud:3|D1200|Fast-Dial-1200:\ :nx=D300:tc=1200-baud:5|D300|Fast-Dial-300:\ :nx=D2400:tc=300-baud:</pre><p>If you have a higher speed modem, you will probably need to add an entry in <ttclass="FILENAME">/etc/gettytab</tt>; here is an entry you could use for a 14.4 Kbpsmodem with a top interface speed of 19.2 Kbps:</p><pre class="PROGRAMLISTING">## Additions for a V.32bis Modem#um|V300|High Speed Modem at 300,8-bit:\ :nx=V19200:tc=std.300:un|V1200|High Speed Modem at 1200,8-bit:\ :nx=V300:tc=std.1200:uo|V2400|High Speed Modem at 2400,8-bit:\ :nx=V1200:tc=std.2400:up|V9600|High Speed Modem at 9600,8-bit:\ :nx=V2400:tc=std.9600:uq|V19200|High Speed Modem at 19200,8-bit:\ :nx=V9600:tc=std.19200:</pre><p>This will result in 8-bit, no parity connections.</p><p>The example above starts the communications rate at 19.2 Kbps (for a V.32bisconnection), then cycles through 9600 bps (for V.32), 2400 bps, 1200 bps,300 bps, and back to 19.2 Kbps. Communications rate cycling is implemented withthe <var class="LITERAL">nx=</var> (``next table'') capability. Each of the lines uses a<var class="LITERAL">tc=</var> (``table continuation'') entry to pick up the rest of the``standard'' settings for a particular data rate.</p><p>If you have a 28.8 Kbps modem and/or you want to take advantage of compression ona 14.4 Kbps modem, you need to use a higher communications rate than 19.2 Kbps.Here is an example of a <tt class="FILENAME">gettytab</tt> entry starting a57.6 Kbps:</p><pre class="PROGRAMLISTING">## Additions for a V.32bis or V.34 Modem# Starting at 57.6 Kbps#vm|VH300|Very High Speed Modem at 300,8-bit:\ :nx=VH57600:tc=std.300:vn|VH1200|Very High Speed Modem at 1200,8-bit:\ :nx=VH300:tc=std.1200:vo|VH2400|Very High Speed Modem at 2400,8-bit:\ :nx=VH1200:tc=std.2400:vp|VH9600|Very High Speed Modem at 9600,8-bit:\ :nx=VH2400:tc=std.9600:vq|VH57600|Very High Speed Modem at 57600,8-bit:\ :nx=VH9600:tc=std.57600:</pre><p>If you have a slow CPU or a heavily loaded system and do not have 16550A-based serialports, you may receive ``<tt class="ERRORNAME">sio</tt>'' ``silo'' errors at57.6 Kbps.</p></div></div><div class="SECT3"><h3 class="SECT3"><a id="DIALUP-TTYS" name="DIALUP-TTYS">17.4.4.2. <ttclass="FILENAME">/etc/ttys</tt></a></h3><p>Configuration of the <tt class="FILENAME">/etc/ttys</tt> file was covered in <ahref="term.html#EX-ETC-TTYS">Example 17-1</a>. Configuration for modems is similar but wemust pass a different argument to <tt class="COMMAND">getty</tt> and specify a differentterminal type. The general format for both locked-speed and matching-speed configurationsis:</p><pre class="PROGRAMLISTING">ttyd0 "/usr/libexec/getty <var class="REPLACEABLE">xxx</var>" dialup on</pre><p>The first item in the above line is the device special file for this entry -- <varclass="LITERAL">ttyd0</var> means <tt class="FILENAME">/dev/ttyd0</tt> is the file thatthis <tt class="COMMAND">getty</tt> will be watching. The second item, <varclass="LITERAL">"/usr/libexec/getty <var class="REPLACEABLE">xxx</var>"</var> (<varclass="REPLACEABLE">xxx</var> will be replaced by the initial <ttclass="FILENAME">gettytab</tt> capability) is the process <tt class="COMMAND">init</tt>will run on the device. The third item, <var class="LITERAL">dialup</var>, is the defaultterminal type. The fourth parameter, <var class="LITERAL">on</var>, indicates to <ttclass="COMMAND">init</tt> that the line is operational. There can be a fifth parameter,<var class="LITERAL">secure</var>, but it should only be used for terminals which arephysically secure (such as the system console).</p><p>The default terminal type (<var class="LITERAL">dialup</var> in the example above) maydepend on local preferences. <var class="LITERAL">dialup</var> is the traditional defaultterminal type on dial-up lines so that users may customize their login scripts to noticewhen the terminal is <var class="LITERAL">dialup</var> and automatically adjust theirterminal type. However, the author finds it easier at his site to specify <varclass="LITERAL">vt102</var> as the default terminal type, since the users just use VT102emulation on their remote systems.</p><p>After you have made changes to <tt class="FILENAME">/etc/ttys</tt>, you may send the<tt class="COMMAND">init</tt> process a <acronym class="ACRONYM">HUP</acronym> signal tore-read the file. You can use the command</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">kill -HUP 1</kbd>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -