Setting up a PPP Connection

September 26th, 2008



Here are the steps you’ll want to follow to establish a PPP connection to an Internet Service Provider, or ISP. In these situations, you’re calling the same phone number and are dynamically allocated an IP address each time you login the ISP’s computer.

First, you’ll need to make sure that your local permissions are set up correctly. When logged in as root, you should edit your /etc/hosts.deny file to add the following line:

 
     ALL: ALL
 

This prevents others from logging on your system via the Internet when you’re connected to your ISP. However, you do want to allow yourself access to your own machine (we assume you do, anyway), so edit your /etc/hosts.allow file to add the following line:

 
     ALL: 127.0.0.1
 

If you haven’t done so already, you should give your own machine a name (we told how to change this in Chapter 2). This information is found in /etc/HOSTNAME.

Next, you’ll need to tell your Linux system where to find data on the Internet. This involves adding the name of your service provider and a DNS server to the /etc/resolv.conf file, in the following format:

 
     search mr.net
 
     nameserver xxx.xxx.xxx.xxx
 

In this example, we told Linux to look for things like news and mail at mr.net. In the place of xxx.xxx.xxx.xxx you’ll provide a DNS address as provided by your ISP.

You’ll also want to take a look at /etc/hosts. It should contain two lines, looking something like this:

 
     127.0.0.1 localhost
 
     0.0.0.0   gilbert
 

If 127.0.0.1 is used for your machine name, change it. This should not be used when a connection to the Internet is made, because it may conflict with some Internet services.

Finally, you’ll want to give Linux the username and password provided to you by your ISP in the /etc/ppp/pap-secrets file. This line will look something like this:

 
     reichard * password
 

where password is the password.

One more step before you make a connection: You’ll need to create a /etc/ppp/chatscript to include information about your ISP, particularly a phone number. The following script works with most modems:

 
  TIMEOUT 5
 
  ” ATZ
 
  OK ATDTxxx-xxxx
 
  ABORT ‘NO CARRIER’
 
  ABORT BUSY
 
  ABORT ‘NO DIALTONE’
 
  ABORT WAITING
 
  TIMEOUT 45
 
  CONNECT “We are connected!”
 
  TIMEOUT 5
 
  “name:” reichard@mr.net
 
  “word:” password
 
  in> ppp
 

where xxx-xxxx is the phone number of your ISP. The final three lines are tailored to our ISP, which presents two prompts (username: and password:) as well as a command line for launching ppp on the host computer. You’ll want to change this for your specific ISP.

 

Linux’s PPP Tools

September 26th, 2008


We recommend that you use the PPP protocol instead of SLIP for many reasons, some technical and some not; basically, it’s easier to set up PPP connections when you’re using dynamically assigned IP addresses.

Not that it’s that simple to set up a PPP connection. The trouble with the Linux world is that it lacks a simple tool like Trumpet Winsock to automate dialup connections to the Internet, which is why you need to slog through descriptions like the one here.

In addition to the dip program, Linux supports a suite of PPP-only applications. The dip program supports the PPP protocol, along with SLIP and CLSIP. The PPP suite of applications only supports PPP. Of these PPP-only tools, the pppd command acts as the PPP daemon and sits in the background awaiting PPP connections.

The ppp-on command brings up a connection. The ppp-off command brings it down. As with dip, there’s a lot of configuration to do. This is one area of Linux that could really use some improvement. You can find out more about Linux’s PPP tools by looking in the /usr/doc/ppp directory.



NOTE:  Confusing as it sounds, the dip program supports the PPP protocol, but not the separate PPP suite of commands. Nor do the PPP commands support dip. That is, you can’t really mix and match dip with ppp-on, ppp-off, and pppd.

In addition to the slip and ppp suites, you can run diald, short for Dial Daemon. Diald maintains a pseudo-networking connection for your phone line, even if the phone line is not actively connected to the Internet. This capability allows you to only tie up your phone line when needed, because diald automatically reconnects when needed and hangs up when a connection is no longer necessary.



ON THE CD-ROMS:  Diald is on the second CD-ROM.

Dip command on Linux

September 26th, 2008

The dip command stands for dialup IP connections, that is, a TCP/IP connection between your Linux system and some other system. The connection is made over a serial line (and presumably a phone line and modem) instead of the traditional Ethernet or other TCP/IP connection. On top of the serial line connection, dip implements one of a number of serial-line Internet protocols, including SLIP, CSLIP (Compressed SLIP), and PPP.

Thus, without a direct hard-wired network link, you can establish an IP (network) link over a phone line. This is very useful for connecting to an Internet service provider. The way this works is that all data going between the two computers is sent over the serial line. At each end, the data is converted into network packets and sent to the appropriate programs. To most programs on either end, there is no real difference between this type of link and a direct network connection, except that serial-line links are typically much slower than direct network connections.

You can use dip for both incoming and outgoing dialup links.

When you dial out with dip, you can configure a chat script to set up a link to your remote system. The chat script contains things like which serial port to use, the system (host) to connect to, what speed to set the modem, the protocol (e.g., PPP, SLIP, etc.), and so on.

You can also use dip to manage incoming connections. Users then login normally over a serial link, but the “shell” launched on login is not bash or csh, but diplogin.

In this case, you can set up a program called diplogin as the “shell” to execute for a particular user in the /etc/passwd file. (Normally, diplogin is a link to dip with the -i option to set dip into input mode. Upon login, dip looks up the user’s name in the /etc/diphosts file. Each entry in this file is a lot like the system password file, /etc/passwd. For each user, you can have an extra external dial-in password to add an extra level of security—a useful thing in the wild atmosphere of the Internet.

Upon successful login, dip sets up a network connection between the dial-in line and your Linux system, using the protocol specified in the /etc/diphosts file for the given user who logged in. Normally, this is CLSIP, SLIP, or PPP.



NOTE:  Dip also supports dynamic IP address allocation. See the online documentation for more on this.

Because dialup Internet connections are so individualistic (we’ve dealt collectively with both static and dynamically allocated addresses), we’re going to leave it up to you to configure dip. You’ll want to read carefully through the online-manual pages for dip, as they contain plenty of examples. They also contain example scripts, which you can adapt to automatically log you on a remote connection.

To help make the first connection, it’s very handy to run dip in test mode. To run it, use the following command line:

     gilbert:/$ dip -t

     dip>

The -t option tells dip to accept interactive commands. You can use these interactive commands to find out more information about what steps work and what steps don’t while you’re debugging a dip connection.

Unfortunately, there is no really easy way to set up dip. You can find out more about dip and its configuration options by looking in the /usr/doc/dip directory.

Linux’s SLIP and PPP Tools

September 26th, 2008


If you aren’t connected to the Internet via a direct network connection, you’ll need to make arrangements to do so. There are two ways to do this.

One method involves piggybacking off of a machine that is directly connected to the Internet. In this manner, you can essentially use the specifics of the connected machine. Connectivity tools that fall under this category include SLiRP, which is run in a remote UNIX shell account and makes it act like a SLIP/CSLIP account. We compiled it on an Ultrix machine and connected to it with DIP. It works great! The source for it is on the CD-ROM in /contrib.



NOTE:  The term program, which was covered in the first edition of this book, is no longer supported under newer versions of Linux.

If you don’t have a permanent TCP/IP connection to the Internet through work or a friend, you can use Linux’s SLIP and PPP tools to connect to the Internet via an Internet service provider of some sort. SLIP (Serial Line Internet Protocol) and PPP (Point-to-Point Protocol) allow you to connect to another TCP/IP machine.

To connect to the Internet via SLIP and PPP, your implementation of Linux must first support both protocols. If you installed directly from the CD-ROM, your Linux kernel will indeed support SLIP and PPP; if you look at the screen closely when you boot Linux, you’ll notice that SLIP and PPP will be listed. However, if for some reason you decided to compile your own kernel, then you should have had the foresight to compile in SLIP and PPP support. (You were asked if you wanted support for these protocols as part of the make process.) If not, then you’ll need to go back and compile a new kernel, paying special attention to the Network section of the makefile.

After doing that, you’ll set up an account with a service provider (like Netcom, PSI, GNN, Microsoft Network, or Minnesota Regional Network), which gives you Internet access using a standard modem. When you connect via a service provider, you’ll be assigned an IP address right on the spot; the process yields a dynamically assigned IP address, which is then used by your Linux system to connect to the Internet.

When you set up an account, you should get a list of information from the service provider. Out of this information, you’ll need to know the following:

  The access telephone number—if you don’t have this number, you can’t dial up the service provider.
  The IP numbers of the Domain Name Servers. These are the servers your system looks to when you want to connect to another machine on the Internet. Without these servers, your Linux system would be lost in cyberspace.
  Your username and password.
  The mechanism for logging on the system. This is a little more daunting than it looks, because it seems that every service provider handles dialup connections a little differently. As an example: our service provider uses a standard UNIX-style login procedure, where the entry of a username and a password is followed by a standard UNIX prompt:

  Welcome to the Twin Cities MRNet dialIP Service.

  User Access Verification

  Username:

  Password:

  slip-server> ppp


After entering ppp at the command prompt, the server initiates the PPP protocol with your machine. This is not standard in the ISP world; most initiate the process immediately after you enter your password.

Basically, SLIP and PPP do the same thing. However, SLIP (the older of the two protocols) is decreasing in popularity, because PPP (quite honestly) is easier to configure and use. Linux contains the dip command, which handles SLIP connections to a service provider.

Getting on the Worldwide Network

September 26th, 2008



The Internet has been the recipient of a ton of hype recently, and with good reason: it’s one of the most exciting developments in the computer world in quite some time. As both a computer user and a Linux user, you’ll greatly benefit from the many possibilities offered by the many offerings of the Internet.

As a matter of fact, you’ve probably noticed the many references to the Internet throughout the course of this book. It seems as though anyone who wants to do any advanced work with Linux needs a link to the Internet. Usenet newsgroups—which we cover in Appendix A—as well as great Web sites can certainly enhance your understanding and usage of the Linux operating system.

How you connect to the Internet depends on your specific circumstances, however. If you’re using Linux in a corporation that’s already connected to the Internet, you can merely piggyback from that connection. If you’re working on a stand alone Linux workstation, you can set up your own Internet connection with the aid of an Internet service provider.

Both of these possibilities exist because of Linux’s built-in networking capabilities—namely, TCP/IP, which you learned about in Chapter 8. Basically, this support for TCP/IP allows a Linux user to use another computer on the network. In Chapter 8, the computers on the network were in the same physical location as your computer. On the Internet, the computers on the network can be just about anywhere. (In other words, the Internet is basically the world’s largest TCP/IP network.)

The concept behind TCP/IP networking is actually pretty simple. Each machine on the network has an individual TCP/IP address, and every other machine on the network can access this machine (if only to be denied access, of course; there are some security measures involved if need be). The extent of the network depends on your needs; some companies purposely restrict their TCP/IP networks to a very confined set of machines; other allow full access to the global Internet.

 

Setting up TCP/IP Information

September 26th, 2008


The files that control TCP/IP configuration are stored in the /etc directory. When you first set up Linux and are asked about machine names and domain names, this information is sent to the /etc/hosts file. While you don’t need to mess with this file if you’re connected to the Internet (it does many of the same things that a Domain Name Server does), it’s a good thing to place the names of essential servers in this file. And if you’re not connected to the Internet but you are maintaining a small network, this is the place to store the IP addresses for the workstations on your system. (Again, this could be done via a DNS on your local system, but it’s a lot easier to use the /etc/hosts file.)

Another file to check is the /etc/networks file, used to configured different networks in the TCP/IP subsystem. This file is summoned when the system launches, and its functions are handled by DNS servers if you’re working on the Internet. Again, if you’re not connected to the Internet but you want to have subnetworks and such (you really don’t; we’re speaking hypothetically here if you’re working on a small network), you’d use this file instead of a DNS.



NOTE:  If you have an ethernet card, you can configure it using the “netconfig” command. You might also need to edit /etc/rc.d/rc.modules to load support for your card.

You’ll also want to run the ifconfig command, which essentially tells the kernel about your Ethernet card and the IP addresses if you’ve not done so already. To see the current state of your system, use the command with no options:

gilbert:/$ ifconfig

lo    Link encap:Local Loopback

      inet addr:127.0.0.1  Bcast:127.255.255.255  Mask:255.0.0.0

      UP BROADCAST LOOPBACK RUNNING  MTU:2000  Metric:1

      RX packets:0 errors:0 dropped:0 overrun:0

      TX packets:40 errors:0 dropped:0 overruns:0

In this case, we’re actually using Linux without a network card or a connection to a network—but Linux thinks it’s on a network using a tool called loopback. Loopback allows applications and daemons that need to communicate via TCP/IP to connect to local resources.

TCP/IP Basics

September 26th, 2008


Under a TCP/IP network, every computer on the network is assigned an IP address, including your computer. If your Linux workstation is permanently connected to a TCP/IP network, this address will remain constant. (If you’re using a dialup connection to the Internet through a service provider, your IP address will be dynamically assigned when you login the service.) This address comes in four fields, such as 255.255.0.0. This breaks down to:

subdomain.subdomain.domain.domain

You will find detailed information on IP addresses, how they’re structured, and how you can acquire them on the second accompanying CD-ROM. We’re not going to spend a lot of time on the intricacies of IP addresses; it’s an involved subject beyond the reach of this book.

From your end, IP addresses are important for connecting to another computer on the network. (By this, we mean the entire network, which can include the rest of the world if you’re connected to the Internet.) However, in many situations you don’t need to know the specific IP address to make a connection, as you probably discovered when you see lists of Internet addresses (such as those found in Appendix A) without any IP addresses listed. Why’s that? Because early in the Internet’s development the decision was made to allow a Domain Name Server (DNS) to handle these dirty details. Your TCP/IP network (or your service provider) has a named DNS somewhere on the network. When you enter an Internet address like ftp.x.org or a mail address like reichard@mr.net, a lookup is performed on the DNS, which then makes sure that the mail or request is routed to the proper machine. If you’ve installed TCP/IP on your system, you’ll be running a daemon named named that handles the connections to the DNS.

The fwhois command connects to the DNS and returns information about a specific user or a domain name:

     gilbert:~$ fwhois mr.net

     Minnesota Regional Network (MR-DOM)

          511 11th Avenue South, Box 212

          Minneapolis, MN 55415

          Domain Name: MR.NET

          ....

          Record last updated on 16-Nov-93

          Domain servers in listed order:

          NS.MR.NET               137.192.240.5

          RS0.INTERNIC.NET          198.41.0.5

          RIVERSIDE.MR.NET          137.192.2.5

          SPRUCE.CIC.NET          35.42.1.100

     gilbert:~$ fwhois dfazio@mr.net

     Fazio, Dennis (DF202)          dfazio@mr.net

     Minnesota Regional Network (MR-DOM)

          511 11th Avenue South, Box 212

          Minneapolis, MN 55415

          Record last updated on 16-Dec-91

The fwhois command also lists users on your Linux system, even if you’re not connected to the Internet.

Networking and Linux

September 26th, 2008



One of the great appeals of the Linux operating system is its built-in networking connectivity. Instead of trying to make an operating system like DOS, Microsoft Windows, or MacOS deal with a network, you can work with Linux, where the network exists at the core of the operating system.

This is accomplished through TCP/IP (Transmission Control Protocol/Internet Protocol), which has become the lingua franca for networking in the UNIX world. Because UNIX-based systems were instrumental in forming the Internet and its predecessors, TCP/IP became the dominant protocol for communication on the Internet. TCP/IP is the major tool for networking UNIX-based computer systems, as most UNIX implementations contain support for TCP/IP. Other operating systems, such as DOS and OS/2, can also connect to TCP/IP networks, although this requires special add-on software.

Linux comes with full support for TCP/IP (provided you installed it when you installed Linux; if not, you’ll need to look at reinstalling Linux or recompiling your kernel). This support comes in the form of the NET-3 set of protocols and programs. On your end, connecting to a UNIX network via TCP/IP is merely a matter of making sure your PC is correctly hooked up to the network via Ethernet card and cabling.



NOTE:  Much of what’s involved with Linux networking is best performed at the sysadm level. If you’re a system administrator, you should follow your own configuration routines at the network level; after all, Linux installs and configures pretty much like any other PC UNIX on the network level. If you’re not a system administrator, we suggest you check out Olaf Kirch’s Linux Network Administrator’s Guide, which can be found on the accompanying CD-ROM or in print at your local bookstore.



Linux also allows you to make a TCP/IP connection via telephone line, using the SLIP or PPP protocol. If you want to connect to the Internet via a dialup connection, you’ll need to use these tools. (We cover this in more depth in Chapter 9.)

Before you try using any of these tools, you should have some background in TCP/IP. We advise checking out Olaf Kirch’s Linux Network Administrator’s Guide, which has been printed by various sources (including the Linux Documentation Project and SSC).

 

Finding Files with ‘find’ command

September 26th, 2008


The find command included with Linux (actually the GNU find command) is very similar to the find command that ships with most other versions of UNIX—that is, the GNU version is maddeningly complex and nonintuitive to use. At its best, find will search your entire filesystem for a specific file. At its worse, find will return every file on the system, leaving you scratching your head about how to proceed with a useful search.

Still, you shouldn’t run into too many problems with find if you remember one thing: You need to make sure all the elements of the command line are properly organized. For example, you won’t find the following command line very useful:

     gilbert:~$ find *

as it returns all the files in your current directory. Similarly, the following command line will list every file (at a dizzying speed, no less) on your Linux system:

     gilbert:/$ find *

a move guaranteed to give you a headache. (Remember, Linux does exactly what you tell it to do.)

Instead, you’ll need to slow down and figure out how to use the find command. Let’s say you want to find the directory location of a file named test.bk. First, you need to tell find how to search for a file. We know the name of the file, so we begin our command line by telling find to search by filename. We do so with the -name option:

     gilbert:/$ find * -name

This is a start. Now we need to tell find what to look for. We do this by adding the name of the file:

     gilbert:~$ find * -name test.bk

If you wanted, you could use a wildcard instead of listing the specific filename. With or without a wildcard, however, the command should work.

If you’re working with a large filesystem, you may want to run the find command in the background. This is accomplished by adding an ampersand to the command line:

     gilbert:~$ find * -name test.bk &

Running this command in the background allows you to do work while the find command searches for the file. For more information on running commands in the background, check out the section “Background Commands and Multitasking” later in this chapter.



NOTE:  When looking at other Linux texts, you’ll be able to see who actually wrote the book using Linux and who wrote the book with a knowledge of UNIX and not much experience with Linux by the way the find command is explained. In most versions of UNIX, the find command requires that -print be added to the end of the command line and that the name of the search be in quotation marks. The GNU version of find requires neither.

There’s a lot more to the find command, as it encompasses an amazing amount of complexity that’s meant for large-scale systems more than for the needs of the average Linux user. If you’re interested in knowing more about the find command, use the following command line:

     gilbert:~$ man find

Viewing Online-Manual Pages with Man

September 26th, 2008



One of the handiest feature of UNIX—and by extension, of Linux—is the existence of online-manual pages, which detail the workings of specific commands. These online-manual pages (commonly referred to as man pages) will list the purpose of a given command, any command-line options, and perhaps other information. (For example, man pages created by the FSF for use with GNU commands tend to be rather verbose, going into the entire purpose of the command and listing any known bugs.) While this sort of information isn’t as useful as a full online help system (for example, you can’t look up a man page for any topics at all; man pages are written for specific commands), it still can help you a great deal, especially if you know a certain command can come close to doing what you want, but you need to know the precise option that yields the desired behavior.

To view an online-manual page, combine the name of the command with the man command:

 
     gilbert:/$ man man
 

The man page for man is obviously a multipage document, as evidenced by the information at the bottom of the screen, because the bottom sentence isn’t complete. To move up and down through the entire man page by entire pages, use the PageUp and PageDown keys; to move up and down the man page line by line, use the keyboard cursor keys ([uarr] and [darr]). To quit the man command and get a command prompt, press the q key (short for quit).