Setting Up an Internet Connection Last updated: June 9, 1998 Development stage: Beta Setting up an Internet connection can get tricky, even frustrating, especially if you're a new Linux user. If your ISP is like most others, it will use Point-to-Point Protocol. I will first describe setting up and using minicom and pppd separately, and then using a chatscript. One can connect to the Internet with either of these methods; if one doesn't work for you, try the other. If both work for you, then you can choose whichever one is the most convenient. If your ISP happens to use the PAP protocol, you can try a PAP setup guide located at http://www.gen-x.net/~hyped/linux/pap.txt. For CHAP, the instructions on the page should work, only instead of using the file pap-secrets, use chap-secrets. If you don't know what I'm talking about, you will soon. There's also a web-based configuration script that will help you. It uses CGI scripts to create files for you to paste into your configuration files in /etc/ppp/. The URL is http://www.wibble.net/~james/cgi-bin/pppconfig.cgi. Lord Pyromage mentioned the pppsetup program, which comes with Slackware. According to him, it makes the PPP setup process much easier. So if you've got Slackware, you might want to give it a try if you don't want to read this page. If I haven't scared you away by now, read on. Using Minicom with PPPd First you should start out by configuring minicom (a terminal dialup program). At the Linux prompt, as root, type minicom -s. That will load minicom in setup mode; after this, just set up the configurations: modem initialization strings (if you have a generic modem the initialization string you might want to try using would be AT&D2; consult your modem manual for the fancy options), etc. Make sure all this is done, and then choose 'Save as dfl' (saving it as the default) from the main minicom menu. I would try watching out for what baud rate you use. Don't use too high of a baud rate, or you might be disconnected because of an unstable connection. Your initialization string could possibly also have something to do with this. If you don't know what you're doing, I would suggest that you use a simple initialization string like AT&D2. DNS and Nameserver Configuration At the Linux prompt again, type pico /etc/resolv.conf to enter the nameserver addresses. Insert something similar to the following lines, replacing them to match your own: search local.net nameserver 205.136.28.2 A nameserver is a machine that most providers set up to translate the hostnames of Internet hosts into their IP addresses (for example, it would resolve www.local.net to 205.136.38.11). My ISP has TWO nameservers, so don't be confused if you receive two (or more) addresses as information on your ISP's nameserver. You might want someone who is already using Linux to do a dnsquery on your ISP's domain. For example, if your ISP is Local Net (mine) and their front page is at http://www.local.net, then have whoever is doing the DNS query type this: dnsquery local.net or dnsquery www.local.net The IP/hostmask it should resolve to or show should be ns2.local.net. Again, I'm using my own ISP as an example. There will also probably be a secondary nameserver for your ISP, so you can use either one, or even better, both. The nameservers are the last lines in the dnsquery; make sure the person doing the dnsquery knows that. Yours will be different if you don't use Local Net as your provider. I want the IP address of ns2.local.net, not the hostname. ns2.local.net is 205.136.38.2 so I write that down somewhere. Just add that "nameserver" line in /etc/resolv.conf followed by the IP address of the actual nameserver (205.136.38.2) and complete the rest of the process. You can also call up your ISP through the phone and ask them the IP address of the nameserver, if you don't know anyone who is already on Linux or who can find out. If you already know what your ISP's nameserver is, then you didn't really need to read the previous few paragraphs on the nameserver. Sorry. As far as I know, you can use anybody's nameserver as long as you have the IP address (numerical, e.g. 205.226.156.2) for it. PPP Options Now you also should edit /etc/ppp/options by typing pico /etc/ppp/options. This is really important in starting point-to-point protocol (PPP). If you don't fill it in you'll have to specify the options every time you connect. Insert the following lines into the file: 0.0.0.0: /dev/ttyS1 lock crtscts defaultroute asyncmap 0 mtu 552 mru 552 The only thing you might need to change is the device entry that tells which device to use for PPP. On my computer, with the external modem using COM2, it's /dev/ttyS1. You should know what COM port your modem is using, either from your experience as a DOS/Windows user or as a frequent Linux user (which you're probably not... for now). Once you find that, you can refer to that device using /dev/modem by making a symbolic link from /dev/ttySX ('X' representing whatever that number is) to /dev/modem. Do this by typing the following as root: ln -s /dev/ttyS1 /dev/modem Replace ttyS1 with whatever the device that you're using is, if necessary. The basic way to remember is that ttyS0 is actually COM1 under DOS, ttyS1 is COM2, ttyS2 is COM3, and so on; the number following "ttyS" is just one number less than the number following COM in your previous operating system. The 0.0.0.0: should be put in the PPP options file if you have a dynamic IP address (your IP address/hostname is randomly assigned to you by your ISP and usually changes everytime you establish an Internet connection). If you have a static IP address (it remains the same each time you connect), I'm not sure if you can leave this out or put in the IP address that you're assigned. If anybody can clear this up for me, please let me know. The mru and mtu lines are your receiving and transmitting packet sizes, I think. I heard someone on IRC ask how to lower the packet size so that a large download wouldn't get in the way of other accesses to the Internet going on at the same time. The speed you can transfer is still the same; it's just smaller packet sizes. A packet size of 552 is smaller than a packet size of 1024. If you don't have pico installed, try some other text editor (emacs, vi, joe, or jed) that you might be able to use to edit that file. After all this is done, all you'll have to do is type minicom as root and then pppd as root. Minicom can be executed by all users, but the Point-to-Point Protocol Daemon (pppd) can only be executed by the superuser (root). I tried changing permissions on the file /usr/sbin/pppd. If you ever accidentally change the permissions on the pppd file/executable, just type chmod 755 pppd from the /usr/sbin/ directory, as root. If you didn't mess with the permissions, you won't need to do the chmod stuff. Using PAP or CHAP? More and more ISPs are switching to PAP or CHAP authentication, which requires a little extra work on your part. Fortunately, this wasn't as hard as I thought it would be. If you're sure your ISP doesn't use PAP or CHAP, you can skip on to the next section. If you use PAP or CHAP, you won't be presented with a login prompt when you dial in with minicom, so that's how you know. You need to fill in /etc/ppp/pap-secrets if your ISP uses PAP, or /etc/ppp/chap-secrets if your ISP uses CHAP. Those files should already be in there, but if they're not, create whichever one you need. All that you really need to do is fill in the chap-secrets (or pap-secrets) file like this: # Secrets for authentication using CHAP # client server secret IP addresses dork * unpopular That's where 'dork' is the username, and 'unpopular' is the password. The asterisk (*) can be left like that. The pap-secrets file also uses the same syntax, just a different filename. In the PPP options file (/etc/ppp/options) it should look like what it was, except with one extra line. 0.0.0.0: /dev/ttyS1 lock crtscts defaultroute asyncmap 0 mtu 552 mru 552 name dork That extra line is name dork, which tells pppd to use that username along with the chap-secrets (or pap-secrets) information when asked for authentication. I use CHAP authentication for my new ISP but instead of just the username, they want the [EMAIL PROTECTED] (pretty weird, huh?), so instead of just "name dork" in /etc/ppp/options I would have to put in "name [EMAIL PROTECTED]". That also goes for /etc/ppp/chap-secrets. Instead of "dork" under "client" I had to put in "[EMAIL PROTECTED]". If anyone has to do the same thing, let me know. Otherwise, filling in just the username should work fine. Dialing In Now, to establish the dialup connection, run minicom. When it loads, it should show the initialization string with the cursor at the end of the text string. Press enter and it should say "OK". Type ATDT #phone#, '#phone#' being the phone number to dial. When the phone on the other end picks up, it should prompt you for a login name and password, which you should type in (unless you're using PAP or CHAP, and if you are, just type Ctrl-a, release Ctrl-a, type 'q', and answer Yes). For some ISPs it will ask whether to use PPP or not, so answer yes. When it shows the PPP data (the stuff that looks like junk and garbage: *&*&*!^%#!^$!%%@#&^$%&*!$%), press Ctrl-a, release Ctrl-a, press 'q', and answer 'yes' to 'Exit without reset?'. That should take you back to the prompt, where you should then type pppd. Typing pppd is critical to establishing the connection. Possible Routing Problems If your ISP uses a gateway (a computer that connects you to the rest of the Internet) that's a different machine than the one you connect to for dialing in, here's what you should do. You need to change the routing configuration on YOUR machine so that you can actually be recognized as a machine on the Internet. The way to tell if you need to change the routing is if you type ifconfig as root and it shows that you have an IP address through your modem, but you can't get ping responses from any hosts, even when you use IP addresses. The way to fix it? First, type route and it will display something like this: Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 127.0.0.0 * 255.0.0.0 U 0 0 3 lo 205.226.158.252 * 0.0.0.0 U 0 0 7 ppp0 As you might expect, most of the IP addresses will probably be different on your setup. The bottom route is incorrect on my system, so to change it, I type route del 205.226.158.252 ppp0 to delete it. Then I type route add default ppp0 to set the new route. Or, if you don't want to delete the old route, you can just set the new route, and it will work just as well. 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 successfully got ping responses. Other Sources of Help That should get your dialup connection up and running. If not, keep trying or ask for help (through any of the *linux* newsgroups or the #Linux* channels on IRC... I hang out in #LinuxHelp on the Undernet). As usual, I support my work fully, so e-mail me at [EMAIL PROTECTED] Using a Chatscript This is a very convenient way to connect to the Internet. Once you get this set up, you can connect with a single command prompt. However, there are things you should know first. Here are things to write down: * What does your login prompt look like? For some ISPs it's login:; for others, it's username:. If you use PAP or CHAP, there will be none. * What does your password prompt look like? Usually it's password: but fill whatever your ISP prompts you for if you want this to work. PAP and CHAP users don't get a password prompt. * How many lines are in between, say, CONNECT 38400 and the first prompt? This is how many \n's you will use. * Are there any other prompts that are presented to you when you first log in? Now go on to making the actual script. As root, create a file to use as the actual chatscript (the text file tells the chat program how 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 that we'll use yourispname.chat as the filename. To edit the file, type pico yourispname.chat. Now put in the following lines into yourispname.chat: ""AT&D2 OK ATDT#phone# 38400 \n ogin: foobar word: altm.415 In place of AT&D2 you can plug in the initialization string that you use. In place of #phone# you should put in the number that you want your modem to call, so for me it would look like ATDT4755868. The '38400' represents the speed you want to connect at and '\n' is telling chat to expect a new line. The part saying 'ogin: foobar' is telling chat to expect the text 'ogin:' to appear somewhere and respond to it by sending the word 'foobar'. The same applies to the next line. Basically you type in any prompts that are presented to you, and then type in what to send back. What is presented and what is sent back can be separated by a space in between. If you dial in, watch for the number of lines between your baud rate (like 38400) and the login: 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. To prevent users other than root from reading from the file and finding out your password for logging in to your provider, you should change the permissions on the chatscript so that only root can read from it. I would do this by typing chmod a-rwx yourispname.chat and then chmod u+rwx yourispname.chat. Now, you should make another script -- a normal (shell) script. Move to /usr/sbin or /usr/bin as root and create the script. Let's call it yourispname; now we proceed to edit the file by typing pico yourispname in /usr/sbin or /usr/bin. The difference is that if you put it in /usr/bin normal users will get to execute the script, but nothing will happen because normal users usually don't have access to pppd and the permissions are set to let only root read, write, and execute the chatscript. Put the following line into the normal (shell) script, yourispname: pppd connect 'chat -f /root/yourispname.chat' /dev/modem 38400 0.0.0.0: asyncmap 0 crtscts defaultroute You might want to change the path to yourispname.chat, having it correspond to the directory that you placed yourispname.chat. After you put in this line, make the file executable and only to be accessed by root (the head honcho on the system) by typing chmod 700 yourispname.chat. For those of you who are lazy or not paying attention, you can change the name 'yourispname' to whatever you want. :) To connect, all you have to do is type the name of the file that you created. All this should be done as root. Disconnecting The way I disconnect is I type killall pppd, which kills the pppd program from running and therefore shuts down communication between your modem and your ISP. Jas has suggested this shellscript: #!/bin/sh kill -TERM `cat /var/run/ppp0.pid` That means you'd put that in a file using a text editor such as pico or vim, and save it as whatever filename you want (ppp-down.sh for Jas' example). Then when you're back at the prompt, type chmod +x ppp-down.sh so that it can be run (executed). I guess I should try this when I disconnect... Modem Trouble There might be all sorts of problems you encounter that are related to your modem, and that is a major obstacle for a lot of people. PnP and Winmodem Linux users who have plug n' play (PnP) modems or the notorius WinModem from US Robotics might have a lot of trouble in getting Linux to recognize that 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", or anything similar. Two ways you can try to get Linux to recognize PnP devices are messing with your BIOS (set the "PnP OS Installed" option to "off") and/or loading Windows 95 first, then using a DOS program called Loadlin to boot a copy of your Linux kernel, usually found as the file called vmlinuz in your /boot/ directory. The file, LOADLIN.EXE, is usually available from your Linux distribution media, be it FTP or CD-ROM. IRQ Conflict Your modem might try to be sharing the same means of communicating with the system with another device that has the same interrupt request, or IRQ. Symptoms of this include an abnormally slow connection, an error about timeouts sending config-requests, and a disconnect soon afterwards. HydroFlow from IRC on the Undernet told me that all he had to do was type setserial /dev/modem irq 10 to get it working. Of course, that's his system, so change the IRQ to fit your own system settings. Then the instructions seemed to have worked. You can check for what devices have which IRQ settings by typing cat /proc/interrupts. Author's Notes When you're upgrading from, say, a generic 14.4 to a 33.6, and both are external, the only settings you need to change in minicom (or the chatscript) are the baud rates and the initialization string. The standard dial string (ATDT) should work for old modems as well as new ones. --------------------------------------------------------------------------- [Counter] Counter put up on October 3, 1997 Copyright � 1997-1998 Joshua Go ([EMAIL PROTECTED]). All rights reserved. Permission to use, distribute, and copy this document is hereby granted. You may modify this document as long as credit to me is given. ---------------------------------------------------------------------- Unsubscribe: [EMAIL PROTECTED] Archive: http://www.vlsm.org/linux-archive/ Linux CD: [EMAIL PROTECTED]
