📄 linux-ppp.html
字号:
where you should then type <B><TT>pppd</TT></B>. Typing <B>pppd</B> is<B>critical</B> to establishing the connection.</P><A NAME="routing"></A><H4><A NAME="7">Possible Routing Problems</A></H4><P>If your ISP uses a gateway (a computer that connects you to the rest ofthe Internet) that's a different machine than the one you connect to fordialing in, here's what you should do. You need to change the routingconfiguration on your machine so that you can actually be recognized as amachine on the Internet. The way to tell if you need to change the routingis if you type <TT>ifconfig</TT> as root, and it shows that you have an IPaddress through your modem, but it still doesn't work. The output of<TT>ifconfig</TT> looks something like this:</P><PRE>eth0 Link encap:Ethernet HWaddr 00:40:05:48:2E:83 inet addr:192.168.0.1 Bcast:192.168.0.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2907 errors:0 dropped:0 overruns:0 frame:0 TX packets:3343 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 Interrupt:10 Base address:0x300lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:3924 Metric:1 RX packets:4364 errors:0 dropped:0 overruns:0 frame:0 TX packets:4364 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0ppp0 Link encap:Point-to-Point Protocol inet addr:207.142.2.34 P-t-P:206.53.129.11 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:576 Metric:1 RX packets:97 errors:0 dropped:0 overruns:0 frame:0 TX packets:88 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:10</PRE><P>If it shows the <TT>ppp0</TT> interface, but you can't get<TT>ping</TT> responses from any hosts, then there might be somethingwrong with your routing. The way to fix it? First, type <TT>route</TT> andit will display something like this:</P><PRE>Kernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface127.0.0.0 * 255.0.0.0 U 0 0 3 lo205.226.158.252 * 0.0.0.0 U 0 0 7 ppp0</PRE><P>As you might expect, most of the IP addresses will probably bedifferent on your setup. The bottom route is incorrect on my system, so tochange it, I type <TT><B>route del 205.226.158.252 ppp0</B></TT> to deleteit. Then I type <TT><B>route add default ppp0</B></TT> to set the newroute. Or, if you don't want to delete the old route, you can just set thenew route, and it will work just as well. Not deleting the old route isprobably safer.</P><P>Those are the only things I had to do. For some reason unknown to me,that pointed the gateway to the correct address and I successfullyreceived <TT><B>ping</B></TT> responses.</P><A NAME="otherhelp"></A><H4><A NAME="8">Other Sources of Help</A></H4><P>That should get your dialup connection up and running. If not, keeptrying, or ask for help through any of the *linux* newsgroups or the#Linux* channels on IRC. (I'd recommend <AHREF="http://linuxhelp.kennesaw.edu/">#LinuxHelp on the Undernet</A>.)</P><P>As usual, I support my work fully, so e-mail me at <AHREF="mailto:jgo@local.net">jgo@local.net</A>. Please keep itshort and simple, while providing the necessary information.</P><A NAME="chatscript"></A><H3><A NAME="9">Using a Chatscript</A></H3><P>This is a very convenient way to connect to the Internet. Once you getthis set up, you can connect with a single command. However, thereare things you should know first. Here are things to write down:</P><UL><LI>What does your login prompt look like? For some ISPs it's <B>login:</B>; for others, it's <B>username:</B>. If you use PAP or CHAP, there will be none.</LI><LI>What does your password prompt look like? Usually it's <B>password:</B> but fill whatever your ISP prompts you for if you want this to work. PAP and CHAP users don't get a password prompt.</LI><LI>How many lines are in between, say, CONNECT 38400 and the first prompt? This is how many <B>\n</B>'s you will use.</LI><LI>Are there any other prompts that are presented to you when you first log in?</LI></UL><P>The best thing to have done before this is to have made sure that youcould dial in with minicom and use pppd to establish a connection. Thatwould have ensured that it was possible for you to get connected. Thismethod is a permanent solution so you won't have to go through the tediousprocess of typing several keystrokes and waiting to enter the nextcommand.</P><P>Now, go on to making the actual script. As root, create a file to useas the actual chatscript (the text file tells the <TT>chat</TT> programhow to communicate with your modem). I suggest giving it a name with the.chat file extension; for the sake of simplicity, let's just say thatwe'll use <TT>yourispname.chat</TT> as the filename. To edit the file,type <TT><B>pico yourispname.chat</B></TT>.</P><P>Now put in the following lines into yourispname.chat:</P><PRE>""AT&D2OK ATDT#phone#38400 \nogin: foobarword: altm.415</PRE><P>In place of AT&D2 you can plug in the initialization string thatyou use. In place of #phone# you should put in the number that you wantyour modem to call, so for me it would look like <TT>ATDT4755868</TT>. The'38400' represents the speed you want to connect at and '\n' is telling<TT>chat</TT> to expect a new line. The part saying 'ogin: foobar' istelling <TT>chat</TT> to expect the text 'ogin:' to appear somewhere andrespond to it by sending the word 'foobar'. The same applies to the nextline. Don't put in the last two lines if you're using PAP or CHAP becausethe passwords aren't authenticated with plain text like that.</P><P>Basically you type in any prompts that are presented to you, and thentype in what to send back. What is presented and what is sent back can beseparated by a space in between.</P><P>If you dial in, watch for the number of lines between your baud rate(like 38400) and the <B>login:</B> prompt; if there's one line in between,use one \n character; if there are two, use two \n characters, and so on.Be sure to watch out for this.</P><P>To prevent users other than root from reading from the file and findingout your password for logging in to your provider, you should change thepermissions on the chatscript so that only root can read from it. I woulddo this by typing <B><TT>chmod go-rwx yourispname.chat</TT></B>.</P><P>Now, you should make another script -- a normal (shell) script. Move to<TT>/usr/sbin</TT> as root and create the script. Let's call it<TT>yourispname</TT>. Now we proceed to edit the file by typing <TT>picoyourispname</TT> in <TT>/usr/sbin</TT>. Keep in mind that you can changethe filenames to whatever you want.</P><P>Put the following lines into the normal (shell) script,yourispname:</P><PRE>pppd connect 'chat -f /root/yourispname.chat' /dev/modem 38400 \0.0.0.0: asyncmap 0 crtscts defaultroute</PRE><P>You might want to change the path to <TT>yourispname.chat</TT>, havingit correspond to the directory that you placed <TT>yourispname.chat</TT>. After you put in this line, make the file executable and only to beaccessed by root (the head honcho on the system) by typing <TT>chmod 700yourispname.chat</TT>.</P><P>To connect, all you have to do is type the name of the file that youcreated. All this should be done as root.</P><A NAME="disconnect"></A><H3><A NAME="10">Disconnecting</A></H3><P>The way I disconnect is I type <TT>killall pppd</TT>, which kills thepppd program from running and therefore shuts down communication betweenyour modem and your ISP.</P><P><A HREF="mailto:dhaliwal@pathcom.com">Jas</A> has suggested thisshellscript:</P><PRE>#!/bin/shkill -TERM `cat /var/run/ppp0.pid`</PRE><P>That means you'd put that in a file using a text editor such as<B>pico</B> or <B>vim</B>, and save it as whatever filename you want(<B>ppp-down.sh</B> for Jas' example). Then when you're back at theprompt, type <B><TT>chmod +x ppp-down.sh</TT></B> so that it can be run(executed). I guess I should try this when I disconnect...</P><A NAME="modemtrouble"></A><H3><A NAME="11">Modem Trouble</A></H3><P>There might be all sorts of problems you encounter that are related toyour modem, and that is a major obstacle for a lot of people.</P><A NAME="winmodem"></A><H4><A NAME="12">PnP and Winmodem</A></H4><P>Linux users who have plug n' play (PnP) modems or the notorius WinModemfrom US Robotics might have a lot of trouble in getting Linux to recognizethat their modem is present. The best solution is to use another modem,make sure that it doesn't say "WinModem", "Plug n'Play", "PnP", "Exclusively for Windows", oranything similar.</P><P>Two ways you can try to get Linux to recognize PnP devices are messingwith your BIOS (set the "PnP OS Installed" option to"off") and/or loading Windows 95 first, then using a DOS programcalled Loadlin to boot a copy of your Linux kernel, usually found as thefile called <B><TT>vmlinuz</TT></B> in your <TT>/boot/</TT> directory. Thefile, <B>LOADLIN.EXE</B>, is usually available from your Linuxdistribution media, be it FTP or CD-ROM.</P><A NAME="irqconflict"></A><H4><A NAME="13">IRQ Conflict</A></H4><P>Your modem might try to be sharing the same means of communicating withthe system with another device that has the same interrupt request, orIRQ. Symptoms of this include an abnormally slow connection, an errorabout timeouts sending config-requests, and a disconnect soonafterwards.</P><P>HydroFlow from <A HREF="http://linuxhelp.kennesaw.edu/"TARGET="_top">IRC on the Undernet</A> told me that all he had to do wastype <B><TT>setserial /dev/modem irq 10</TT></B> to get it working. Ofcourse, that's his system, so change the IRQ to fit your own systemsettings. Then the instructions seemed to have worked.</P><P>You can check for what devices have which IRQ settings by typing <B>cat/proc/interrupts</B>.</P><A NAME="initstrings"></A><H4><A NAME="14">Finding Exact Init Strings</A></H4><P>Since some of you might be wondering about how to find exactinitialization strings for your modem, <AHREF="mailto:karnowsky@nmol.com">FusionGyro</A> wrote:</P><P><I>I would like to offer a tip for you to possibly include in your FAQfile. For people coming to Linux from Windows 9x, there is a"simple" way to find all of the exact complicated modem strings. First, make sure you have logged on to your ISP since you booted. Thenjust fire up the control panel, open "Modems", highlight thecorrect modem, press "Properties", hit the"Connection" tab, press "Advanced", and then hit"View Log". (Gee, that wasn't so easy, was it ;). You shouldbe staring at a text file. This file will contain everything that wassent and recieved until a PPP connection was made.</I> Here's a cutout from theexample he gave:</P><PRE>12-13-1998 02:56:07.36 - Cirrus Logic 33600 bps PnP V34 in use.12-13-1998 02:56:07.36 - Modem type: Cirrus Logic 33600 bps PnP V3412-13-1998 02:56:07.36 - Modem inf path: MDMTI.INF12-13-1998 02:56:07.36 - Modem inf section: Modem412-13-1998 02:56:07.61 - 115200,N,8,112-13-1998 02:56:07.62 - 115200,N,8,112-13-1998 02:56:07.62 - Initializing modem.12-13-1998 02:56:07.75 - Recv: <cr>12-13-1998 02:56:08.22 - Interpreted response: Ok12-13-1998 02:56:08.22 - Send: ATS7=60\T0L1M1\N3-J1%C1"H3\Q3B0N1X4<cr>12-13-1998 02:56:27.67 - Recv: COMPRESSION:V42B12-13-1998 02:56:27.67 - Interpreted response: Informative12-13-1998 02:56:27.67 - Recv: <cr>12-13-1998 02:56:27.67 - Interpreted response: Informative12-13-1998 02:56:27.67 - Recv: <lf>12-13-1998 02:56:27.67 - Error-control on.12-13-1998 02:56:27.67 - Data compression on.</PRE><P><I>While much of it is useless, it does contain the important stuff: AT&F E0 V1 W4 &D2 &C1 S0=0 -C1, etc.</I></P><!-- This paragraph added on Tue Mar 2 16:26:50 PST 1999 --><P><A HREF="mailto:pp@poulpetersen.dk">Poul Petersen</A> wrote inabout a site where you can look up information about your modem,including the init string. It's at <AHREF="http://www.spy.net/~dustin/modem/">http://www.spy.net/~dustin/modem/</A>.</P><A NAME="notes"></A><H3><A NAME="15">Author's Notes</A></H3><P>When you're upgrading from, say, a generic 14.4 to a 33.6, and bothare external, the only settings you need to change in minicom (or thechatscript) are the baud rates and the initialization string. Thestandard dial string (ATDT) should work for old modems as well as newones.</P><A NAME="nopico"></A><H4><A NAME="16">No Pico?</A></H4><P>If you don't have <B><TT>pico</TT></B> installed, try some other texteditor (<TT>emacs</TT>, <TT>vi</TT>, <TT>joe</TT>, or <TT>jed</TT>) thatyou might be able to use to edit that file. Use that instead of"pico" wherever "pico" appears as a command. Itdoesn't matter what text editor you use.</P><HR><P><B><FONT SIZE="-1">Copyright © 1997-1999 <AHREF="mailto:jgo@local.net">Joshua Go(jgo@local.net)</A>. All rights reserved. Permission to use,distribute, and copy this document is hereby granted. You may modifythis document as long as credit to me is given.</FONT></B></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -