old-www/LDP/LG/issue25/vermeer.html

200 lines
9.7 KiB
HTML

<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>A Simple Internet Dialer for Linux LG #25</title>
</HEAD>
<!-- <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#A000A0" ALINK="#FF0000"> -->
<BODY TEXT="#000000" BGCOLOR="#FFFFCC" LINK="#0000EF" VLINK="#006600" ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H2>A Simple Internet Dialer for Linux</H2>
<H4>By <a href="mailto:mv@fgi.fi">Martin Vermeer</a></H4>
</center>
<P> <HR> <P>
Those of us that have used Netscape (or other Web browsers) under Windows,
may have felt some envy at the sight of the Dialer, a little box in one
corner of the screen showing that you are on-line and how much time you
have already spent on-line, so your phone bill doesn't go overboard.
<P>In Linux, on the other hand, setting up a dial-up connection and making
it work is often a rather painful process, a "challenge", if you like:
Not only no handy auto-install packages available from your internet service
provider -- you have to figure out everything for yourself, and know what
questions to ask -- but also establishing the connection every time requires
you to go through a sequence of operations.
<P>Open an xterm or a virtual console, log in as root, and run the ppp
startup script (unless of course you use the&nbsp; <FONT FACE="Courier New,Courier">diald</FONT>
package for dial-on-demand, an alterative also. I personally found that
it had too much a mind of its own :-).
<P>Closing the connection similarly requires you to do the same to run
a disconnect script.
<P>One of the first things I did therefore when I decided to learn<B> tcl/tk
</B>was to write a Dialer look-alike. It (<FONT FACE="Courier New,Courier"><A HREF="tkdial">tkdial</A></FONT>)
is attached to this text; it is the first<B> tcl/tk </B>program I <I>ever</I>
wrote -- just under 150 lines -- and that may show.&nbsp; But<B> tcl/tk</B>
is ideal for this kind of job, "glueing" existing command line facilities
together into a beautiful motif-look, mouseable package. Just have a look
at the pictures!
<BR>
<HR WIDTH="100%">
<CENTER><IMG SRC="./gx/vermeer/linkdown.jpg" ALT="[link down]" HEIGHT=98
WIDTH=126 ALIGN=TEXTTOP>&nbsp;<IMG SRC="./gx/vermeer/linkup.jpg" ALT="[link up]" HEIGHT=98 WIDTH=126 ALIGN=TEXTTOP></CENTER>
<CENTER>
<HR WIDTH="100%"></CENTER>
You can put a call to this script somewhere in your X startup, in the case
of Red Hat 5.0, in the file <FONT FACE="Courier New,Courier">/etc/X11/Anotherlevel/fvwf2rc.init.</FONT>
Then you will always have it on your desktop (Linux <I>lives</I> on connectivity!).&nbsp;
It gives precise, interactive, manual control of your ppp link.
<P>There are some things with a dial-up connection which appear not generally
known (<I>I'm&nbsp; not talking to you, geeks and gurus </I>:<I>-</I>).
I'll give a quick run-down of my experiences as I understood them (but
note that I am no professional):
<UL>
<LI>
In order to be able to run <FONT FACE="Courier New,Courier">tkdial </FONT>(which
calls <FONT FACE="Courier New,Courier">pppd</FONT>) as an ordinary user,
you should have<FONT FACE="Courier New,Courier"> pppd</FONT> set suid root.
Additionally, you should be able to read the scripts in the<FONT FACE="Courier New,Courier">
/etc/ppp</FONT> directory, so they should either be world readable or readable
by a group to which you belong. (A nice exercise in basic system administration.
But if you give world reading rights to your <FONT FACE="Courier New,Courier">pap-secrets</FONT>
file, you will deservedly fail your exam!)</LI>
<LI>
The standard Red Hat <FONT FACE="Courier New,Courier">sendmail</FONT> setup
uses <FONT FACE="Courier New,Courier">sendmail -bd -q1h, </FONT>in other
words, activate the <FONT FACE="Courier New,Courier">sendmail </FONT>daemon
once an hour. That's not much. In a dial-up environment you want to send
out mail while the line is up, so change the <FONT FACE="Courier New,Courier">-q1h</FONT>
to <FONT FACE="Courier New,Courier">-q2m</FONT>, for example, for every
two minutes. And follow with the <FONT FACE="Courier New,Courier">mailq</FONT>
command if your mail really has left your machine, before closing down
the ppp link. (If you forget, not to worry: The queue will continue to
try for five days, every time ppp comes up.)</LI>
<LI>
There is an option to <FONT FACE="Courier New,Courier">pppd</FONT> called<FONT FACE="Courier New,Courier">
lcp-echo-interval</FONT>, which can be used to keep the line alive. LCP
means Link Control Protocol, and by putting an option <FONT FACE="Courier New,Courier">lcp-echo-interval
60 </FONT>into either your <FONT FACE="Courier New,Courier">/etc/ppp/options
</FONT>file or on the <FONT FACE="Courier New,Courier">pppd</FONT> command
line when starting it up (i.e. inside the <FONT FACE="Courier New,Courier">tkdial
</FONT>script file), you can keep your line alive even when not actively
browsing.</LI>
<BR>This is important because, with the ubiquity of crashy operating systems,
internet service providers have taken to the habit to cut the line when
nothing has arrived over it for a couple minutes. Imagine starting a five
hour download, going shopping, and returning only to find that three minutes
after you closed the door, the machine crashed and the phone line is still
open, burning up your money for nothing! (This could even happen in principle
with Linux, if the power goes down and you don't have an UPS, or your dog
gnaws off the phone wire. Well, the modem has a time-out also). So Windows
dialers send an empty package once every minute or so to the ISP, telling
"don't worry, I'm still alive!" And when the system crashes, the line cuts
promptly.
<BR>With the option given above, also Linux will send an empty package
every 60 seconds.
<LI>
If you have a POP3 mail service, the best program (transport agent) undoubtedly
is <FONT FACE="Courier New,Courier">fetchmail</FONT>, which transports
the mail to your "system maildrop", typically <FONT FACE="Courier New,Courier">/var/spool/mail</FONT>/&lt;userid>.
Also <FONT FACE="Courier New,Courier">fetchmail</FONT> can be run as a
daemon. You can use <FONT FACE="Courier New,Courier">xbiff</FONT> or <FONT FACE="Courier New,Courier">xmailbox</FONT>
to inform you of arrived mail, and read it with<FONT FACE="Courier New,Courier">
pine</FONT>, <FONT FACE="Courier New,Courier">exmh</FONT> (recommended,
another one of those <B>tcl/tk</B> miracle programs!) or whatever. If you
use Netscape mail, forget about all this, you just have to configure it
on its own terms, which involves learning pretty much the same concepts
anyway.</LI>
<LI>
A <I>trick </I>(I don't really know if this is wise or intended, but it
sure is effective!):</LI>
<BR>If you use very much the same search agent all the time, e.g. Alta
Vista, put it in the file <FONT FACE="Courier New,Courier">/etc/hosts</FONT>.
Find out Alta Vista's IP address with <FONT FACE="Courier New,Courier">ping</FONT>.
The details are left as an exercise for the reader, as well as the explanation
for the speedup achieved (<I>hint: DNS...</I>)
<LI>
Make sure that your machine name (as given in the network setup procedure)
is the same as that which your ISP gave to your mailbox. So, if you are
<FONT FACE="Courier New,Courier">john.smith@isp-international.com</FONT>,
call your machine<FONT FACE="Courier New,Courier"> isp-international.com</FONT>.
Not very romantic, but you avoid problems with an anti-spam feature in
some <FONT FACE="Courier New,Courier">sendmail</FONT> installations, which
bounces mail coming from a "sender" not existing (i.e. not found by the
domain name service) on the internet. (I expect that this feature can be
circumvented by reconfiguring and recompiling <FONT FACE="Courier New,Courier">sendmail.cf</FONT>.
I guess the <FONT FACE="Courier New,Courier">sendmail</FONT> folks just
bet that such a feat is way beyond your average spammer, and I bet they're
right...)</LI>
<BR>Alternatively,<I> make </I>yourself exist; but that requires the co-operation
of your ISP. E.g. EUnet would give you a mailbox name of <FONT FACE="Courier New,Courier">donald.duck@john-smith.pp.fi</FONT>,
which provides you with a slightly more personalized name for your own
machine...<BR>
And make sure to keep the<FONT FACE="Courier New,Courier"> localhost</FONT>&nbsp;
name also valid. Some programs depend on it.</UL>
<HR WIDTH="100%">
<P><I>Acknowledgement: </I>I am indebted to<I> Jaakko Hyv&auml;tti</I>
of EUnet Finland, who provided me with working ppp scripts and plenty good
advice.
<BR>
<HR WIDTH="100%">
<CENTER>
<H2>
Enjoy!</H2></CENTER>
<CENTER>
<HR WIDTH="100%"></CENTER>
<CENTER>
<H3>
(a piece of my desktop:)</H3></CENTER>
<CENTER>
<H3>
-<BR CLEAR=BOTH>
<BR></H3></CENTER>
<CENTER><IMG SRC="./gx/vermeer/mydesktop.jpeg" ALT="[my desktop]" HEIGHT=300 WIDTH=400></CENTER>
<!--===================================================================-->
<P> <hr> <P>
<center><H5>Copyright &copy; 1998, Martin Vermeer<BR>
Published in Issue 25 of <i>Linux Gazette</i>, February 1998</H5></center>
<!--===================================================================-->
<P> <hr> <P>
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
ALT="[ TABLE OF CONTENTS ]"></A>
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
ALT="[ FRONT PAGE ]"></A>
<A HREF="./ayers3.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./singer.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->