⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userppp.html

📁 这是很好的学习嵌入式LINUX的文章
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!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>Using User PPP</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="PPP and SLIP" href="ppp-and-slip.html" /><link rel="PREVIOUS" title="PPP and SLIP" href="ppp-and-slip.html" /><link rel="NEXT" title="Using Kernel PPP" href="ppp.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></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 Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="ppp-and-slip.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 21 PPP and SLIP</td><td width="10%" align="right" valign="bottom"><a href="ppp.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="USERPPP" name="USERPPP">21.2 Using User PPP</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Updated and enhanced by</span> TomRhodes.</i> <i class="AUTHORGROUP"><span class="CONTRIB">Originally contributed by</span>Brian Somers.</i> <i class="AUTHORGROUP"><span class="CONTRIB">With input from</span> NikClayton, Dirk Fr鰉berg, and Peter Childs.</i> <div class="SECT2"><h2 class="SECT2"><a id="AEN30052" name="AEN30052">21.2.1 User PPP</a></h2><div class="SECT3"><h3 class="SECT3"><a id="AEN30054" name="AEN30054">21.2.1.1 Assumptions</a></h3><p>This document assumes you have the following:</p><ul><li><p>An account with an Internet Service Provider (ISP) which you connect to using PPP.</p></li><li><p>You have a modem or other device connected to your system and configured correctlywhich allows you to connect to your ISP.</p></li><li><p>The dial-up number(s) of your ISP.</p></li><li><p>Your login name and password. (Either a regular <spanclass="TRADEMARK">UNIX</span>&reg; style login and password pair, or a PAP or CHAP loginand password pair.)</p></li><li><p>The IP address of one or more name servers. Normally, you will be given two IPaddresses by your ISP to use for this. If they have not given you at least one, then youcan use the <tt class="COMMAND">enable dns</tt> command in <ttclass="FILENAME">ppp.conf</tt> and <b class="APPLICATION">ppp</b> will set the nameservers for you. This feature depends on your ISPs PPP implementation supporting DNSnegotiation.</p></li></ul><p>The following information may be supplied by your ISP, but is not completelynecessary:</p><ul><li><p>The IP address of your ISP's gateway. The gateway is the machine to which you willconnect and will be set up as your <span class="emphasis"><i class="EMPHASIS">defaultroute</i></span>. If you do not have this information, we can make one up and your ISP'sPPP server will tell us the correct value when we connect.</p><p>This IP number is referred to as <var class="LITERAL">HISADDR</var> by <bclass="APPLICATION">ppp</b>.</p></li><li><p>The netmask you should use. If your ISP has not provided you with one, you can safelyuse <tt class="HOSTID">255.255.255.255</tt>.</p></li><li><p>If your ISP provides you with a static IP address and hostname, you can enter it.Otherwise, we simply let the peer assign whatever IP address it sees fit.</p></li></ul><p>If you do not have any of the required information, contact your ISP.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Throughout this section, many of the examples showing the contents ofconfiguration files are numbered by line. These numbers serve to aid in the presentationand discussion only and are not meant to be placed in the actual file. Proper indentationwith tab and space characters is also important.</p></blockquote></div></div><div class="SECT3"><h3 class="SECT3"><a id="AEN30106" name="AEN30106">21.2.1.2 Creating PPP DeviceNodes</a></h3><p>Under normal circumstances, most users will only need one <ttclass="DEVICENAME">tun</tt> device (<tt class="FILENAME">/dev/tun0</tt>). References to<tt class="DEVICENAME">tun0</tt> below may be changed to <tt class="DEVICENAME">tun<varclass="REPLACEABLE">N</var></tt> where <var class="REPLACEABLE">N</var> is any unitnumber corresponding to your system.</p><p>For FreeBSD installations that do not have <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=devfs&sektion=5&manpath=FreeBSD+6-current"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">devfs</span>(5)</span></a> enabled(FreeBSD&nbsp;4.X and earlier), the existence of the <tt class="DEVICENAME">tun0</tt>device should be verified (this is not necessary if <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=devfs&sektion=5&manpath=FreeBSD+6-current"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">devfs</span>(5)</span></a> isenabled as device nodes will be created on demand).</p><p>The easiest way to make sure that the <tt class="DEVICENAME">tun0</tt> device isconfigured correctly is to remake the device. To remake the device, do the following:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /dev</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">sh MAKEDEV tun0</kbd></pre><p>If you need 16 tunnel devices in your kernel, you will need to create them. This canbe done by executing the following commands:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /dev</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">sh MAKEDEV tun15</kbd></pre></div><div class="SECT3"><h3 class="SECT3"><a id="AEN30139" name="AEN30139">21.2.1.3 Automatic <bclass="APPLICATION">PPP</b> Configuration</a></h3><p>Both <tt class="COMMAND">ppp</tt> and <tt class="COMMAND">pppd</tt> (the kernel levelimplementation of PPP) use the configuration files located in the <ttclass="FILENAME">/etc/ppp</tt> directory. Examples for user ppp can be found in <ttclass="FILENAME">/usr/share/examples/ppp/</tt>.</p><p>Configuring <tt class="COMMAND">ppp</tt> requires that you edit a number of files,depending on your requirements. What you put in them depends to some extent on whetheryour ISP allocates IP addresses statically (i.e., you get given one IP address, andalways use that one) or dynamically (i.e., your IP address changes each time you connectto your ISP).</p><div class="SECT4"><h4 class="SECT4"><a id="USERPPP-STATICIP" name="USERPPP-STATICIP">21.2.1.3.1 PPP andStatic IP Addresses</a></h4><p>You will need to edit the <tt class="FILENAME">/etc/ppp/ppp.conf</tt> configurationfile. It should look similar to the example below.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Lines that end in a <var class="LITERAL">:</var> start in the firstcolumn (beginning of the line)-- all other lines should be indented as shown using spacesor tabs.</p></blockquote></div><pre class="PROGRAMLISTING">1     default:2       set log Phase Chat LCP IPCP CCP tun command3       ident user-ppp VERSION (built COMPILATIONDATE)4       set device /dev/cuaa05       set speed 1152006       set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \7                 \"\" AT OK-AT-OK ATE1Q0 OK \\dATDT\\T TIMEOUT 40 CONNECT"8       set timeout 1809       enable dns1011    provider:12      set phone "(123) 456 7890"13      set authname foo14      set authkey bar15      set login "TIMEOUT 10 \"\" \"\" gin:--gin: \\U word: \\P col: ppp"16      set timeout 30017      set ifaddr <var class="REPLACEABLE">x.x.x.x</var> <varclass="REPLACEABLE">y.y.y.y</var> 255.255.255.255 0.0.0.018      add default HISADDR</pre><div class="VARIABLELIST"><dl><dt>Line 1:</dt><dd><p>Identifies the default entry. Commands in this entry are executed automatically whenppp is run.</p></dd><dt>Line 2:</dt><dd><p>Enables logging parameters. When the configuration is working satisfactorily, thisline should be reduced to saying</p><pre class="PROGRAMLISTING">set log phase tun</pre>in order to avoid excessive log file sizes.<br /><br /></dd><dt>Line 3:</dt><dd><p>Tells PPP how to identify itself to the peer. PPP identifies itself to the peer if ithas any trouble negotiating and setting up the link, providing information that the peersadministrator may find useful when investigating such problems.</p></dd><dt>Line 4:</dt><dd><p>Identifies the device to which the modem is connected. <ttclass="DEVICENAME">COM1</tt> is <tt class="FILENAME">/dev/cuaa0</tt> and <ttclass="DEVICENAME">COM2</tt> is <tt class="FILENAME">/dev/cuaa1</tt>.</p></dd><dt>Line 5:</dt><dd><p>Sets the speed you want to connect at. If 115200 does not work (it should with anyreasonably new modem), try 38400 instead.</p></dd><dt>Line 6 &#38; 7:</dt><dd><p>The dial string. User PPP uses an expect-send syntax similar to the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=chat&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">chat</span>(8)</span></a> program. Referto the manual page for information on the features of this language.</p><p>Note that this command continues onto the next line for readability. Any command in<tt class="FILENAME">ppp.conf</tt> may do this if the last character on the line is a``\'' character.</p></dd><dt>Line 8:</dt><dd><p>Sets the idle timeout for the link. 180 seconds is the default, so this line is purelycosmetic.</p></dd><dt>Line 9:</dt><dd><p>Tells PPP to ask the peer to confirm the local resolver settings. If you run a localname server, this line should be commented out or removed.</p></dd><dt>Line 10:</dt><dd><p>A blank line for readability. Blank lines are ignored by PPP.</p></dd><dt>Line 11:</dt><dd><p>Identifies an entry for a provider called ``provider''. This could be changed to thename of your <acronym class="ACRONYM">ISP</acronym> so that later you can use the <varclass="OPTION">load ISP</var> to start the connection.</p></dd><dt>Line 12:</dt><dd><p>Sets the phone number for this provider. Multiple phone numbers may be specified usingthe colon (<var class="LITERAL">:</var>) or pipe character (<varclass="LITERAL">|</var>)as a separator. The difference between the two separators isdescribed in <a href="http://www.FreeBSD.org/cgi/man.cgi?query=ppp&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">ppp</span>(8)</span></a>. To summarize,if you want to rotate through the numbers, use a colon. If you want to always attempt todial the first number first and only use the other numbers if the first number fails, usethe pipe character. Always quote the entire set of phone numbers as shown.</p><p>You must enclose the phone number in quotation marks (<var class="LITERAL">"</var>) ifthere is any intention on using spaces in the phone number. This can cause a simple, yetsubtle error.</p></dd><dt>Line 13 &#38; 14:</dt><dd><p>Identifies the user name and password. When connecting using a <spanclass="TRADEMARK">UNIX</span> style login prompt, these values are referred to by the <ttclass="COMMAND">set login</tt> command using the \U and \P variables. When connectingusing PAP or CHAP, these values are used at authentication time.</p></dd><dt>Line 15:</dt><dd><p>If you are using PAP or CHAP, there will be no login at this point, and this lineshould be commented out or removed. See <a href="userppp.html#USERPPP-PAPNCHAP">PAP andCHAP authentication</a> for further details.</p><p>The login string is of the same chat-like syntax as the dial string. In this example,the string works for a service whose login session looks like this:</p><pre class="SCREEN">J. Random Providerlogin: <var class="REPLACEABLE">foo</var>password: <var class="REPLACEABLE">bar</var>protocol: ppp</pre><p>You will need to alter this script to suit your own needs. When you write this scriptfor the first time, you should ensure that you have enabled ``chat'' logging so you candetermine if the conversation is going as expected.</p></dd><dt>Line 16:</dt><dd><p>Sets the default idle timeout (in seconds) for the connection. Here, the connectionwill be closed automatically after 300 seconds of inactivity. If you never want totimeout, set this value to zero or use the <var class="OPTION">-ddial</var> command lineswitch.</p></dd><dt>Line 17:</dt><dd><p>Sets the interface addresses. The string <var class="REPLACEABLE">x.x.x.x</var> shouldbe replaced by the IP address that your provider has allocated to you. The string <varclass="REPLACEABLE">y.y.y.y</var> should be replaced by the IP address that your ISPindicated for their gateway (the machine to which you connect). If your ISP has not givenyou a gateway address, use <tt class="HOSTID">10.0.0.2/0</tt>. If you need to use a``guessed'' address, make sure that you create an entry in <ttclass="FILENAME">/etc/ppp/ppp.linkup</tt> as per the instructions for <ahref="userppp.html#USERPPP-DYNAMICIP">PPP and Dynamic IP addresses</a>. If this line isomitted, <tt class="COMMAND">ppp</tt> cannot run in <var class="OPTION">-auto</var>mode.</p></dd><dt>Line 18:</dt><dd>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -