tcp/ip configuration and dhcp configuration for red...

21
TCP/IP Configuration and DHCP Configuration For Red Hat Linux 9 (RHL9) Presentation Report Course: CS 5780 - System Administration Instructed By: Dr. Sanjiv Bhatia Included: Executive Summary The OSI Protocol Architecture Introduction to TCP/IP Configuring TCP/IP for RHL9 Introduction to DHCP Configuring DHCP server for RHL9 Configuring DHCP client for RHL9 References Prepared on Thursday, November 13, 2003 By: David Nguyen

Upload: phamdan

Post on 30-Jan-2018

254 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

TCP/IP Configuration and DHCP Configuration For Red Hat Linux 9 (RHL9)

Presentation Report

Course:

CS 5780 - System Administration Instructed By:

Dr. Sanjiv Bhatia

Included:

Executive Summary The OSI Protocol Architecture

Introduction to TCP/IP

Configuring TCP/IP for RHL9

Introduction to DHCP

Configuring DHCP server for RHL9 Configuring DHCP client for RHL9

References

Prepared on Thursday, November 13, 2003 By:

David Nguyen

Page 2: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

1

Executive Summary

In effort to standardize the diverse network systems, the Open Systems Interconnection (OSI) protocol model was introduce by the International Standard Organization (ISO) in 1984 as a framework for developing communication protocol. The OSI model is based on seven layers. Each layer is designed to provide specific services to the layer above it. The objective of the bottom layer is to hide the network complexity from the layers above it and isolate the operation of the data transfer process at each layer. The TCP/IP protocol is the common protocol on most computer systems. TCP/IP is a protocol suite consists of a large collection of protocols that are the communication protocol of the internet. TCP/IP is consisted of four layers, application, transport, network access, and physical layer. Each layer of the TCP/IP protocol can be related to the OSI model. Every computer connected to the TCP/IP network must have a unique IP address. IP address can be Class A, B, C, D, or E. IP address can be further divided to obtain a subnet number. Some special IP address has special meaning and reserved from general used. To allow the computer to communicate beyond the LAN, gateway or router is employed. To configure TCP/IP for Red Hat Linux 9 (RHL9) manually, the process can be done in four steps, loading network driver for the interface card, modify the network configuration files, configure the network interface, and modify the routing table. RHL9 provide a graphical user interface (GUI) tool to configure TCP/IP called �redhat-config-network�. The GUI of �redhat-config-network� has four tabs, Devices, Hardware, DNS, and Hosts. New and existing network hardware and interface device can be managed in the Hardware tab and Devices tab. Thus, DNS server and static host name can be managed in the DNS tab and Hosts tab. DHCP is a network protocol for automatically assigning IP address to computers on a network. Each computer on the network connects to a central DHCP server which sending the client�s network configuration including IP address, subnet mask, gateway, and DNS servers. DHCP simplify the task of administration for client system configuration and management. The heart and soul of a DHCP server is lay within its configuration file, /etc/dhcpd.conf. The configuration file defines how the server assigns information to client base on the subnet and media access control (MAC) address. Configuring DHCP client for RHL9 is similar to configuring TCP/IP for RHL9. However, the process is much simpler because it requires no knowledge of the network TCP/IP setting. DHCP client can be configured manually or configured via �redhat-config-netwok� GUI tool.

Page 3: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

2

I. The Open System Interconnection (OSI) Protocol Architecture In effort to standardize the diverse network systems, the Open Systems Interconnection (OSI) protocol model was introduce by the International Standard Organization (ISO) in 1984 as a framework for developing communication protocol. The OSI model is based on seven layers. Each layer is designed to provide specific services to the layer above it. The objective of the bottom layer is to hide the network complexity from the layers above it and isolate the operation of the data transfer process at each layer. Figure 1.1 describes the services at each layer of the OSI model.

Application

Presentation

Session

Transport

Network

Data Link

Physical

End user application program.

Establishes and control communicationbetween applications. Ensure securitydelivery, and communication recovery.

Provides error recognition and recovery.Ensure that all data are properly delivered,add transport layer-specific ID.

Provide end-to-end routing of packets.Split long messages into smaller units.

Creates data frame for transmission and controlsthe shared access to network physical medium.Include error checking, correction, etc.

Figure 1.1 The OSI Protocol Architecture Model

Provides formatting for the application layer.Conversion, compression, encoding, and etc.

Provides standards dealing with the electricaldetail of the transmission (NIC, cable type, etc).Physically transmits frames of data through thecable.

II. Transmission Control Protocol / Internet Protocol (TCP/IP)

Introduction Although the architecture of the OSI protocol model is often used to describe communication function, it is rarely implemented. Instead, TCP/IP is the selected protocol on most systems because of its popularity. Moreover, TCP/IP is supported by almost every operating systems and hardware vendors. TCP/IP is the communication protocol used by UNIX systems for years. It was a result of the protocol research and development conducted on the experimental packet-switched network, ARPANET. The project was funded by the Defense Advanced Research Project Agency of the U.S. Department of Defense in 1960. TCP/IP protocol is considered as a protocol suite. The protocol suite consists of a large collection of protocols, which are the communication protocol of the internet today (see figure 2.1).

Page 4: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

3

TCP

IP

RSVPOSFSIGMPICMP

UDP

BGP FTP SNMPTELNETSMTPHTTP

MIME

Figure 2.1 The TCP/IP Protocol Suite

BGP = Border Gateway Protocol OSPF = Open Shortest Path FirstFTP = File Transfer Protocol RSVP = Resource reSerVation ProtocolHTTP = Hyper Text Transfer Protocol SMTP = Simple Mail Transfer ProtocolICMP = Internet Control Message Protocol SNMP = Simple Network Management ProtocolIGMP = Internet Group Management Protocol TCP = Transmission Control ProtocolIP = Internet Protocol UDP = User Datagram ProtocolMIME = Multipurpose Internet Mail Extension

TCP/IP, particularly TCP (transmission control protocol) and UDP (user datagram protocol), use ports to name the ends of logical connections, which carry the communication. There are 216 = 65536 ports for TCP and 216 = 65536 ports for UDP. Each application running on the same host that uses TCP or UDP can be associated with unique port number. Some of the reserved port for TCP is listed in figure 2.1A.

5 Remote Job Entry 80 World Wide Web http7 Echo 88 Kerberos20 FTP (default data) 108 SNA Gateway Server21 FTP (control) 119 Network News Transfer Protocol23 TELNET 161 SNMP Agent Port25 SMTP 162 SNMP Manager Port43 WhoIs 179 Border Gateway Protocol53 Domain Name Server 194 Internet Relay Chat Protocol79 Finger 389 Lightweight Directory Access Protocol

Figure 2.1A Transmission Control Protocol Assigned Port Numbers

Application

Presentation

Session

Transport

Network

Data Link

Physical

Application

Transport(host-to-host)

NetworkAccess

Physical

OSI Model TCP/IP

Figure 2.2 A comparison of the OSI and TCP/IP protocol architectures

Page 5: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

4

Architecturally, TCP/IP is consisted of four layers. They are application, transport, network access, and physical layer. Each layer of the TCP/IP protocol and its service can be compare to the OSI model is in the figure 2.2. Internet Addressing Every computer connected to the TCP/IP network (or internet) must have a unique internet protocol (IP) address. This address is represented in four octets; each octet is represented in eight bits binary (total 32 bits long). The valid value for each octet is ranged from 0 to 255 (11111111 = 28). Figure 2.3 show the format and a valid range of IP address.

2.3 Format and a valid range of IP address

4th octet3rd octet2nd octet1st octet

0-255

11111111 11111111 11111111 11111111

0-255 0-255 0-255

IP addresses comprise two parts. The network ID and the host ID. An IP address can identify a network (if the host part is all zero) or an individual host. There are 3 principal and 2 reserved network address classes for IP. They are:

• Class A: Few networks, each with many hosts. • Class B: Medium number of network, each with a medium number of hosts. • Class C: Many networks, each with a few hosts. • Class D: Reserved for multicast. • Class E: Reserved for experimental purpose.

Class A address

1.0.0.0 to126.255.255.255

0 7 bits network 24 bits host

10 14 bits network 16 bits host

110 21 bits network 8 bits host

Class B address128.0.0.0 to

191.255.255.255

Class C address192.0.0.0 to

223.255.255.255

1110 multicastClass D address

224.0.0.0 to239.255.255.255

11110 future useClass E address

240.0.0.0 to225.255.255.255

Figure 2.4 IP address formats and range

Class A network address begins with a binary 0 in the first octet, so the range of the first dotted decimal number in class A address is 0 to 127 (binary 00000000 to 01111111). Network addresses with the first dotted decimal of 0 (binary 00000000) and 127 (binary

Page 6: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

5

01111111) are reserved, so there are 126 potential class A network numbers, which have a first dotted decimal number in range 1 to 126. Class B network address begins with a binary 10 in the first octet, so the range of the first dotted decimal number in class B address is 128 to 191 (binary 10000000 to 10111111). The second octet is also part of the class B address so that there are 214 = 16,384 class B addresses. Class C network address begins with a binary 110 in the first octet, so first dotted decimal number ranges from 192 to 223 (binary 11000000 to 11011111). The total number of class C address is 221 = 2,097,152. Class D network address begins with a binary 1110 in the first octet, so first dotted decimal number ranges from 224 to 239 (binary 11100000 to 11101111). These addresses are reserved. Class E network address begins with a binary 11110 in the first octet, so first dotted decimal number ranges from 240 to 255 (binary 11110000 to 11111111). These addresses are reserved. Subnet and subnet masks IP address can be further divided to obtain the network number, subnet number, and host number. The network number identifies a network of networks. The subnet number identifies a sub network within that particular network. The concept of sub-netting was introduced to allow the flexibility of interconnected LAN structures within an organization, while insulate the over-all internet against the unnecessary growth in network numbers and routing complexity. To find the network number, subnet number, and host number of an IP address, the calculation involves the use of the subnet mask. The effect of the subnet mask is to erase the portion of the IP address that references the host number on a subnet. What remain are the network number and subnet number. Figure 2.5 demonstrated the use of the subnet mask for the IP address 134.124.15.13 (admiral.umsl.edu).

IP address

Bitwise AND of addressand mask (resultant

network/subnet number)

Subnet mask

Subnet number

Host number

10000110.01111100.00001111.00001101

11111111.11111111.11111111.00000000

10000110.01111100.00001111.00000000

10000110.01111100.00001111.00000000

00000000.00000000.00000000.00001101

Binary Representation Dotted decimal

134.124.15.13

255.255.255.0

134.124.15.0

15

13

Figure 2.5 IP address, subnet mask, network number, subnet number, and host number

Page 7: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

6

Special address Some special IP address has special meaning.

• Network ID 0.0.0.0 means �this host�. • Address 127.0.0.0 is also means �this host� (loop back interface). • The first address and last address in the range of addresses of a network is reserved

for the network number and broadcast address respectively. These IP addresses may vary depend on the subnet mask.

• Addresses 10.x.x.x are Class A addresses reserved for private used. • Addresses in range 172.16.x.x to 172.31.x.x are Class B addresses reserved for

private used. • Addresses in range 192.168.0.x to 192.168.255.x are Class C addresses reserved for

private used. • Addresses in rang 224.x.x.x to 239.x.x.x are class D address that is used for

multicasting. • Addresses in range 240.x.x.x to 255.x.x.x are class E address that is reserved for

experimental purpose. Routing Because of the structure of the IP addressing, a host on a network can only communicate with other hosts on the same network. To overcome this limitation, router or gateway is employed. Routing is the mechanism that determines the path of a data packet taken from its source to its destination. The route of packet is determined by looking up the destination IP address in a routing table. The machine or device that performs these routing and/or forwarding functions is called a gateway or router. There are four common type of routing:

• Minimal - a network completely isolated from all other networks requires only minimal routing.

• Static - a network with one or two gateways is typically configured using static routing.

• Dynamic � a Large networks that have multiple routers and/or gateways installed, perhaps pointing to the same remote network for redundancy purposes

• Static and Dynamic - a combination of static and dynamic routing III. Configuring TCP/IP for RHL9 The network topology in figure 3.1 is shown the physical layout of a small typical Linux network. For demonstration purpose, the discussion of this report will strictly focus only on ethernet network.

Page 8: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

7

ServerNottingham (192.168.0.2)

Workstation Workstation Workstation

The Internet

Gateway / RouterDotnet (192.168.0.1)

Figure 3.1 Ethernet Network

HubNetwork 192.168.0.0 (Netmask 255.255.255.0)

Workstation

Configure TCP/IP for RHL9 manually Configuring a static IP address for TCP/IP for Red Hat Linux 9 (RHL9) consist of four steps. They are:

• Loading the network driver for the interface card. • Modify the network configuration files. • Configure the network interface. • Modify the routing table.

In RHL9, loading the network driver for network interface card is handled by a utility program called �kudzu�. Kudzu is a hardware probing tool that runs when the system boot up to determine what hardware has been added or remove from the system. Kudzu can detects and configures new network hardware at the system boot time. Alternatively, kudzu can be run after the system started to configure any change to the network hardware that did not configured during boot. It is advisable to let kudzu to handle the network hardware detection since kudzu automatically loads the appropriate driver module into the kernel and configure the network hardware correctly. It eliminates the guessing work in the trial and error method. Once the network driver for the network interface card is loaded, a set of network configuration files need to be modified. These files can be found in the directory /etc. They are: /etc/hosts /etc/hosts is a text file that maps host names to IP addresses. The host file allowed users to refer to an IP address by it alias. Each entry in /etc/hosts contains an IP address and follows by a hostname and/or alias. All fields are separate by a space or tab. The /etc/hosts is consulted to resolve a host name to IP address before queries domain name server (DNS). Moreover, many network configuration scripts are depended on the �localhost.localdomain� entry in the /etc/hosts file to set its parameter on start up. Figure 3.2 show a typical representation of /etc/hosts file.

Page 9: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

8

# /etc/hosts# Do not remove the following line, or various programs# that require network functionality will fail.127.0.0.1 localhost.localdomain localhost192.168.0.1 dotnet.home.net dotnet192.168.0.2 nottingham.home.net nottingham192.168.0.3 saigon.home.net saigon192.168.0.4 hanoi.home.net hanoi134.124.15.13 admiral.umsl.edu admiral134.124.30.128 hoare.cs.umsl.edu hoare134.124.15.133 jinx.umsl.edu jinx134.124.15.136 EPSILON3.umsl.edu EPSILON3

Figure 3.2 Sample /etc/hosts file /etc/resolv.conf /etc/resolv.conf is used by the network for hostname resolution (Figure 3.3). The �domain� entry defines the default domain name. The default domain name is automatically appended to a host name that does not contain any dot (.). The /etc/resolv.conf can contain up to three DNS servers. The last two servers are backup server in case of the first server is failed or timed out.

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

# /etc/resolv.confdomain home.netnameserver 24.217.0.3nameserver 24.217.0.4

Figure 3.3 Sample /etc/resolv.conf file

In Linux, the network interface card can be activated using the command /sbin/ifconfig. The ifconfig command is a complex networking utility that can set, check and monitor the values of a network interface card. When ifconfig executed without any parameter, it displays the status of all network interface that has been activated in the system. This information is very useful when we are configured static IP address for DHCP server in the later section of this report. The simplest syntax of ifconfig command to bring up the network interface is shown in figure 3.4. For complex options, please see the man page.

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

Syntax: Ifconfig interface-name ip-address/netmask up | down

Example 1: ifconfig eth0 192.168.0.2/24 upExample 2: ifconfig eth0 192.168.0.2 netmask 255.255.255.0 upExample 3: ifconfig eth0 down

Example 1 and 2 are equivalent which tell ifconfig to activate network interface eth0,assign IP address 192.168.0.2 to it, and use netmask 255.255.255.0.

Example 3 tells ifconfig to deactivate network interface eth0.

Figure 3.4 The /sbin/ifconfig command

Page 10: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

9

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

Syntax: route add | del default gw gateway-ip-address

Example 1: route add default gw 192.168.0.1Example 2: route add 0.0.0.0 gw 192.168.0.1Example 3: route del default

Example 1 and 2 are equivalent which tell route to add a default routing entry into therouting table which will route all the packet to the gateway if it does not know the routeto the destination.

Example 3 tells route to remove the default routing entry in the routing table.

Figure 3.5 The /sbin/route command

As default, the routing table only contains a minimum entry to allow hosts on the same network to communicate. After the network interface has been activated, the routing table must be modified to add a new route to the default gateway. The routing table can be view or modify with the command /sbin/route. When the route command is executed without any argument, it displays the current entries in the routing table. Figure 3.5 shows the syntax for adding and deleting an entry in the routing table. Complex options can be found in the man page for the /sbin/route command. Last, the hostname must be set since many TCP/IP protocols require the system to identify its self by name to each other. The hostname can be set using the command /bin/hostname. When execute without any parameter, the hostname command returns the current assigned hostname of the system, which defaulted to �localhost.localdomain�. Figure 3.6 show the syntax and the example of the /bin/hostname command.

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

Syntax: hostname <hostname.domainname>

Example 1: hostname nottingham.home.net

Example 1 tells the hostname command to assign nottingham.home.net to the hostname of the system.

Figure 3.6 The /bin/hostname command Some of the preceding procedure, such as editing the network configuration files is a permanent change. However, the ifconfig, route, and hostname command to adjust the system setting is not. These changes will only last as long as the system is up. To make these changes permanent, they must be included in the system start up script. For RHL9, this file is /etc/rc.d/rc.local. Figure 3.7 shows a sample of /etc/rc.d/rc.local file that include the system change previously with the ifconfig, route, and hostname command.

Page 11: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

10

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

# /etc/rc.d/rc.local# You can put your own initialization stuff in here if you don't# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# Activate network interface eth0/sbin/ifconfig eth0 192.168.0.2/24 up

# Add default route/sbin/route add default gw 192.168.0.1

# Set host name/bin/hostname nottingham.home.net

Figure 3.7 Sample /etc/rc.d/rc.local file

Configure TCP/IP for RHL9 via graphical user interface The manual process in configuring TCP/IP for RHL9 can configure TCP/IP networking just fine for any RHL9 system. However, the tediousness of locating and modifying the network configuration files is very time consuming task. Fortunately, RHL9 provide a graphical user interface (GUI) utility program call �redhat-config-network� which reside in the directory /usr/sbin to perform the TCP/IP network configuration at ease. The redhat-config-network simplifies most of the manual process in configure TCP/IP. Nevertheless, the user still required to have a substantial amount of networking knowledge including the TCP/IP setting of the network in configuring the new system to communicate with the entire local area network (LAN) and the internet. There are four steps to configure TCP/IP using redhat-config-network. Each step is performed within a separated tab of the GUI. These tabs are Devices, Hardware, DNS, and Hosts. Adding network hardware

Figure 3.8 The Hardware tab of redhat-config-network

Page 12: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

11

Network hardware must be added before it can be configured. Existing network hardware configuration can be modified or deleted after it had added to the system. These tasks can be accomplished by using the Hardware tab within redhat-config-network (figure 3.8). In Hardware tab, user can add, modify, or delete a network hardware profile or specify any special setting regarding the network hardware. All changes must be saved before user can proceed further. Adding new device

Figure 3.9 The Devices tab of redhat-config-network

Figure 3.9A Modify network setting Once new network hardware is added in Hardware tab, user can configure a new network interface by associate it to a device in the Devices tab within redhat-config-network (figure

Page 13: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

12

3.9). Any existing network interface in the device tab can be activate, deactivate, modified or deleted; however, extreme caution must be exercised. Mistakenly, deactivate, delete or modify an interface may cause serious unpredictable network behavior of the system. Any changes made in the Device tab must be saved before user can proceed further. Redhat-config-network allowed each interface in the Devices tab to be manual activated by the user or automatically activate at boot time (configurable). Advanced options such as multiple interfaces, multiple route, and gateways can also easily configure by editing the networking setting of the network device (figure 3.9A). Adding DNS entries

Figure 3.10 The DNS tab of redhat-config-network

Similar to the manual process in configuring TCP/IP for RHL9, DNS server must be provided to resolve host name into IP address. The IP address entry of DNS can be specify in the DNS tab of redhat-config-network (figure 3.10). Up to 3 DNS server IP address entries can be specify. DNS search path is an option that allowed user to reduce typing by omitting the specified domain name when performing network accesses. Though this option provides some convenience, its usage is not recommended to avoid potential problem in resolving IP address of a host name on a network. In addition to DNS server entries, host name can also be specified in the DNS tab. This is the same as to adding the /bin/hostname command into /etc/rc.d/rc.local to set the host name at the system start-up.

Adding static host name entries Similarly, static host name IP address mapping entries can be specified in the Hosts tab of redhat-config-network (figure 3.11). These entries will have precedence over any DNS attempt to resolve a hostname. For efficiency, every host normally maintain in own mapping copy of all local hosts on its network. This prevents the system to queries the DNS to resolve a local host name, which may take longer time to process.

Page 14: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

13

Figure 3.11 The Hosts tab of redhat-config-network IV. Introduction to Dynamic Host Control Protocol (DHCP) DHCP is a network protocol for automatically assigning IP address to computers on a network. Each computer on the network connects to a central DHCP server which sending the client its network configuration including IP address, subnet mask, gateway, and DNS servers. (Figure 4.1) DHCP simplify the task of administration for client system configuration and management. When configuring client systems, administrators can select DHCP and do not have to enter IP address, subnet mask, gateway, or DNS servers. The client system retrieves such information from the DHCP server when initiating a network connection at boot time. DHCP is also useful as a central administration tool. Administrator can change the IP address of some or all of the client systems on the network by just editing the DHCP configuration file on the server. Moreover, if the address of DNS servers changed, no modification is required on the client system. The change is only needed to update at a central location, DHCP server. Once the network restarted and client systems rebooted, the change will take affect on every client systems.

Page 15: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

14

DHCP ServerNottingham (192.168.0.2)

DHCP ClientSaigon (192.168.0.3)

DHCP ClientHanoi (192.168.0.4)

DHCP ClientDynamic IP Address

The Internet

Gateway/Router

Figure 4.1 Dynamic Host Conrol Protocol

HubNetwork 192.168.0.0 (Netmask 255.255.255.0)

DHCP ClientDynamic IP Address

Client ConfigurationIP addressNetmask

DNS serverGateway address

Domain Name

V. Configuring DHCP Server for RHL9 The heart and soul of a DHCP server is lay within its configuration file, /etc/dhcpd.conf. The configuration file defines how the server assigns information to clients on base on the subnet and media access control (MAC) address of the client system. Configuration file The configuration file contains statements that are written in a rule base scripting language. It may contain extra tabs or blank lines for formatting purpose. The keywords are case sensitive and comments are started with a hash symbol (#). The statement in the DHCP configuration file fall into 2 categories; they are parameter, which are instructions for DHCP server or information to provide to client, and declaration, which describe the topology of the network or associate parameter with a set of declaration. Some declarations rely on information described in parameter. In such case, the parameter must precede the declaration in the file. Declaration that span into multiple lines must enclose in a pair of curly brace ({}). Some parameters start with the �option� keyword is referred to as option. Option configures DHCP server options; whereas parameters configure value that are not optional or control the way DHCP server behaves. Parameters and options declare before a section that enclosed in curly bracket is considered global parameters, which apply to all sections below it. The configuration file must also define a DNS update scheme. There are two method is currently in used. They are ad-hoc method and an interim method. The statement defines a DNS update scheme for the DHCP server should existed on top of the configuration file. Figure 5.1 show a sample of /etc/dhcpd.conf file.

Page 16: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

15

# DNS update scheme. Requiredddns-update-style interim;

# Gatewayoption routers 192.168.0.1;

# DNS server. Up to 3 servers allowedoption domain-name-servers 24.217.0.3, 24.217.0.4;

# Assign dynamic IP address to this subnetsubnet 192.168.0.0 netmask 255.255.255.0 { default-lease-time 7200; # 2 hours max-lease-time 10800; # 3 hours option subnet-mask 255.255.255.0; option domain-name "home.net"; get-lease-hostnames true; # look up hostname from DNS

range 192.168.0.100 192.168.0.254; # dynamic IP address range}

# DHCP server ignore request from this subnetsubnet 192.168.1.0 netmask 255.255.255.0 {

# unused interface}

# Group specific options and parametersgroup { default-lease-time 86400; max-lease-time 86400;

# Assign declare hostname to client use-host-decl-names true;

# Static IP address assignment host saigon { hardware ethernet 00:10:4B:75:2F:9E; fixed-address 192.168.0.4; }

# Static IP address assignment host hanoi { # Overwrite hostname assignment option host-name "hanoi.home.net"; hardware ethernet 00:A0:CC:34:7E:70; fixed-address 192.168.0.3; }}

Figure 5.1 Sample /etc/dhcpd.conf file

Subnet declaration and dynamic IP address assignment Every subnet on the network must be declared in /etc/dhcpd.conf file otherwise DHCP server will fail to start. Subnet declaration start with the keyword �subnet� follows by subnet ID and the key word �netmask� which follow by netmask number. Subnet declaration has a �range� declaration that defines a range of IP address that the server will offer. This range is generally outside the range of IP address that permanently assigned to devices and systems that offer service on the net work such as printers, DNS servers, routers, gateways, etc. For subnet on the network that is not required the service of DHCP server, an empty subnet declaration (without �range� declaration) on a subnet is causing the DHCP server not to respond to any request on that subnet. (Figure 5.2)

Page 17: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

16

# Assign dynamic IP address to this subnetsubnet 192.168.0.0 netmask 255.255.255.0 { default-lease-time 7200; # 2 hours max-lease-time 10800; # 3 hours option subnet-mask 255.255.255.0; option domain-name "home.net"; get-lease-hostnames true; # look up hostname from DNS

range 192.168.0.100 192.168.0.254; # dynamic IP address range}

# DHCP server ignore request from this subnetsubnet 192.168.1.0 netmask 255.255.255.0 {

# unused interface}

Figure 5.2 Subnet declaration in /etc/dhcpd.conf file Static IP address assignment Client system can operate well with dynamic IP address obtains from DHCP server; however, the obtained IP address is not guarantee to be the same every time. To ensure that DHCP server assign the fixed IP address to special purpose computers or devices on the network, the DHCP server must be configured to assign IP address base on the MAC address of the network device. The MAC address is the 6-byte hexadecimal number hardware address encoded on the ethernet by the manufacture. Though this is not a secure way to identify a specific hardware on the network, it is good enough for most purpose (MAC address can be overwritten by most operating system). MAC address can be located using the command /sbin/ifconfig. (Figure 5.3)

[root@localhost root]# /sbin/ifconfig eth0

eth0 Link encap:Ethernet HWaddr 00:10:4B:75:2F:9E BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:19 Base address:0x2800

Figure 5.3 MAC address of a network interface DHCP server delivers a fix IP address to a request client system by the host declaration. This declaration begins with the keyword �host� and follows by the host name (without domain name). The host name can also be overwritten by the declaration �host-name�. Within the host declaration, the MAC address must be supply as parameter to the �hardware ethernet� declaration, and the �fix-address� declaration specify the IP address that will be assign to this MAC address. The static IP address assign to specify MAC address must be outside the range of dynamic IP address offer by the DHCP server, but within the network block. Overlapping static and dynamic IP address may cause in the DHCP server to refuse granting the overlapped address if it has already dynamic assigned. (Figure 5.4)

Page 18: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

17

# Static IP address assignmenthost saigon {

hardware ethernet 00:10:4B:75:2F:9E; fixed-address 192.168.0.4; }

# Static IP address assignmenthost hanoi {

# Overwrite hostname assignment option host-name "hanoi.home.net"; hardware ethernet 00:A0:CC:34:7E:70; fixed-address 192.168.0.3; }

Figure 5.4 Static IP address assignment Group declaration Parameters and options can be specified as local or global with in the /etc/dhcpd.conf file. However, there are situations that parameter and options must be specified for a group of client systems. The group declaration creates a group of identified hosts with some shared parameters. For instance, the administrator want the DHCP sever to provide host name to clients via DNS lookup or via the name used in the host declaration. The group declaration feature can be expand into other functionalities such as providing different boot files for different computers using �file-name� and �next-server� parameters, or optimize the network configuration for different group of systems on the network. (Figure 5.5)

# Group specific options and parametersgroup {

default-lease-time 86400; max-lease-time 86400;

# Assign declare hostname to clientuse-host-decl-names true;

# Static IP address assignment host saigon { hardware ethernet 00:10:4B:75:2F:9E; fixed-address 192.168.0.4; }

# Static IP address assignment host hanoi { # Overwrite hostname assignment option host-name "hanoi.home.net"; hardware ethernet 00:A0:CC:34:7E:70; fixed-address 192.168.0.3; }}

Figure 5.5 Group declaration in /etc/dhcpd.conf file

DHCP server operation DHCP server is using the file /var/lib/dhcp/dhcpd.leases to store the lease information for each recently assigned IP address. This information include the length of the lease, to whom the address has been assigned, the start and end dates for the lease, and the MAC address of the network interface card that was used to obtain the lease. This file must initially exist for

Page 19: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

18

DHCP server to startup. If it is not existed or corrupted, an empty file can be created using the �touch� command. If more than one network interface attached to a system but DHCP service is required on only one of the interface, modification can be made to the file /etc/sysconfig/dhcpd to instruct DHCP server to start only on the specified network interface by assigning the network interface name to the variable �DHCPDARGS�. (Figure 5.6)

# /etc/dhcpd# Command line options here

DHCPDARGS=eth0

Figure 5.6 The /etc/dhcpd file

DHCP server can be start, stop, or restart by issuing the command �/sbin/service�. (Figure 5.7)

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

Syntax: service dhcpd start | stop | restart

Example 1: /sbin/service dhcpd startExample 1 tells /sbin/service to activate the DHCP server.

Figure 5.7 Activating DHCP server

Last, no changes made to the configuration file will take effect until the DHCP server is restarted. VI. Configuring DHCP client for RHL9 Configuring DHCP client for RHL9 is rather similar to configuring TCP/IP for RHL9 as previously mentioned in section III. However, the process is much simpler and requires no knowledge of the network TCP/IP setting. Configure DHCP client manually Configuring a DHCP client consist of 3 steps. They are:

• Loading the network driver for the network interface card. • Modify network configuration files. • Reboot

Loading the network driver for the interface card is essentially the same as configuring TCP/IP for RHL9 Please refers to section III, Configuring TCP/IP for RHL9. To configure for DHCP client to obtain a leased IP address at boot time the file /etc/sysconfig/network and each device file in the directory /etc/sysconfig/network-scripts must be modified

Page 20: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

19

/etc/sysconfig/network /etc/sysconfig/network is a text file, which used to specify information about the desire network configuration. It is used by several scripts at boot up to determine if the system is configured for networking. It contains one or more keyword or value such NETWORKING and HOSTNAME. To configure the system for networking, the value for the keyword NETWORKING must set to value �yes�. (Figure 6.1)

# /etc/sysconfig/networkNETWORKING=yesHOSTNAME=nottinghamGATEWAY=192.168.0.1

# /etc/sysconfig/network

NETWORKING=yesHOSTNAME=localhost.localdomain

Figure 6.1 The /etc/sysconfig/network

Directory /etc/sysconfig/network-scripts/ The directory /etc/sysconfig/network-scripts contain the network interface device file ethN where N is the numeric value that identifies the network interface configuring for DHCP client. For instance, if the client system only has one network interface then the device file would be /etc/sysconfig/network-scripts/ifcfg-eth0. A separate configuration file for each network interface on the client system is required if such device need to obtain a dynamic IP address. In the file, three entries required. They are DEVICE, which must be set to the network interface that will obtain the IP address, BOOTPROTO, which must set to use the dynamic host control protocol, and ONBOOT, which tells the client system to obtain a dynamic IP address at boot time. (Figure 6.2)

# /etc/sysconfig/network-scripts/ifcfg-eth0

# Please read /usr/share/doc/initscripts-*/sysconfig.txt# for the documentation of these parameters.

DEVICE=eth0BOOTPROTO=dhcpONBOOT=yes

Figure 6.2 Sample /etc/sysconfig/network-scripts/ifcfg-eth0 Once the system is loaded the network interface driver and the modification the network configuration file is completed, the client system is required to reboot for all the proper changes go in effect. Configure DHCP client via graphical user interface Configuring DHCP client using �redhat-config-network� is rather simple and straightforward. Similar to configuring static IP address using �redhat-config-network�, the network hardware must be added in the Hardware tab. Once the network hardware has been added, it can be configured to obtain a dynamic IP address from the DHCP server in the Devices tab (default option). After the new device interface configuration is saved, and redhat-config-network is restarted, the new interface device is ready for manually activated to obtain an IP address from the DHCP server immediately. Otherwise, it will be activated on the next reboot.

Page 21: TCP/IP Configuration and DHCP Configuration For Red …sanjiv/classes/cs5780/projects/F03/nguyen.pdf · TCP/IP Configuration and DHCP Configuration For Red ... To configure TCP/IP

20

Figure 6.3 Configure DHCP client with redhat-config-network

VII. References Stalling, William. Business Data Communications, New Jersey: Prentice Hall, 2001. Smith, Roderick. Advanced Linux Networking, Boston: Addison Wesley, 2002. Nemeth, Evi; Garth Snyder; Scott Seebass; and Trent R. Hein. Unix System Administration Handbook, New Jersey: Pearson Education, 2000. Red Hat Linux 9, Red Hat Linux Customization Guide. http://www.redhat.com/docs/manuals/linux/RHL-9-Manual/custom-guide/