ALINK="#FF0000">

"Linux Gazette...making Linux just a little more fun!"


Expanding Your Home Network

By JC Pollman


You have struggled and gotten your home network working. I assume you have some sort of dial on demand, printer serving, and probably file sharing using samba. After a couple of weeks of relaxing and self-congratulating, you ask yourself: now what?

  What follows are bits and pieces of useful improvements I have come across while running my own home network. All of them provide me with added features and greatly extended my knowledge of Linux. Although I use the Redhat distribution, they should work on all distributions.  What I present here are quick set-ups, to truely understand what you are doing you have to read the How-Tos and files that come with the programs.

Am I Connected? You know by now that, just because the modem dialed, you are not guaranteed of getting connected. And it would also be nice to know when the modem goes off line - especially if  you are using an internal modem and your server is without a monitor like mine. Linux obviously knows when these things happen as it executes commands when the on-line-status changes. You can take advantage of this by putting your own commands in the scripts it runs. When the modem connects AND you are logged into your ISP, Linux runs the /etc/ppp/ip-up script, and when the modem goes off line, it runs the /etc/ppp/ip-down script. All you have to do is to add a line at the end of these scripts to tell you what happened. I use sound files to announce the connect status. One of the last lines of my ip-up is:

cat /etc/ppp/doom.au >/dev/audio &

This "plays" the doom.au file and lets me know that I am fully connected to the internet. Add a similar line to your ip-down file to tell you when the modem goes off line.

TIME. You can also use the ip-up file to keep your server's time accurate. There are several time programs you can use, but I find netdate the easiest. I just add these lines after my sound line:

/usr/sbin/netdate isp-computer

clock -w

where isp-computer is the name of a computer at my ISP, and clock -w writes the time to the cmos.

Cleaning Up after pulling the plug. My wife is famous for finding something on the net and then wanting to make an immediate phone call. This usually means she pull the modem's phone wire out of the jack and then makes her call. This is nothing tragic, but I ended up with lots of ip-down scripts that never finish executing. Typing ps ax on Saturday usually gave me a half dozen processes to kill. I got tired of this and wrote a script to clean them up automatically:

#!/bin/sh kill `ps ax|grep down|cut -c 1-5`

  I set this up as a cron job, so it runs every night.

One Home for All. You probably have Linux running on more than one of your client programs. Keeping your personal setup in sync between computers becomes a pain after a while. Additionally, it would be nice when you run your email program to have all your folders available, and have your bookmarks available when you startup Netscape. The solution is to have use the /home directory on the server as the /home directory on all the computers. To do this, make sure all the kernels have nfs compiled into them, export the /home directory on the server, and then mount the server's /home directory on the clients. The server uses the file: /etc/exports to decide what, and how, to allow other computers to use. The appropriate line from my exports file is:

/home  *.kulai.org(rw)

where my network is kulai.org.  Then you can mount the server's /home directory by putting a line in your fstab that looks like this:

192.168.124.10:/home /home      nfs noauto,rw,rsize=8192,wsize=8192 0 0

Note: my home server's ip address is: 192.168.124.10 Yours will be different. Then mounting the /home directory with a line in your rc.local like this:

mount  /home

This is a fairly simple process, but there are some gotchas you need to be aware of. NFS does not have a solid reputation for reliability and security. Some versions of the kernel do not work well with NFS, so check the news groups and dejanews if everything looks good but you can not mount /home. Also, the users on the different computers must all have the same UID and, I think GID, on each computer. For example, if Fred is UID 500 on the server, he must be UID 500 on all the other computers - as stated in the /etc/passwd file. There are ways around this, but life is much easier if the UIDs match. Additionally, mounting the entire /home directory is probably not the best solution when what you really want is just /home/user. You can get around this in xdm by using the Xstartup and Xreset files to mount and unmount the user's home directory when they login and logout. This method has problems with KDE as KDE does not shut down fast enough and so Xreset will not unmount the directory.

A more elegant solution is to use automount. It will automatically mount /home/user directories, and can also automount  your floppies and cdroms. First, recompile your kernel with automount turned on. Then install the autofs program.  Then create the file: /etc/auto.master. It needs only one line:

/home   /etc/auto.home --timeout 120

which says: use /home as the mount point, and the file:/etc/auto.home to define the subdirectories.  The timeout option is for automatic unmounting after 120 seconds of inactivity. If you want to use this to automount floppies, cdroms, etc, you will need another line - read the Howto and Install files.

Then create the /etc/auto.home  file.  A line from mine reads:

nick    -rw,soft,intr,rsize=8192,wsize=8192     192.168.124.10:/home/nick

The first entry: nick , is the subdirectory under /home that autofs will use to mount the nfs directory:  192.168.124.10:/home/nick.  Note, the server must now export each user's home directory individually, e.g. the exports file now reads:

/home/nick    *.kulai.org(rw)

Another advantage of this setup for the adventurous: I run several un*xes at home.  If I run the same version of the programs in them that I run in Linux, by mounting my home directory I keep the same initialization files, e.g. I use icewm for my window manager in Linux and FreeBSD, because I mount the same /home directory for both OSes, my menus stay the same.

Common Passwords. As computers, and especially hard drives, come and go, I find that keeping the passwords in sync is also an annoying task. Linux provides a simple solution: NIS. Basically, the server does the login, so, no matter which computer you are using, the login verification is run against a single file on your server. This will only keep the un*x passwords the same: I manually made the MS Windows passwords the same, so when my spouse, or kids, get on the computer, they type the same user name and password no matter whether they are running Windows or Linux.  You will have to read the NIS Howto as it is beyond the scope of this article to explain how to set it up.

HTTP Proxy. If your family members go to many of the same web pages you can speed up the "download" time by caching the pages on your server. That way, if your spouse goes to www.Yahoo.com in the afternoon, and your kids go to it when they get home from school, they get the copy off of the server which is much faster than actually connecting to the site. This pays big benefits when several of you are on the internet at the same time.  You can setup Apache to do this if you have Apache running already, or check http://freshmeat.net for a http proxy program.

USENET News.  I assume that anyone reading this article is also a big user of the usenet news groups.  Setting up a full fledged news server for home is just too much work, but a program named leafnode may be just the solultion.  After setting it up and allowing it to get the list of news groups from your current server, point your news reader (Linux, Windows, or in any other operating system) to your server.  Subscribe to the groups you want and then rerun leafnode. It will only get the articles from the groups people on your network subscribed to.  I set it to run, via cron, at 4 in the morning so at 5, when I arrive with my cup of coffee, all the articles for all my groups are ready and waiting for me on my server. Sweet!


Copyright © 1999, JC Pollman
Published in Issue 39 of Linux Gazette, March 1999


[ TABLE OF CONTENTS ] [ FRONT PAGE ]  Back  Next