old-www/LDP/LG/issue33/richardson.html

306 lines
12 KiB
HTML

<!--startcut ==========================================================-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<title>DialMon: The Linux/Windows diald Monitor LG #33</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#A000A0"
ALINK="#FF0000">
<!--endcut ============================================================-->
<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1><font color="maroon">DialMon: The Linux/Windows diald Monitor</font></H1>
<H4>By <a href="mailto:mike@quaking.demon.co.uk">Mike Richardson</a></H4>
</center>
<P> <HR> <P>
<h3>In The Beginning</h3>
<p>There seem to be quite a number of small networks, either at
home or at small companies, which use Windows (be they 3.1 or
95/98/NT workstation) clients, and a Linux box as a dial-up
router to the InterNet at large. A common setup is to use <font
color="#FF0000">IP masquerading</font>, so that the the clients
can hide behind a single IP address, with <font color="#FF0000">diald</font>,
the dial-on-demand daemon, so that the Linux box connects as and
when required. This works pretty well</p>
<ul>
<li>you only need to pay for the single IP addess rather than
a subnet (ie., a block of IP addresses)</li>
<li>the masquerading almost automatically provides a firewall</li>
<li>you only pay connection charges when needed (in places
where local phone calls are not free)</li>
</ul>
<p>The real problem with this is that users on the Windows
clients have no real indication of the state of the dial-up link.
So, if a connection fails to materialise (ie., your web browser
cannot find a URL), you may not know whether the URL doesn't
exist, or the dial-up link didn't come up.</p>
<P> <HR> <P>
<h3>Let There Be Light</h3>
<p>Dialmon was originally conceived as a simple monitor to
provide the Windows user with some information about the link. In
its original form, it comprised a single daemon process <font
color="#FF0000">dialmon</font> which ran on the Linux box in
parallel to <font color="#FF0000">daild</font>, and a client <font
color="#FF0000">dialm</font> to run on the Windows client.</p>
<p>The <font color="#FF0000">dialmon</font> daemon connected to
the <font color="#FF0000">diald</font> daemon using the laters
control fifo, requesting that state information be retured via a
second fifo which <font color="#FF0000">dialmon</font> created.
When <font color="#FF0000">dialm</font> clients connected, the
state information provided by <font color="#FF0000">diald</font>,
suitably filtered to remove un-needed stuff, was passed back to
the <font color="#FF0000">dialm</font> client, which could then
display the current dial-up state. Two sorts of information were
displayed, the actual link state (up, down, connecting ...) and
message output generated by <font color="#FF0000">diald</font>'s
connect and disconnect scripts.</p>
<p>So if, for instance, you pointed your browser at <a
href="http://www.linuxgazette.com">http://www.linuxgazete.com</a>
(sic) then you could see the link come up and, when the browser
failed to find the URL, you hopefully realised that you should
have pointed it at <a href="http://www.linuxgazette.com">http://www.linuxgazette.com</a>.</p>
<P> <HR> <P>
<h3>Keep Your Finger On The Pulse</h3>
<p>This seemed a big improvement, but there were still some more
minor niggles. Firstly, the web browser would often time out a
URL before the dial-up link came up (particularly in the early
evening!), which meant trying the URL a second time. Of course,
by this stage the dial-up link had often just gone down again on
account of there being no traffic. Secondly, if you ran sendmail
or similar on the Linux box and used a mail reader on the Windows
client, then to get an urgent item of mail on its way from the
Linux box to your ISP (or to check for incoming mail), you'd need
to indulge in some trick like using your web browser simply to
force the link up. Try explaining that one to your users!</p>
<p>So, <font color="#FF0000">dialmon</font> was extended to allow
control over the link Actually, these changes spanned three
releases, but the effect is that users on the Windows clients,
can, subject to various access controls, request that the link be
brought up, request that it be taken down, and even request that <font
color="#FF0000">diald</font> itself be stopped and restarted with
a different configuration (which appeared because I need to use
two ISPs). This feature also has the side effect that if <font
color="#FF0000">diald</font> crashes, then <font color="#FF0000">dialmon</font>
will restart it.</p>
<p>The access control can be based either on the host on which <font
color="#FF0000">dialm</font> is running, or on a user name with
password checking. The latter can be set up to use Linux box user
names which do not have login access and which are different to
the Windows user's real user name (if any) on the Linux box.</p>
<P> <HR> <P>
<h3>Icing On The Cake</h3>
<p>One or two users asked whether <font color="#FF0000">dialmon</font>
could show some load information, ie., the amount of traffic
going through the dial-up link. Having done nothing myself,
someone (Jim Mathews, thanks) provided some code to give an
indication of this via an icon in the Win95/98/NT system tray.
This has now been extended to show a pair of bars in the <font
color="#FF0000">dialm</font> window, one for transmit and one for
receive, which show, at least approximately, the percentage of
the dial-up bandwidth which is being used.</p>
<p>This is quite useful if you are doing a large download, to get
an idea of whether it is worth carrying on, or whether you should
kill the download and try later (while America sleeps, maybe).</p>
<P> <HR> <P>
<h3>Building The Edifice</h3>
<p>So, how does one set all this up? The distribution (<a
href="ftp://sunsite.unc.edu/pub/Linux/system/daemons/dialmon-0.4.tgz">ftp://sunsite.unc.edu/pub/Linux/system/daemons/dialmon-0.4.tgz.THISONE</a>)
contains the Linux and Windows sources, plus prebuilt Win31 and
Win95/98/NT clients. Once you have built and installed the Linux <font
color="#FF0000">dialmon</font> daemon, you need to configure it.</p>
<p>I'll describe the setup I use at home (which is also the
office). The network comprises two Linux boxes, of which one
called <font color="#FF0000">quaking</font> runs <font
color="#FF0000">diald</font> and sendmail, plus a Windows 3.1
machine called <font color="#FF0000">rover</font> which my wife
Tina mainly uses, and a Windows 95 machine called <font
color="#FF0000">gingling</font> which I use. I want to be able to
bring the dial-up link both up and down, and to switch between
two ISPs, and I want to allow Tina to bring the link up and down,
but not to switch ISPs.</p>
<p>The <font color="#FF0000">dialmon</font> daemon uses two
configuration files, <font color="#FF0000">/etc/dialmon.conf</font>
to specify its own setup, and the options to be given to client
machines, and <font color="#FF0000">/etc/dialmon.users</font> to
specify options to be given to specific users. These are shown
below:</p>
<p><strong>/etc/dialmon.conf</strong></p>
<pre>[host]
port 7002
force 90
fifo /etc/diald/diald.ctl
allow up
ddconf Planet &quot;-f /etc/diald.conf.planet&quot;
ddconf Demon &quot;-f /etc/diald.conf.demon&quot;
</pre>
<p>This specifies that <font color="#FF0000">dialmon</font>
listens for <font color="#FF0000">dialm</font> clients on port
7002 and will force the dial-up link up for 90 seconds (after
which, if there is no traffic on the link, diald will shut it
down). The <em>allow up</em> line specifies that any client <font
color="#FF0000">dialm</font> is allowed to bring the link up. The
two <em>ddconf</em> lines specify ISP configurations; the text in
&quot;....&quot; is the arguments to <font color="#FF0000">diald</font>.</p>
<div align="left">
<pre><strong>/etc/dialmon.users</strong></pre>
</div><div align="left">
<pre>[mike]
passwd dialmon
allow up
allow down
allow ctrl
[tina]
passwd dialmon
allow up
allow down</pre>
</div>
<p align="left">The users file specifies the access for myself
and Tina. The lines <em>passwd dialmon</em> indicates that when <em>mike</em>
(or <em>tina</em>) connects, the password supplied should be
checked against that for the user <em>dialmon</em> rather than <em>mike</em>
(or<em> tina</em>).</p>
<p align="left">Lastly, the daemons run from a startup script <font
color="#FF0000">/etc/rc.d/init.d/diald</font> which is linked as <font
color="#FF0000">/etc/rc.d/rc3.d/S99diald</font> (I use the RedHat
distribution which has SysV style startup scripts):</p>
<p align="left"><strong>/etc/rc.d/init.d/diald</strong></p>
<pre>#!/bin/sh
#
# diald Start or stop the dialer daemon
#
. /etc/rc.d/init.d/functions
if [ ! -f /etc/sysconfig/network ]; then
exit 0
fi
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = &quot;no&quot; ] &amp;&amp; exit 0
[ -f /sbin/ifconfig ] || exit 0
# See how we were called.
case &quot;$1&quot; in
start)
echo -n &quot;Starting dialer demon: &quot;
/sbin/route del 0.0.0.0
# Start dialmon, which will in turn run diald with the Demon
# configuration, and will if necessary kill off the ppp0
# PPP daemon
#
daemon /usr/sbin/dialmon -rDemon -pppp0 -b28800
[ -f /proc/sys/net/ipv4/ip_dynaddr ] &amp;&amp;
echo 1 &gt; /proc/sys/net/ipv4/ip_dynaddr
echo &quot;&quot;
;;
stop)
# Shut dowm. Don't use killproc because we want a SIGTERM and
# not a SIGKILL, so that dialmon can terminate diald (and maybe
# pppd as well).
#
echo -n &quot;Shutting down dialer daemon: &quot;
[ -f /var/run/dialmon.pid ] &amp;&amp; (
kill -TERM `cat /var/run/dialmon.pid`
rm -f /var/run/dialmon.pid
echo -n &quot;dialmon &quot;
)
echo &quot;&quot;
;;
*)
echo &quot;Usage: diald {start|stop}&quot;
exit 1
esac
exit 0</pre>
<p>The <em>-rDemon</em> argument to /usr/sbin/dialmon tells
dialmon to initially run diald with the <em>Demon</em>
configuration. The <em>-ipppp0</em> argument says that, when <font
color="#FF0000">dialmon</font> restarts <font color="#FF0000">diald</font>,
it should kill any ppp daemon running for the <em>ppp0</em> link
(it looks in /var/run/ppp0.pid), and <em>-b28000</em> says that
the nominal link bandwidth is 28000 baud (used for the receive
and transmit displays).</p>
<P> <HR> <P>
<h3>In Conclusion</h3>
<p>I've found that <font color="#FF0000">dialmon</font> makes
life easier for myself, and my wife (who claims to be a
computerphobe but loves eMail) uses it all the time; I've also
installed it on the office network of one of my clients. Quite a
number of people have eMail'ed me about it (thanks for the bug
reports, suggestions, contributions, not to mention the thanks)
so I'd like to think that its made life a bit better for them as
well.</p>
<p>As I mentioned above, it should be available from <a
href="ftp://sunsite.unc.edu/pub/Linux/system/daemons/dialmon-0.4.tgz">ftp://sunsite.unc.edu/pub/Linux/system/daemons/dialmon-0.4.tgz.THISONE</a>
(<em>THISONE</em> on account of an upload error, please ignore
the <em>tgz</em> file without the extension unless it's been
sorted!) Please feel free to eMail me at <a
href="mailto:mike@quaking.demon.co.uk">mike@quaking.demon.co.uk</a>
.</p>
<!--===================================================================-->
<P> <hr> <P>
<center><H5>Copyright &copy; 1998, Mike Richardson <BR>
Published in Issue 33 of <i>Linux Gazette</i>, October 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="./york.html"><IMG SRC="../gx/back2.gif"
ALT=" Back "></A>
<A HREF="./kacur.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
<P> <hr> <P>
<!--startcut ==========================================================-->
</BODY>
</HTML>
<!--endcut ============================================================-->