Notice: This material is excerpted from Running A Perfect Internet Site with Linux, ISBN: 0-7897-0514-1. The electronic version of this material has not been through the final proof reading stage that the book goes through before being published in printed form. Some errors may exist here that are corrected before the book is published. This material is provided "as is" without any warranty of any kind.

Copyright ©1996, Que Corporation. All rights reserved. No part of this book may be used or reproduced in any form or by any means, or stored in a database or retrieval system without prior written permission of the publisher except in the case of brief quotations embodied in critical articles and reviews. Making copies of any part of this book for any purpose other than your own personal use is a violation of United States copyright laws. For information, address Que Corporation, 201 West 103rd Street, Indianapolis, IN 46290 or at support@mcp .com.

Chapter 5 - Setting Up Your Site for General Use

Now that you've got Linux installed, you need to do a bit of fine-tuning. Once that's done, you'll be able to use your Linux system, and then you can get on to the fun stuff of setting up all of the tools for your site!

In this chapter, you learn how to:

General Site Preparations

Let's take a bit of time to get familiar with your system before proceeding to deal with adding users and other system administrator tasks.

You may find that you need to recompile your kernel before you continue. The default kernel you end up with with Slackware can take up a good chunk of your system's memory. If it takes up a big enough chunk of your RAM, that forces your system to go into swap space that much earlier.

The kernel is stored as a compressed file, and loaded into memory as your system boots. The file is /zImage or /vmlinuz (only one of these will exist on your system). To see the file size, type ls -l filename. The compressed file is expanded, and then loaded into memory, so if it looks like the size you see will take up more memory than you'd like, imagine how much it might take up when expanded.

For information on replacing your kernel, see chapter 16, "Upgrading Your Software."

Booting Your System

The first thing you need to do before proceeding is to reboot your Linux system if you haven't done it yet. When you see the LILO prompt, press either the Alt key or the Ctrl key. Then, at the prompt, enter the name you assigned to Linux in your LILO setup (e.g., linux).

If you can't remember what you called your Linux session, just press the Tab key. That will list your options.

Now, you can watch screens and screens of messages flash by as Linux boots, telling you what's happening in the process. Finally, you should get to the following (Note that your machine name will appear in place of catherine): Welcome to Linux 1.2.8. catherine login:

If you didn't set your machine name during the installation process and instead are using the defaults, you can edit the file /etc/rc.d/rc.M. Find the lines in this file that refer to hostname and change it from the default to the name of the computer you're setting up (e.g., catherine).

Linux and Drives

Unlike MS-DOS and Macintosh systems, UNIX systems look at drives (hard drive, floppy drives, and so on) as directories in their filesystem. The general format of the command used to mount a device is:

mount device_name location_to_mount_to

For example, if you wanted to mount a data CD, and your CD-ROM is defined as /dev/cdrom (all of your devices are listed in the /dev directory), and wanted to mount the CD at /mount/cd you would use:

mount -t iso9660 /dev/cdrom /mount/cd

This breaks down as follows:

If you wanted to mount a floppy disk using the filesystem ext2, at device /dev/fd0 (the A drive in MS-DOS terms), and to /mount/floppya, you would use the following:

mount -t ext2 /dev/fd0 /mount/floppya

When you're finished using the filesystem you mounted, you can't just remove the disk, CD, etc. You need to first unmount the drive. This tells your system to finish writing any data that's left, and that the path you mounted it to no longer exists. To unmount something, use:

umount device_name

To unmount the CD-ROM in the first example in this section, you would simply type:

umount /dev/cdrom

Linux and File Permissions

While most UNIX users are familiar with file permissions, it is important to understand them as a system administrator. It's through setting your file permissions appropriately that you will keep your system secure. The easiest way to make an insecure system is to have permissions that make an intruder's work easy.

File permissions are broken down into groups to determine the access for the file's owner, the owner's group, and everyone.

t     rwx     rwx     rwx

The structure of file permissions is, reading the line above from left to right:

The first item in the permissions values describes the file type. It can be one of the following:

The following three sets of three each have the same permission options:

For example, the file permissions:

-rwxrw-r--

The permissions above define a normal file. Its user can read, write, and execute it. The user's group can read and write it, but not execute it. Anyone outside the user's group can only read it.

Now, to set these permissions, you use the command chmod. Since each item (except for the type definition) is either on or off, either blank or with a letter, permissions can be expressed with the binary numbering system.

In the case of permissions, the binary usage is 1 for "allowed," and 0 for "disallowed." However, instead of using binary to enter the permissions, you'll use the decimal versions. Each variation on permission combinations has its own decimal value, which is the sum of the binary components (see table 5.1).Table 5.1 Decimal Equivalents of the Permission Combinations

Permission
Set     Binary  Decimal
---     000     0
--x     001     1
-w-     010     2
-wx     011     3
r--     100     4
r-x     101     5
rw-     110     6
rwx     111     7

Let's break down the example from above, -rwxrw-r--:

To set the above permissions, you would use:

chmod 764 filename

If you want to set the file to run as something other than the standard, you can do this with chmod as well. In particular, you can set this file to run as SUID (set user ID), or SGID (set group ID). By doing this, you tell the file to run as though it's a member of the particular group or owner.

Setting a file to SUID or SGID simply requires adding an extra digit to the permissions you use with chmod (see table 5.2). Technically, if you don't use anything, it assumes a leading 0.Table 5.2 The Set ID chmod Settings

Decimal SID Setting
0       Standard file. Runs as the user who invokes it.
2       SGID: File runs as a member of its group.
4       SUID: File runs as its owner.
6       Both SUID and SGID.

The example we've been using in this section would be permission set 0764. If it were 2764, it would look like -rwxrwsr--. 4764 would be -rwsrw-r--. 6755 would be -rwsrwsr--.

Linux and Environment Variables

When you log into an account, it starts up a shell. This shell runs in an environment, with its own variables that define your preferences and settings. There are two types of environment variables, exported and local.

Exported environment variables exist outside of your shell script. They're mostly defined in your startup script, which is .login or .profile. To get a list of your current environment variable settings, type env. Some examples of environment variables and their settings for the user fred might be:

HOME=/home/fred

SHELL=/bin/tcsh

The export environment variable people are most likely to want to change will be the PATH statement. Just as with an MS-DOS path statement, this variable defines all the paths the system automatically searches when you enter a command. You can modify your PATH statement in your .login or .profile file.

How you set an environment variable as exported depends on the shell you're using:

Local environment variables are only used within the shell script. When the script is finished running, the variable no longer exists. Keep in mind that your .login or .profile script actually runs the entire time you're logged in. Local environment variables are mostly used in scripts written for specific purposes, where you don't need the values set to last past the running of the script. To set a local environment variable regardless of the shell type, simply use the format:

VARIABLE=value

For example, TERM=console tells your system that you typically log in from the actual console instead of dialing in.

Mounting Remote Home Directories

If you're running a large site you will likely want to have user home directories on their own drive. This is because home directories can take up a lot of space, depending on whether or not you set disk quotas, and how large those disk quotas are per user. Remember, space tends to fill.

If you haven't set this hard drive up for use yet, there are a few things you need to do:

  1. Make sure your computer's BIOS recognizes this hard drive, and take note of which hard drive it shows up as (1, 2, 3, etc.).
  2. In Linux, take note of the last hard drive name you have assigned (hda, hdb, etc.)

If you're not sure what exactly you've already set up, type mount (as root) to get a list of the drives your system is set to use.

  1. 3. Use fdisk to add another disk to your Linux setup (using fdisk is covered in chapter 3, "Getting Ready To Install Linux from the CD-ROM").

Don't forget to format the drive for Linux!

Now, to turn this disk into /home. To turn your extra drive into the home directory, do the following:

  1. Log in as root.
  2. 2. Back up your home directory!!! Change it to something like home-original for now, by typing:
mv /home /home-original

Make sure to do this drive switch when no one is using your system! See chapter 15, "Upgrading Your System" if you are making this change after your system is already up and running with users.

  1. To ensure that the filesystem on the new drive is set up properly, run fsck manually (it usually checks the filesystem during bootup). If, for example, your new drive was hdc, then you would type the following to force an immediate check:
fsck -f -y /dev/hdc
  1. Edit the file /etc/fstab
  2. Now we'll tell your system how to mount the new drive. The format of an fstab line is:
devicename   mount location      filesystem type   options

The general options available are:

You can use multiple options separated by commas, or just the word defaults if you don't want to set anything special.

For example, if your main partition is /dev/hda1, and you're using the ext2 filesystem, this drives's entry would look like:

/dev/hda1      /            ext2            defaults

For the new drive (I'll use /dev/hdc1 as an example), the entry might be:

/dev/hdc1      /home         ext2            defaults

This tells your system to mount the new drive partition as its /home directory.

  1. Shut down your system (shutting down is covered later in this chapter) and reboot.
  2. Change into the backup of your home directory (as root). In my case, this would be cd /home-backup
  3. Move the contents of this directory to the new home "directory" with mv * /home

If you're concerned with something happening to your files during the move, you may want to make a backup of the backup directory just in case.

Adding Machines to Your Network

Once you get your main server set up, you can start setting up the other machines in your network (if there are other machines). You can add all or some of them now if you want to be able to install some servers on separate machines, or have at least one machine other than the main Internet server to test your services from. Or, you can proceed and get your main server completely set up, and then come back and set up some or all your other machines. The order you work in when it comes to adding machines to your network really depends on your personal preferences and needs.

The work you will need to do when adding machines is identical regardless to when in the site setup process you decide to add them.

For each machine you'll add, you need to go back to chapters 3 and 4 and install Linux on them. However, keep in mind that these other machines are not your main server. You won't need to install any of the main services on these machines, because they will use clients and look to your server instead. Other differences will be addressed in this section, so be sure to read it before you go back and begin setting them up.

Be sure to pick your Ethernet cards from the list in the Hardware How-To. Also, be sure to get the proper cable types.

Telling the Server About Other Machines

When you add a machine to your network, you have to tell the server it exists. This ensures that the main server knows how to route each machine's packets to and from the Internet, and within your own network. Fortunately, since the Linux setup utility takes care of storing the network information required for the other machines, all you have to worry about is adding them to the server.

To add these files to your server, log in as root and edit the file /etc/hosts. For each machine-and each incoming modem line, and each device you want people to be able to connect to such as printers-you'll need to enter two pieces of information: the IP address, and a list of name aliases.

Assigning IP Addresses

Assign each machine and device its own IP address from within those assigned to you. There's no necessary order of what numbers to use where. Most simply choose one number up as they add machines to the network.

It's helpful to put physical labels on machines, and especially modems. On a machine, use the IP address and name. On a modem, use the IP address and its phone number. This will save on running around time when dealing with technical problems.

If you're setting up subnets, be sure to read ahead in the Setting up subnets section before proceeding.

Assigning the Alias List

This alias list includes the actual full domain name plus host name for the machine, plus any aliases you want to add, all separated by spaces. Aliases might include:

Many sites like to name their hosts on a theme. It's much more interesting to the sysadmin than looking at a list of meaningless host names like machine1, machine2, etc. If you have a favorite hobby, sport, genre of movies or books, or time period you can use it to come up with related host names. Just make sure not to pick something that will run out of options too quickly!

An example of an entry (pulling an IP address and domain name out of the air, both may actually exist on the Net) for a machine is

195.85.231.5     baseball baseball.sports.net

Your main server might have a longer entry, for example

195.85.231.1     fencing fencing.sports.net www.sports.net ftp.sports.net

Setting Up Subnets

If the discussion of subnets in chapter 1, "Why Create Your Own Site with Linux?" led you to determine that you need to use subnets within your site, then follow this section carefully. If you don't intend to use subnets, go ahead and skip to the next.

Typically, you'll see the number 255.255.255.0 and be told that this is your netmask (on a class C address, on class B it would be 255.255.0.0 and class A it would be 255.0.0.0). However, this can become your subnet mask.

In order to tell your site what your subnets are, you need to assign a subnet mask. In order to assign a subnet mask, you need to think of IP addresses in terms of bits. An IP address is made up of four sets of 8 bits.

11111111.11111111.11111111.00000000

The decimal for the first set is

128+64+32+16+8+4+2+1=255

So, these bits all together form the class C netmask:

255.255.255.0

When you assign subnets, you use the last set of eight bits to tell your site how many subnets you're going to have. Because of this, if you want a number of subnets that doesn't quite work out in binary, you'll need to estimate the next step up. Let's say you want 6 subnets. You need to look and see how many binary combinations you have to use to get this number of subnets.

Binary
Digits  Possibilities   Subnets
One     0       Two
        1
Two     00      Four
        01
        10
        11
Three   000     Eight
        001
        010
        011
        100
        101
        110
        111

To get six subnets, you need to start with eight subnets and use only the first six combinations: 000, 001, 010, 011, 100, 101. The last two combinations aren't used: 110 and 111.

As you can see, you will need to waste a bit of address space to get six subnets. Now that we know how many binary digits we need to get six subnets, we need to figure out the final IP decimal to use.

The netmask we're using for six subnets is:

11111111.11111111.11111111.11100000

The decimal for 11100000 is 128+64+32=224.

So, if you wanted six subnets, your netmask would suddenly become 255.255.255.224. In fact, if you wanted seven or eight subnets you'd use the same netmask.

Each of the six subnets will be within a particular IP range. To determine these IP numbers, we have to go back to the bit format. In figure 5.3, we determined which bits our six subnets would start with. From there, we can determine the IP ranges for each of these subnets.

Subnets Bit Format      IP Range
000     00000001-00011110       1-30
001     00100001-00111110       33-62
010     01000001-01011110       65-94
011     01100001-01111110       97-126
100     10000001-10011110       129-158
101     10100001-10111110       161-190
110     193-222
111             225-254

00000001 is the lowest valid host; 00000000 is reserved. 255 (11111111) is also reserved.

So, if you had the IP assigned 235.23.42, a machine in subnet one might be 235.23.42.13. A machine in subnet three might be 235.23.42.68.

Telling Your Nameserver About Your Machines

Your nameserver-since you're providing your own primary nameservice-needs to know about the other machines on your network as well, so it can translate them into the appropriate IP numbers for the rest of the Internet.

As root, edit the file /etc/named.rev. Now, for each machine and incoming modem line, plus any devices you want people to be able to access from outside your network, you need to make a nameservice entry. This entry is in four parts:

Putting this entry together, it would look like:

5     IN     PTR     baseball.sports.com

Mounting Directories by NFS

Network File System (NFS) is a method of mounting directories across a network as though they were on your local machine. There are two aspects to NFS mounting. You have to set up the machine whose directory is being mounted to allow it, and you have to set up the machines access the directory to do so.

Setting the NFS Server To Allow Access

The machine whose directory is mounted is the NFS server for that particular directory. There are a few files you need to attend to in order to set a server up to allow other machines to access its files via NFS.

First, you need to edit the file /etc/exports (create it if it doesn't already exist). Each line in this file contains two pieces of information. The first is the path for the directory you're allowing other machines to access. The second is a list of machines who are allowed to access the directory, and their permissions. An example (rw stands for read and write permissions):

/home     hockey (rw) baseball(rw) soccer(rw)

Make sure that the file /etc/rc.d/rc.net1 has the following components in place:

if [ -x $NFSD ]; then
        echo -n " 'basename $NFSD'"
         $NFSD -f /etc/exports
fi
if [ -x $MOUNTD ]; then
        echo -n " 'basename $MOUNTD'"
         $MOUNTD
fi

Setting Other Machines To Access NFS Mountable Directories

The machines NFS mounting the directories are clients. Sometimes you'll have a machine being both server and client, if it needs to both offer and mount NFS directories. Make sure if a machine is performing this dual function that you do both the server and client setup.

There is one file you need to attend to in the machines you want to have mount an NFS directory. This file is /etc/fstab (covered in depth in the section on adding hard drives), which is loaded at boot time and consequently mounts the appropriate directories.

An example of mounting the /home directory on the server machine (let's call it referee) to /home on the local (client) machine is:

referee:/home /home nfs

This breaks down as follows:

Creating Accounts

Since it's not a good idea to do anything except system administration tasks from root, now's a good time to create some accounts on your site. It's also important to ahead and set up some accounts aside from root so you can use them to test your servers as you get them set up. It's important not to assume that because your software works for root, it will work for everyone!

Creating User Accounts

To create an account by hand, type adduser at the prompt. You'll get the following sequence of prompts:

Login to add (^C to quit):
Full Name:
GID [100]:
UID [501]:
Home Directory [/home/username entered in first prompt]:
Shell [/bin/bash]:
Password [username entered in first prompt]:
Information for new user [username entered in first prompt]:
Home directory:  Shell: you entered at  [shell you entered 
[home directory]   the earlier prompt]  earlier]
Password:   UID:  GID:  [password you entered earlier]
  [UID you entered earlier]     [GID you entered earlier]
Is this correct? [y/n]:

The UID is the User ID. This tells Linux what User group the particular account belongs to when it files permissions.

The GID is the Group ID. This tells Linux what Group the particular account belongs to when it files permissions.

For example, I'll set up an account for myself, answering the prompts as follows:

  1. Login of dee
  2. Full name of Dee-Ann LeBlanc
  3. GID of 100 (100 is the default in the Slackware distribution for a general user.)
  4. UID of 501 (500 is the user root; 501 is mine because I was the next account added, and the number will go up from there with each user.)
  5. Home Directory of /home/dee (There's no rule that says you have to chose /home/<username>, it's simply tradition and it makes it easy to keep track of where everyone's directories are.)
  6. Shell of /bin/bash (Bash is common for root, but less experienced users often find /bin/tcsh more friendly.)
  7. Password of (Well, I'll come up with something!)

When you choose a password, try not to pick a standard dictionary word, and use a combination of upper and lower case letters. Adding numbers is even better. You'll learn more about the need to have hard-to-get passwords in chapter 12, "Security."

Don't forget to give root a password! As root, type passwd, and follow the prompts. Root's initial password is blank, so when you're asked to enter the old password, just hit Enter.

You can set up a skeleton directory to mirror what you want your users' directories to look like (particular files you know everyone will need). Just create the directory /etc/skel and put everything in there that you want to be in all user directories by default.

It's common practice to send a standard form letter piece of electronic mail to a new account when you set it up. If you write your own account setup program or a special script, you can configure your system to do this for you automatically so you don't have to remember to send the mail each time. A simple example script I'll call newuser calls the adduser program, and afterwards sends the mail you want follows (invoke this script by typing newuser newusername):

#!/bin/sh
/needpathfor/adduser
mail -s 'Subject line for the mail' $1 < /path/file_to_send.txt

The lines in this script do the following:

  1. #!/bin/sh
  2. Tells Linux to run the /bin/sh shell, which interprets everything that comes after that.
  3. /needpathfor/adduser
  4. Runs the adduser program for you. Fill it in just like you filled it in before.
  5. mail -s 'Subject line for the mail' $1 < /path/file_to_send.txt
  6. Invokes the mail program. The -s states that the next item is the subjet of the mail, which you'll put inside single quotes. The $1 refers to the username (the newusername mentioned above) to send the mail to. The < tells the script to include what follows in the mail. The item /path/file_to_send.txt refers to the full path and filename of the text file you want included in the new user e-mail.
***end numbered list***

For example, if I typed newuser dee, I would first go through the adduser program as described earlier in this section, and then the script would send dee e-mail containing the text file I created for this purpose.

Keeping Track of Usage Time for Accounting Purposes

If you're running a site that requires you to bill for SLIP line usage, you'll need to recompile your kernel and say yes to the IP accounting option (see chapter 16, "Upgrading Your Software" for more on compiling a new kernel).

Check out the Linux Documentation Project Web pages for pointers to accounting programs (see appendix C for a listing of URLs for the LDP pages).

Informing Users of Internet Etiquette

It is the responsibility of system administrators to be sure that users know where to find resources explaining Internet etiquette. This is partially to ensure a good reputation for your site, especially if it is a large one. You don't want a reputation for having clueless users who consistently don't appear to have any idea of what they're doing!

You can't force people to read documentation, or be sure they read it even if you put in safeguards that requires them to say they did. However, you can provide an explanation of why it's important to understand a bit of how the Internet works (most people don't want to look clueless) and pointers to recommended reading. The best way to do this is through including this information in the initial e-mail you send to users as their account is set up (more about this in a moment).

There are a number of excellent resources on the Internet regarding Internet etiquette (netiquette). On UseNet, these resources (which you may want to require your users to read) are:

Also, if your users want FAQs for almost any newsgroup, they can find them by FTPing to rtfm.mit.edu and going to /pub/usenet.

Acceptable Use Policy

It's important to set up an Acceptable Use policy for your site. This policy should detail:

The basic idea of your Acceptable Use Policy is to state the rules for using your site up front. This helps new users to understand a bit of what is unacceptable behavior, and also gives you the room to deal with problem users without getting sued. If they break one of the rules in your AUP, you can point to it and show them exactly which rule they broke, and exactly where you said how that infraction would be dealt with.

Some tips on putting together an Acceptable Use Policy are:

Keep in mind that if you develop serious problems with a user that affect a good portion of the Internet, the other system administrators may put a lot of pressure on your site to deal with them. It's important to have the legal backing of your acceptable use policy so you can deal with someone who's flooding UseNet, or otherwise abusing the Internet.

Assigning User Disk Quotas

If you're concerned that your users will overrun your site's hard drive space through their home directories, you can assign quotas to keep them limited to a particular amount of drive space.

There are two types of quotas you can use, hard and soft. If you are seriously hard-pressed for disk space, you may want to use hard quotas. With hard quotas, the system will not allow the user to exceed the quota you assign, which can cause whatever they're doing at the moment to crash. They won't be allocated any more disk space until they clean their usage down below their quota.

However, if you have a little leeway in your space, you may want to assign soft quotas. When a user reaches his limit with a soft quota, he can exceed that limit temporarily. This allows the user to finish the particular task he's working on, and then clean out some space. If the user doesn't clean out space, and leaves his disk usage higher than his quota, each time he logs in he will be warned. If the user persists in not cleaning out the space, he won't be allowed to use any additional disk space until he cleans his home directory back down below their quota.

Setting Your System To Use Disk Quotas

Before you can assign user disk quotas, you have to tell your system that you intend to use them. First, however, you need to decide what particular directories you want to apply the quotas too. If you just want to assign user quotas, /home is a good choice, as all of the user home directories inside it would be affected.

To set your site up to handle disk quotas, do the following:

  1. Log in as root.
  2. Edit the file /etc/fstab.
  3. To tell your system to expect quotas to be applied to, for example, /home and everything beneath it (with your home directories being for this example on /dev/hda1 using the filesystem ext2), enter the following:
/dev/hda1 /home ext2 rw,quota
  1. This sets the home directories to both readable and writable, and tells the system they'll have quotas assigned to them.

If you mounted home directories from a separate drive, then you can change the default entry to rw,quota instead of adding a new line.

  1. Save and exit the file.

Setting Up User Quotas

Now we'll set up the quotas themselves. To set a quota for all users, do the following:

  1. Change to /home.
  2. Type touch quota.group. This creates the data file that handles user quotas, and the rest of the quota system needs it to be there before you proceed in defining those quotas. You could also use quota.user, but then you'd have to create a new quota every time you assigned a new user account!
  3. Type chmod 600 quota.group. This changes the file's permissions to only readable and writable by the owner, root.
  4. Type edquota -g users. This invokes the command that will handle setting your quotas for you, making sure files are in their proper places and to their proper settings.

The edquota command is used to assign disk quotas to users and groups. Its general format is:

edquota -flag who_to_assign

The edquota flags are:

Edquota then opens a temporary file where you can define how you want the quota handled. The format for the definition line is:

fs /filesystem_to_have_the_quota blocks (soft=number_of_blocks,[ic:cc]
hard=number_of_blocks) inodes (soft=number_of_inodes,[ic:cc]
hard=number_of_inodes)

An example follows.

  1. Once the temporary file comes up, add the line that defines the quota space you want to assign to your user home directories. For example, if you wanted to set your limits to a soft of around 10M, and a hard of around 20:
fs /home blocks (soft=10000, hard=20000) inodes (soft=0, hard=0)

One block of disk space is one kilobyte (k, or 1024 bytes) of disk space.

Every file needs 1 inode. The inode contains the filesystem information about this file. Unless you want to limit the number of actual files someone can have, set the inode limit to 0, which disables that limit option. This way, the user can have as many files as he wants as long as he stays within the limits.

  1. Save and exit the file.
  2. Type quotaon -a. This tells your system to use the quotas you've set, and to use all quotas you've defined.

Handling Connections

As an Internet site, you need to handle connections to other machines. These come in two forms. First, there is the connection between you and your provider. This is, of course, important because if you're not connected, you're not on the Net! The other type of connection is that of your users dialing into your site (if you have dial-in connections).

Connecting to Your Provider via Modem

To connect to your provider using a modem (an analog or digital modem), you'll use the dip program. This package is part of the Slackware distribution disks on disk set n. If you didn't install it and you need it, go ahead and do so now.

For especially high grade connections, e.g. T1, your provider or the people you purchase/lease your equipment from may recommend another connection method.

Once you have the binary installed, you need to make a login configuration file. Where you put it is your choice, since you include the path to the file when you call the dip program. It's important that you first find out from your provider the sequence of commands you'll need. You should be familiar with modem login scripts, but I'll provide an example of a dip login script here to show you some tips:

init:
     print Initializing...
     get $local host.domain.com
     port cua1
     speed 38400
     send atz1\r
     wait OK 5
     send AT&C1&D2&K3&R1&S0\r
     wait OK 5
     if $errlvl != 0 goto modem_trouble

dial:
     sleep 3
     print Dialing Internet Direct...
     send atdt5551234\r
     if $errlvl != 0 goto modem_trouble
     wait BUSY 10
     if $errlvl != 0 goto login
     print BUSY
     send \r
     wait CARRIER 5
     send atz\r
     wait OK 5
     goto dial

login:
     print Login prompt...
     wait gin: 30
     if $errlvl != 0 goto login_error
     send rsoft\r

     print Password prompt...
     wait word: 30
     if $errlvl != 0 goto password_error
     send blort\r

     wait session 30
     if $errlvl != 0 goto prompt_error
     get $rmTip remote 30
     if $errlvl != 0 goto prompt_error
     wait to 30
     get $locip remote 30

done:
     print Host is $rmTip
     print You are $locip
     get $mtu 1006
     default
     mode CSLIP
     goto exit

prompt_error:
     print Timeout waiting for IP login to fire up...
     goto error

login_error:
     print Trouble waiting for login prompts...
     goto error

password_error:
     print Trouble waiting for the password prompt...
     goto error

modem_trouble:
     print Trouble occurred with the modem...
     goto error

error:
     print CONNECT FAILED to Internet Direct

exit:

You may want to write a script that checks occasionally to make sure your connection is up, and if it's not up it reconnects your site automatically.

If you don't want to use dip, you can use slattach. There is more on dip and slattach in the Net-2 How-To.

Users Connecting to Your Site via Modem

If you have users dialing in for SLIP connections, you need to have a program waiting to pick up the phone. The program I recommend for this task is sliplogin. You can find this program by FTP at sunsite.unc.edu, /pub/Linux/system/Network/serial/sliplogin-1.5.tar.gz (the version number may be different when you go to fetch the file).

This program has a number of configuration files associated with it. These files contain all the information necessary for it to run all of your incoming SLIP connections, and some of them require some alterations. The ones requiring changes are discussed here.

You can set up accounts that only allow people to use SLIP through your machine. The sliplogin program documentation spells out in detail how to set up these accounts.

The slip.hosts File

In the slip.hosts file, you define types of logins and how they're treated. The following is an example of this file.

# login  local-addr  remote-addr  netmask    slipmode  opt2 ...
#
# valid slipmodes: normal,compressed,ax25,6bit,auto
#
slip    199.60.103.1  DYNAMIC    0xffffff00  normal
cslip   199.60.103.1  DYNAMIC    0xffffff00  compressed
bob     199.60.103.1  DYNAMIC    0xffffff00  normal
susan   199.60.103.1  DYNAMIC    0xffffff00  compressed

I'll walk you through the slip definition line. The IP number given is that of the site's server. Then, when you tell it DYNAMIC, it knows that you want to dynamically assign IP addresses as people dial in. The hex 0xffffff00 (you would need to use the appropriate hex for a non-class C address) is 255.255.255.0, which tells sliplogin to replace the last digit in the server's IP number with the appropriate digit for the line. Finally, you define the connection type as either compressed (using CSLIP compression) or normal.

The slip.tty File

In the slip.tty file, you define what IP addresses to use for which tty's during dialin. This tells your system which address to use for DYNAMIC definitions. An example of this file is below. As you see, a definition in this file contains the name of the device, then the IP address assigned to that device.

# slip.tty    tty -> IP address mappings for dynamic SLIP
#
/dev/ttyS0    199.60.103.4

The slip.login File

The slip.login file is what's run when someone logs in via dial-up as just slip. There is only one change you need to make in this file, which is the hardware address for your Ethernet card. To get this address, type ifconfig. The Ethernet address in the example below is 00:20:AF:6E:E1:47.

#!/bin/sh -
#
#  @(#)slip.login       5.1 (Berkeley) 7/1/90
#
# generic login file for a slip line.  sliplogin invokes this with
# the parameters:
#      1        2      3      4         5          6        7     8-n
#   slipunit ttyspeed pid loginname local-addr remote-addr mask opt-args
#
/sbin/ifconfig $1 $5 pointopoint $6 mtu 1500 arp -trailers up
/sbin/route add $6 $1
#in case you have an ethernet card this will announce the slip client
#xx:xx:xx:xx has to be replaced by your hardware address
/sbin/arp -s $6 00:20:AF:6E:E1:47 pub
echo $4 > /var/run/$6
exit 0

Accessing the Internet from Winsock on the Same Network

If you have machines on your local network that you either switch between Linux and Windows on, or only use Windows on, you can use them to access the Internet over Ethernet even if they're not in Linux. Just configure your Winsock program to use a direct connection instead of SLIP or PPP, and set the appropriate network values.

Using Your Virtual Consoles

One wonderful feature of UNIX that Linux shares is that of having virtual consoles. By virtual consoles, I mean that you can be logged in to the system more than once and through different accounts.

You have twelve virtual consoles by default. You switch between them by holding down the Alt key and the appropriate function key. For example, right now you're probably on Alt+F1. Hold down the Alt key and press F2. You'll find yourself at another login prompt. Keep doing that on Alt+F3 through Alt+F12; they're all new login prompts. At each prompt, you can log in through the same account as you're logged in to another console, or a different one.

Shutting Down Your Linux System

With Linux, you really don't want to just shut the computer off right away. There may be important data stored in the buffers that won't get saved if you just turn the machine off, or you may be shutting off a process, that you didn't notice, before it finishes what it's doing.

To shut down your system, do the following:

  1. Log in as root.
  2. Type shutdown [-hrf] [time]
  3. Watch and wait.

The "h" stands for hard shutdown: The computer will shut down all processes and then sit and wait for you to hit reset or shut it off.

The "r" stands for restart or reboot: The computer will automatically reboot once all processes are shut down. A restart shutdown is particularly useful if you intend to reboot and use LILO to access another operating system.

I commonly use shutdown -h now. That tells my system to immediately shut down all processes, and then sit and wait for me to either shut the power off or hit the reset key.

If you want to tell it to shut down in a certain amount of time, give the time in minutes. For example, type shutdown -h 5.

Now you're all set up and ready to start installing your servers!

QUE Home Page

For technical support for our books and software contact support@mcp.com

Copyright ©1996, Que Corporation