Expanding Your Home Network LG#39

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:

READ  HP hardware supported by Linux

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.

READ  HelpDex LG #54

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.

READ  Linux Fax for Dummies LG #28

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!