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 you want to try to get set up quickly, there's 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.linux.net.nz/pppconfig/.
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. Please be patient with this document. It's long, but reading it will, in all likelihood, make things work if you've tried other documents already. Note that your ISP must use PPP in order for this document to work for you.
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), baud rate, and so on. Make sure all this is done, and then choose 'Save as dfl' (saving it as the default) from the main minicom menu.
If minicom complains about not having /dev/modem, get out of the program and type ln -sf /dev/ttyS1 /dev/modem. If your modem was on COM2 under DOS or Windows, use that. Otherwise if you have COM1, for example, you'd use ttyS0 instead of ttyS1. The number after the letters is one less, since Linux starts at 0 instead of 1.
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. Also, make sure the baud rate is high enough to use your modem at its highest speed. I put the baud rate up just one setting above my modem's fastest transfer speed. Your initialization string could possibly also have something to do with unstable connections. If you don't know what you're doing (like me), I would suggest that you use a simple initialization string like AT&D2.
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 126.96.36.199
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 188.8.131.52). Many ISPs have more than one nameserver, so don't be confused if you receive two (or more) addresses when requesting information about 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:
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 184.108.40.206 so I write that down somewhere.
Just add that "nameserver" line in /etc/resolv.conf followed by the IP address of the actual nameserver (220.127.116.11) 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.
As far as I know, you can use anybody's nameserver as long as you have the IP address (numerical, e.g. 18.104.22.168) for it. That means you can have your /etc/resolv.conf file look exactly like mine and it would still work.
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 type pppd, and that's would be a big hassle. Insert the following lines into the file:
0.0.0.0: /dev/ttyS1 lock crtscts defaultroute asyncmap 0 mtu 576 mru 576
The only thing you might need to change is the device entry that tells which device to use for PPP. On my computer, with my 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:
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 DOS or Windows.
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 (one which remains the same each time you connect), put in the IP address that you have been given. If you don't know, you probably have a dynamic IP, so use 0.0.0.0.
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 576 is smaller than a packet size of 1024.
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.
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 firstname.lastname@example.org (pretty weird, huh?), so instead of just "name dork" in /etc/ppp/options I would have to put in "name email@example.com". That also goes for /etc/ppp/chap-secrets. Instead of "dork" under "client" I had to put in "firstname.lastname@example.org". Mindspring, a well-known ISP, does this also; it helps distinguish between people who have one service from a smaller acquired ISP from another acquired ISP, both still using their old names. They might have the same username, and this kind of prevents conflict. Thanks to Mark Peters of Mindspring for this information.
In many other cases, you may only have to fill in the username.
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#, where "#phone#" is the phone number to dial. When the other end picks up, it should prompt you for a login name and password, which you should type in. If you are using PAP or CHAP, just use the Alt-q combination (or Ctrl-a, q if that doesn't work) and answer "Yes" right there without entering the username/password sequence. For some ISPs it will ask whether to use PPP or not. Obviously, you want to answer yes. When it shows the PPP data (the stuff that looks like junk and garbage: *&*&*!^%#!^$!%%@#&^$%&*!$%), press Alt-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.
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 it still doesn't work. The output of ifconfig looks something like this:
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:0x300 lo 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:0 ppp0 Link encap:Point-to-Point Protocol inet addr:22.214.171.124 P-t-P:126.96.36.199 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
If it shows the ppp0 interface, but you can't get ping responses from any hosts, then there might be something wrong with your routing. 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 188.8.131.52 * 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 184.108.40.206 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. Not deleting the old route is probably safer.
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 received ping responses.
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'd recommend #LinuxHelp on the Undernet.)
As usual, I support my work fully, so e-mail me at joshuago at users dot sourceforge dot net. Please keep it short and simple, while providing the necessary information.
This is a very convenient way to connect to the Internet. Once you get this set up, you can connect with a single command. However, there are things you should know first. Here are things to write down:
The best thing to have done before this is to have made sure that you could dial in with minicom and use pppd to establish a connection. That would have ensured that it was possible for you to get connected. This method is a permanent solution so you won't have to go through the tedious process of typing several keystrokes and waiting to enter the next command.
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. Don't put in the last two lines if you're using PAP or CHAP because the passwords aren't authenticated with plain text like that.
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 go-rwx yourispname.chat.
Now, you should make another script -- a normal (shell) script. Move to /usr/sbin 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. Keep in mind that you can change the filenames to whatever you want.
Put the following lines 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.
To connect, all you have to do is type the name of the file that you created. All this should be done as root.
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...
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.
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.
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.
Since some of you might be wondering about how to find exact initialization strings for your modem, FusionGyro wrote:
I would like to offer a tip for you to possibly include in your FAQ file. 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. Then just fire up the control panel, open "Modems", highlight the correct modem, press "Properties", hit the "Connection" tab, press "Advanced", and then hit "View Log". (Gee, that wasn't so easy, was it ;). You should be staring at a text file. This file will contain everything that was sent and recieved until a PPP connection was made. Here's a cutout from the example he gave:
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 V34 12-13-1998 02:56:07.36 - Modem inf path: MDMTI.INF 12-13-1998 02:56:07.36 - Modem inf section: Modem4 12-13-1998 02:56:07.61 - 115200,N,8,1 12-13-1998 02:56:07.62 - 115200,N,8,1 12-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: Ok 12-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:V42B 12-13-1998 02:56:27.67 - Interpreted response: Informative 12-13-1998 02:56:27.67 - Recv: <cr> 12-13-1998 02:56:27.67 - Interpreted response: Informative 12-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.
While much of it is useless, it does contain the important stuff: AT &F E0 V1 W4 &D2 &C1 S0=0 -C1, etc.
Poul Petersen wrote in about a site where you can look up information about your modem, including the init string. It's at http://www.spy.net/~dustin/modem/.
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.
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. Use that instead of "pico" wherever "pico" appears as a command. It doesn't matter what text editor you use.
Copyright © 1997-1999 Joshua Go (joshuago at users dot sourceforge dot net). 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.