October 2006


What Is Linux? technical support and no documentation. It’s also possible to install Red Hat Linux 9 as part of a dual boot setup on your machine. This gives you an option if you just have one machine and you don’t want to give up your Windows or other operating system. While you’re welcome to explore these alternatives, and while they are totally compatible with the material you’ll find in this book, we don’t discuss them in any detail. What Is Linux? When you ask this question of a Linux aficionado, their answer will almost invariably make some reference to Linus Torvalds and the open source community. As you’ll see from our potted history, Linus is a pivotal character in the creation and development of Linux, and the open source roots of Linux are central to its popularity. Linus Torvalds and the Birth of Linux Linus Benedict Torvalds was studying at the University of Helsinki, Finland, when his interest in computing led him to become curious about operating systems and how he could improve upon the existing systems of the day - and specifically the various Unix derivatives. With this small step, the development of the Linux kernel (its core) was begun; and in October 1991 version 0.02 was released onto the Internet with this now famous posting: From: (Linus Benedict Torvalds) Newsgroups: comp.os.minix Subject: Free minix-like kernel sources for 386-AT Message-ID: <1991Oct5.054106.4647@klaava.Helsinki.FI> Date: 5 Oct 9105:41:06 GMT Organization: University of Helsinki Do you pine for the nice days of minix-1.1, when men were men and wrote their own device drivers? Are you without a nice project and just dying to cut your teeth on a OS you can try to modify for your needs? Are you finding it frustrating when everything works on minix? No more all-nighters to get a nifty program working? Then this post might be just for you :-) As I mentioned a month(?) ago, I’m working on a free version of a minix-lookalike for AT-386 computers. It has finally reached the stage where it’s even usable (though may not be depending on what you want), and I am willing to put out the sources for wider distribution. It is just version 0.02 (+1 (very small) patch already), but I’ve successfully run bash/gcc/gnu-make/gnu-sed/compress etc under it. Sources for this pet project of mine can be found at nic.funet.fi (128.214.6.100) in the directory /pub/OS/Linux. The directory also contains some README-file and a couple of binaries to work under linux (bash, update and gcc, what more can you ask for :-) . Full kernel source is provided, as no minix code has been used. Library sources are only partially free, so that cannot be distributed currently. The system is able to compile “as-is” and has been known to work. Heh. Sources to the binaries (bash and gcc) can be found at the same place in /pub/gnu. 5
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check Actions servlet hosting services

Linux is quickly becoming a major player on the world’s operating system scene - it’s fast, it’s stable, and above all it’s freely available. Within the Linux market, Red Hat Linux holds the distinction of being the most popular distribution, and with Red Hat Linux 9 it’s now even easier to install and use than ever! This book teaches you everything you need to know in order to install, configure, use, and maintain your Red Hat Linux system. It’s been specially written for Red Hat Linux 9, though you will also find it a very useful guide if you’re planning to use its slightly older brother, Red Hat Linux 8.0, and any subsequent Red Hat Linux releases. Who Is This Book For? This book is targeted primarily at readers who are using (or planning to use) the Red Hat Linux operating system for the first time. It offers the simple, plain-speaking guidance you need as you begin to explore the vast potential of open source software. We assume that the reader is familiar with using an operating system before such as Apple’s Macintosh, Unix, or one of the many versions of the Microsoft Windows operating system. An awareness of concepts like file systems, applications, and users and permissions would be an advantage, but is not essential; the book will provide insight for those readers who have not considered these concepts before. No previous knowledge of Linux is assumed. What You Need to Use This Book All you need for this book is a machine and a copy of the Red Hat Linux 9 distribution. The easiest option (and the one we’ll use in this book) requires: A single machine that you can dedicate to your Red Hat Linux 9 installation. Red Hat advises at minimum a Pentium class CPU with 650MB hard disk space and 128MB memory, but recommends a 200MHz Pentium with 2.5GB hard disk space and 192MB memory for better performance. It also says that most factory-built machines made in the last two years will be compatible with Red Hat Linux 9, and many older machines too. (See Chapter 1, and http://hardware.redhat.com, for more on hardware compatibility.) A copy of Red Hat Linux 9 included with this book. Other Alternatives There are other ways to obtain the Red Hat Linux 9 distribution. You could: Download the Red Hat Linux 9 distribution images for free via FTP, and burn them onto CDs. However, this is quite complex - for example, you’d need an ISO burner (this is a piece of software that unpacks the ISO files as you burn them onto your chosen media). If you’re feeling ambitious, follow the guidelines at http://www.redhat.com/download/howto_download.html); the distribution is available at a number of mirror sites around the world. Buy installation disks cheaply from a third-party vendor. However, these disks tend to come with no 4
Note: If you are looking for reliable and quality webspace company to host and run your servlet application check Actions servlet hosting services

On the other hand, if the buffer holds more data than will fit in your array, you can iterate and pull it out in chunks with code like this: char [] smallArray = new char [10]; while (buffer.hasRemaining()) { int length = Math.min (buffer.remaining(), smallArray.length); buffer.get (smallArray, 0, length); processData (smallArray, length); } The bulk versions of put() behave similarly but move data in the opposite direction, from arrays into buffers. They have similar semantics regarding the size of transfers: buffer.put (myArray); is equivalent to: buffer.put (myArray, 0, myArray.length); If the buffer has room to accept the data in the array (buffer.remaining() >= myArray.length), the data will be copied into the buffer starting at the current position, and the buffer position will be advanced by the number of data elements added. If there is not sufficient room in the buffer, no data will be transferred, and a BufferOverflowException will be thrown. It’s also possible to do bulk moves of data from one buffer to another by calling put() with a buffer reference as argument: dstBuffer.put (srcBuffer); This is equivalent to (assuming dstBuffer has sufficient space): while (srcBuffer.hasRemaining()) { dstBuffer.put (srcBuffer.get()); } The positions of both buffers will be advanced by the number of data elements transferred. Range checks are done as they are for arrays. Specifically, if srcBuffer.remaining() is greater than dstBuffer.remaining(), then no data will be transferred, and BufferOverflowException will be thrown. In case you’re wondering, if you pass a buffer to itself, you’ll receive a big, fat java.lang.IllegalArgumentException for your hubris. I’ve been using CharBuffer for examples in this section, and so far, the discussion has also applied to other typed buffers, such as FloatBuffer, LongBuffer, etc. But the last two methods in the following API listing contain two bulk move methods unique to CharBuffer: 40
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services

CharBuffer charBuffer = CharBuffer.wrap (”Hello World”); The three-argument form takes start and end index positions describing a subsequence of the given CharSequence. This is a convenience pass-through to CharSequence.subsequence(). The start argument is the first character in the sequence to use; end is the last position of the character plus one. 2.3 Duplicating Buffers As we just discussed, buffer objects can be created that describe data elements stored externally in an array. But buffers are not limited to managing external data in arrays. They can also manage data externally in other buffers. When a buffer that manages data elements contained in another buffer is created, it’s known as a view buffer. Most view buffers are views of ByteBuffers (see Section 2.4.3). Before moving on to the specifics of byte buffers, we’ll concentrate on the views that are common to all buffer types. View buffers are always created by calling methods on an existing buffer instance. Using a factory method on an existing buffer instance means that the view object will be privy to internal implementation details of the original buffer. It will be able to access the data elements directly, whether they are stored in an array or by some other means, rather than going through the get()/put() API of the original buffer object. If the original buffer is direct, views of that buffer will have the same efficiency advantages. Likewise for mapped buffers (discussed in Chapter 3). In this section, we’ll again use CharBuffer as an example, but the same operations can be done on any of the primary buffer types (see Figure 2-1). public abstract class CharBuffer extends Buffer implements CharSequence, Comparable { // This is a partial API listing public abstract CharBuffer duplicate(); public abstract CharBuffer asReadOnlyBuffer(); public abstract CharBuffer slice(); } The duplicate() method creates a new buffer that is just like the original. Both buffers share the data elements and have the same capacity, but each buffer will have its own position, limit, and mark. Changes made to data elements in one buffer will be reflected in the other. The duplicate buffer has the same view of the data as the original buffer. If the original buffer is read-only, or direct, the new buffer will inherit those attributes. Direct buffers are discussed in Section 2.4.2. Duplicating a buffer creates a new Buffer object but does not make a copy of the data. Both the original buffer and the copy will act upon the same data elements. 44
Note: If you are looking for inexpensive but high quality provider to host and run your jsp application check Astra jsp hosting services

Configuring the DHCP Server After dhcpd is installed, it must be configured. The DHCP daemon is configured through the dhcpd.conf file. The file can contain an extensive list of configuration commands that provide direction to the server and configuration information to the clients. A DHCP server can be configured to provide service to individual hosts and to entire subnets of hosts. The dhcpd configuration language includes host and subnet statements that identify the scope of systems being serviced. A host statement might contain the following: host osprey { hardware ethernet 00:00:0C:43:8D:FB ; fixed-address 172.16.70.8 ; } This statement defines the hostname, Ethernet address, and IP address of the client. When configured in this way, dhcpd provides a static address assignment similar to the service provided by a BootP server. This statement matches the client’s Ethernet address against the configuration entry, and returns a static IP address to the client. Using this technique, DHCP can be used to assign static addresses to systems, such as name servers, that require static addresses. The format of the subnet statement is subnet 172.16.70.0 netmask 255.255.255.0 { range 172.16.70.100 172.16.70.250 ; } The subnet statement declares that the system is providing DHCP service to network 172.16.70.0. Furthermore, the range clause says that the server is providing dynamic addressing, and that the

Hint: If you are looking for very good and affordable webspace to host and run your j2ee hosting application check Virtualwebstudio j2ee web hosting services

This causes dhcpd to read its configuration from /var/dhcp/test.conf, but the /etc/dhcpd.conf file is still required! The /etc/init.d/dhcpd script does not run dhcpd unless it finds both the /etc/ dhcpd.conf file and the /var/lib/dhcp/dhcpd.leases file. Initializing the dhcpd.leases File dhcpd stores a database of the address leases it has assigned in the dhcpd.leases file. The file must exist for dhcpd to boot. When the server is first installed, create an empty dhcpd.leases file to ensure that the daemon starts correctly. dhcpd writes database entries into the file as ASCII text. If you’re curious, you can view the file to see what leases have been assigned. Entries in the file have the following format: lease address {statements} Each lease begins with the keyword lease and the IP address that is assigned by the lease. This is followed by a group of statements that define the characteristics of the lease. Possible values that might appear in the list of statements include the following: starts date Records the start time of the lease. date contains the weekday, year, month, day, hour, minute, and second when the lease started. ends date Records the time when the lease will end. date contains the weekday, year, month, day, hour, minute, and second when the lease will end. hardware hardware-type mac-address Records the client’s physical-layer address. On an Ethernet, the hardware-type is ethernet, and the mac-address is the Ethernet address. uid client-identifier Records the client’s DHCP identifier if one was used by the client when it obtained the lease. Most clients are identified by their MAC addresses, and do not require a separate DHCP identifier. client-hostname “name” Records the client’s hostname if the client provided it using the client-hostname DHCP option. (Much more will be said about DHCP options later in this chapter.) hostname “name” Records the client’s hostname if the client provided a hostname using the hostname DHCP option. Microsoft Windows clients send their hostnames to the server using the hostname option. abandoned Identifies this as an abandoned lease. If the server has trouble assigning an address (either because the client rejects the address, or the server determines that an unassigned address is already in use), the server marks it “abandoned” until it runs short of available addresses and needs to try this one again. Use this information when you want to examine the contents of the dhcpd.leases file. Beyond that, you don’t need to be concerned about these commands. When you create the file, you create it empty. After you create it, you can forget about it because dhcpd maintains the file. The file that does require your input, however, is the dhcpd.conf file that is used to configure the server. 234
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

Running dhcpd Under Red Hat Linux 7.2, the DHCP daemon is started by the /etc/init.d/dhcpd script. The script accepts the same arguments as the /etc/init.d/named script described in Chapter 4. The most commonly used arguments are start, stop, and restart. For example, the following command will start dhcpd: [root]# service dhcpd start Starting dhcpd: [ OK ] Use a tool such as chkconfig or tksysv to ensure that the /etc/init.d/dhcpd startup script is run whenever the system reboots. On our sample Red Hat system, the following chkconfig commands cause the dhcpd script to run whenever the system reboots in runlevel 3 or 5: [root]# chkconfig –list dhcpd dhcpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off [root]# chkconfig –level 35 dhcpd on [root]# chkconfig –list dhcpd dhcpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off The /etc/init.d/dhcpd script uses the dhcpd command to start the DHCP server. The syntax of the dhcpd command is dhcpd [-p port] [-f] [-d] [-q] [-cf file] [-lf file] [interface-list] -p port Defines an alternate port. Normally, dhcpd listens for client requests on port 67, and responds on port 68. Use the -p option to change to non-standard ports. This is used only for testing. -f Runs dhcpd as a foreground process. This is used only for debugging. -d Sends error messages to stderr instead of to syslogd. -q Prevents dhcpd from printing out its startup message. -cf file Identifies the file from which dhcpd should read its configuration. By default, dhcpd reads its configuration from /etc/dhcpd.conf. -lf file Identifies the file to which dhcpd should write address lease information. By default, dhcpd writes lease information to /var/lib/dhcp/dhcpd.leases. interface-list Lists the names of the interfaces that dhcpd should monitor for client request. By default, dhcpd listens to all interfaces that support broadcasts. To set dhcpd command-line arguments on a Red Hat system, store the arguments in the file /etc/ sysconfig/dhcpd. The /etc/init.d/dhcpd script reads arguments from that file before starting the DHCP daemon. For example, to make dhcpd read its configuration from a file named /var/dhcp/ test.conf, create a /etc/sysconfig/dhcpd file that contains the following: [root]# cat /etc/sysconfig/dhcpd # Command line options here DHCPDARGS=-cf /var/dhcp/test.conf 233
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

Using dhcpd with Old Linux Kernels dhcpd works well with the Linux 2.4 kernel. However, if your Linux system uses an outdated kernel, installing dhcpd may not be all that is required to get it running. In that case, there are a few potential problems that need to be addressed by system-specific configurations. The best way to solve these problems is to update to a new kernel. If, for some reason, you are unwilling to update your kernel, you should read this sidebar. If you provide service to Microsoft Windows DHCP clients, you may encounter problems with the limited broadcast address. If it appears that Microsoft Windows clients do not see DHCP messages from the server while other types of clients do, you need to define a specific route for the limited broadcast address on your Linux server. To do so, first add the name all-ones to the /etc/hosts table: 255.255.255.255 all-ones Then, add a route for the limited broadcast address: route add -host all-ones dev eth0 To reinstall the special route after each boot, add the route statement to the rc.local startup script. Old distributions with the versions of the kernel that require it often include the code to add the limited broadcast route in the /etc/rc.d/init.d/dhcpd script used to start dhcpd. In addition to the limited broadcast problem, there are some other problems that relate to old Linux kernels. Multiple network interfaces dhcpd cannot use multiple interfaces with Linux kernels prior to version 2.0.31. SO_ATTACH_FILTER undeclared This error may occur when compiling dhcpd under Linux 2.2. If it occurs, the symbolic link /usr/include/asm may be broken. That link should point to the Linux asm headers. Protocol not configured To run under Linux 2.1 and 2.2, dhcpd needs the CONFIG_PACKET and CONF_FILTER options configured in the kernel. If the message Set CONFIG_PACKET=y and CONFIG_FILTER=y in your kernel configuration is displayed during the dhcpd build, you need to reconfigure the kernel and enable these options. See Chapter 13, “Troubleshooting,” for information on configuring the kernel. IP BootP agent Linux 2.1 will run dhcpd only if the BootP agent is enabled. (The BootP agent is part of dhcpd.) Check to see whether /proc/sys/net/ipv4/ip_bootp_ agent exists. If it does, check to see if it contains a 1. If it doesn’t exist or contain a 1, insert the following line into a startup script to write a 1 to the ip_bootp_agent file: echo 1 > /proc/sys/net/ipv4/ip_bootp_agent Linux kernel 2.4 solves all of these problems. However, as the Linux kernel versions change and new releases of dhcpd are issued, new problems may emerge. See the README file that comes with the dhcpd distribution for the latest information. 232
Note: If you are looking for cheapest and affordable webspace to host and run your servlet application check Astra servlet hosting services

Reverse Address Resolution Protocol Before leaving the topic of configuration protocols, we should quickly mention Reverse Address Resolution Protocol (RARP). As the name implies, it is the reverse of ARP. Instead of asking for an Ethernet address in response to an IP addresses, this protocol broadcasts an Ethernet address, and asks for an IP address in response. A RARP server uses the /etc/ethers file to map Ethernet addresses to IP addresses. It then sends the IP address from the ethers file to the client system. A sample /etc/ethers file is shown here: 00:00:C0:4F:3E:DD bluejay 00:10:4B:87:D4:A8 duck 08:00:20:82:D5:1D raven 00:00:0C:43:8D:FB osprey Each line in the file contains an Ethernet address, followed by a hostname or IP address. Hostnames are most commonly used, but they must be valid names that map to IP addresses. We mention this protocol because the nsswitch.conf file covered in Chapter 4, “Linux Name Services,” includes /etc/ethers as a part of the NIS service, which might make you curious about it. However, you should not use RARP. RARP only provides the client with an IP address. No other configuration information is provided. Much better configuration servers are available for Linux, including DHCP, which is the right configuration server for most networks. Installing the DHCP Server Many Linux distributions include the DHCP daemon (dhcpd). dhcpd is the server side of DHCP, and is required only on the DHCP server. The clients do not run dhcpd. Information on configuring a DHCP client is provided later in the chapter. The DHCP server software is a component that can be selected during the initial Linux installation. If the DHCP server software was not installed as part of the initial installation, install it now using a package manager such as the rpm command or the X Windows tool gnorpm. If you use gnorpm, DHCP can be found in the System Environment/Daemons display. Note For an example of using the rpm command to install a software package, see the “Using Package Manager” section in Chapter 5, “The Apache Web Server.” Of course, it is possible that your Linux system does not come with the DHCP software, or that you want a more recent version than the one that comes with your system. In either case, you can download the source code for dhcpd from http://www.isc.org/ or (via anonymous FTP) from ftp.isc.org/isc/dhcp , where it is stored in a gzipped tar file. Restore the tar file, change to the directory it creates, and run the ./configure script located there. configure determines the type of system you’re running, and creates the correct Makefile for that system. Run make to compile the software. (If you have an outdated Linux system, see the following sidebar, “Using dhcpd with Old Linux Kernels,” for information about problems that you might encounter.) On current Linux systems, dhcpd should compile without errors. Of course, things may change with future releases. If you get errors, send mail to the dhcp-server@isc.org mailing list, describing your configuration and the exact problem you have. The list is read by most of the people using dhcpd, and someone may have already solved your problem. To join the mailing list, go to www.isc.org/services/public/lists/dhcp-lists.html and fill out the form. 231
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services

The client puts all of the information it knows about itself in the BOOTREQUEST packet, which might be only its physical-layer address. When a BootP server receives a packet on port 67, it creates a BOOTREPLY packet by filling in as much of the missing configuration information as it can. The server then broadcasts the packet back to the network using UDP port 68. The client listens on port 68. When it receives a packet on the port that contains its physical-layer address, it uses the information from the packet to configure TCP/IP. Dynamic Host Configuration Protocol BootP is simple and effective. So effective, in fact, that it became the basis for Dynamic Host Configuration Protocol. DHCP operates over the same UDP ports, 67 and 68, as BootP. It provides all of the services of BootP as well as some important extensions. DHCP is designed to provide all possible TCP/IP configuration parameters to its clients. DHCP includes every parameter that was defined in the “Requirements for Internet Hosts” RFC, which means that everything necessary for TCP/IP can be configured from the DHCP server. The other, and probably more important, extension is that DHCP permits IP addresses to be dynamically assigned. Manually configuring a system with ifconfig permanently assigns an address to the interface. The address assigned to a host through BootP is also a permanent assignment. Both of these techniques are static the address is permanently assigned and cannot be used for any other host. With DHCP, an address is “leased” to the host for a specific period of time. When the time expires, the host must either renew the lease or return the address to the server so that it can be assigned to another system. The advantages of dynamic address assignment are as follows: You don’t need to create a custom configuration for each host. On a BootP server, you must create a configuration for every client because you are responsible for assigning each system a unique IP address. With a DHCP server, the server is responsible for the address assignments. It makes more effective use of scarce IP addresses. Unused addresses are returned to the address pool, from where they can be used again. Dynamic address assignment, like everything else, is not perfect. DNS may not know about addresses that are assigned through DHCP, which means that remote computers could not look up the address of a system that got its address from DHCP. In that case, a system using a dynamically assigned address could not offer services to other systems. This is a shortcoming, but it’s not a fatal flaw. First, only officially recognized servers should offer services to other systems, and skilled technical people who don’t have any trouble doing a TCP/IP configuration run most servers. Second, the number of servers on a network is small compared with the total number of systems, and therefore the burden of server configuration is correspondingly small. Third, the bulk of the systems on a network are desktop systems that shouldn’t offer TCP/IP services to remote users, so they do not need static IP addresses. This makes desktop clients perfect candidates for dynamic address assignment. And finally, there are techniques for coordinating addresses between DHCP and DNS using Dynamic DNS (DDNS). To find out more about DDNS, see Linux DNS Server Administration by Craig Hunt, Sybex 2001. Even without DDNS, DHCP works fine for most systems, and can dramatically decrease the configuration workload. 230
Note: If you are looking for high quality webhost to host and run your jsp application check Vision jsp hosting services

« Previous PageNext Page »