LinuxDHCP Server Configuration

Source: Internet
Author: User
Article Title: LinuxDHCP server configuration. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
11.1 DHCP Overview
11.1.1 necessity of using DHCP
In TCP/IP networks, before each workstation can access resources on the network, basic network configurations must be performed. Some main parameters, such as IP addresses, subnet masks, and default gateways, DNS is essential, and some additional information, such as IP management policies, may be required. For a slightly larger network, the task of network management and maintenance is rather heavy. If a computer is transferred from one subnet to another, you need to reconfigure the system. It is not necessary for normal level workstation users to grant them the permissions to configure their workstation network. If a user who does not have the corresponding technical level mistakenly changes the network configuration of the workstation out of curiosity or want to learn, resulting in a network failure, the consequences are self-evident. Therefore, a mechanism is required to transfer TCP/IP configuration and management from the user end to the network management end to implement centralized IP management. The solution is to use DHCP.
  
11.1.2 main functions of DHCP
DHCP stands for the Dynamic Host Configuration Protocol (Dynamic Host Configuration Protocol), designed by the IETF (Internet network engineer Task Team). The detailed Protocol content is in RFC documents rfc2131 and rfc1541. The objective is to reduce the planning, management, and maintenance burden of TCP/IP networks and solve the problem of insufficient IP address space. The server running DHCP sets up the TCP/IP network and dynamically processes the IP Address Configuration of the workstation. The DHCP lease is associated with the preset IP address, the DHCP lease provides a mechanism to automatically and securely allocate and lease IP addresses on TCP/IP networks to achieve centralized IP address management without human intervention from network administrators. In addition, DHCP is designed as an extension of BOOTP (self-lifting Protocol). It supports diskless workstations that require network configuration information and provides corresponding support for systems that require fixed IP addresses.
  
11.2 how DHCP works
11.2.1 DHCP terms
Before introducing the working principle of DHCP, explain the meanings of these terms:
  
DHCP Client: An Internet host that obtains network configuration parameters through DHCP, usually the workstation of a common user.
  
DHCP server: the DHCP server provides network setting parameters to the DHCP Client's Internet host.
  
DHCP/BOOTP relay Proxy: the host or router that forwards DHCP messages between the DHCP client and the server.
  
DHCP is designed based on the client/server model. DHCP clients and DHCP servers send and receive DHCP messages for communication.
  
11.2.2 DHCP Message format:
    
The format of DHCP messages is the same as that of BOOTP messages. This design enhances the BOOTP server tool and serves both BOOTP and DHCP. In addition, the BOOTP relay proxy can forward DHCP requests across subnets.
  
The sections are described as follows:
  
The numbers in the brackets indicate the size of this segment in 8-bit groups. Except for options, the lengths of other segments are fixed, the length of the options segment must be at least 312 8-bit groups.
  
For example, op (1) indicates that the length of this segment is an 8-bit group.
  
Op is the message operation code. If the value is 1, it indicates that BOOTREQUEST (User-initiated request); if the value is 2, it indicates BOOTREPLY (User-initiated response)
  
During the dialogue between the DHCP client and the DHCP server, the op segment is set as BOOTREQUEST (1) by the DHCP Client and BOOTREPLY (2) by the DHCP server ).
  
Htype is a hardware address type.
  
Hlen is the hardware address length.
  
The hops DHCP Client sets this item to zero, and the relay proxy needs to use
  
A random number generated by the xid DHCP client upon request. It provides a combination of client requests and server responses in all subsequent DHCP messages.
  
The ciaddr client is used to request a specific IP address, which was previously assigned to the client and is expected to be retained.
  
Yiaddr is filled in by the DHCP server, including the IP address it provides to a DHCP client.
  
Host address of the siaddr Server
  
IP address of the giaddr relay proxy
  
Chaddr DHCP client hardware address
  
Sname server host name
  
File Startup file Name
  
Options
  
Before obtaining an IP address, the DHCP client uses the htype, hlen, and chaddr segments to indicate its hardware address. This value is used by the server and relay proxy that responds to the customer's hardware address. Two unused 8-bit flags in the BOOTP protocol are defined in the DHCP message. The high bit of this segment is used to indicate whether the client can receive the Unicast response before the IP address is configured. The remaining low bit is retained and must be set to zero. The hops and secs segments are selectively used by the relay agent during initialization. The sname and file fields can be used by BOOTP or diskless websites.
  
Options
  
After the option is attached to a fixed length segment of the DHCP message, to be compatible with the BOOTP tool, the first four eight-bit groups of the Option segment contain
The magic cookies defined in RFC1497, the remaining segments are DHCP options. All DHCP options are defined in RFC1533.
Format. Most options are used to indicate network transmission settings, such as Subnet mask (mask), DNS server address, etc.
This option is used by the DHCP protocol and is required in most messages.
  
The encoding format of DHCP options is as follows:
    
The options can be fixed or variable length. All options start with an 8-bit group ID, which is used to identify the options. The Fixed Length option without data is composed of only one ID code. In addition, only option 0 and 255 are fixed lengths, and other options are variable lengths. to indicate the length of option data, an 8-bit group is followed by the ID code, the value of this 8-bit length group does not contain the ID code and Length Code itself.
  
For example, the subnet mask option in the DHCP option is defined as follows:
    
The ID code is 1 and the length is 4 8-bit groups. The subsequent 4 8-bit groups are subnet masks.
  
The DHCP Message Type option has a tag code of 53 and an 8-bit group with values ranging from 1 to 7, representing different DHCP message types.
    
  
The last option is an End with a zero length (option 255), indicating that this is the End of the option for DHCP clients to process. The advantage of option encoding is that DHCP clients can correctly receive the option no matter how long it is (not necessarily all DHCP client programs fully comply with RFC standards ).
  
Whether it is a DHCP client or a DHCP server, a specific DHCP message is formed by entering each segment according to the DHCP Message format requirements, non-connection-oriented UDP (User Datagram Protocol) of the transport protocol for DHCP, send DHCP messages from DHCP clients to port 67 of the DHCP server, the DHCP message sent from the DHCP server to the client is sent to port 68 of the DHCP client. Because the DHCP client does not have its own IP address before obtaining the IP address assigned by the server, therefore, the source IP address segment of the UDP datagram header containing the DHCP message is 0.0.0.0, And the destination IP address is 255.255.255.255.
  
11.2.3 dhcp ip Address Allocation Process:
The DHCP Client initializes TCP/IP and broadcasts a DHCPDISCOVER message on the local physical subnet to determine the DHCP server location and its IP address. If the DHCP server and the client are not in the same physical subnet, The BOOTP relay proxy forwards the message to the DHCP server. Since there may be more than one DHCP server on the network, all DHCP servers with valid IP address information will send a proposal to the client. The client selects IP address information from the first proposal received and broadcasts a message request for a lease address. The DHCP server that sends the proposal responds to the message, specifies the IP address information to the client, and sends a confirmation. All other DHCP servers recall their respective proposals. The client initializes and binds the TCP/IP protocol. After the configuration is complete, the client can use common network communication and all IP services and applications used to connect to other IP hosts.
  
11.3 install DHCP server software
  
Almost all Linux systems use Paul Vixie/ISC DHCPd to implement DHCP server functions. Visit http://www.isc.org/isc?news.
  
At present, most of the books in Linux contain this software. If it is Red Hat and provided in RPM form, you only need to simply install it with RPM.
  
# Rpm-I dhcpd-1.3.17pl5-i386.rpm
  
11.4 Basic Applications
  
According to the current situation, most Linux DHCP servers provide services for the Windows 95/98 client platform.
  
11.4.1 add Host Routing
  
To enable the DHCP server to serve the correct DHCP Client Machine in MS, you need to create a route to address 255.255.255.255 and add this route command to/etc/rc. d/rc. local to make the machine run automatically after each start.
  
# Route add-host route 255.255.255 dev eth0
  
In some old Linux core systems, error messages may be reported:
  
255.255.255.255: Unkown host
  
Try adding the following entries to the/etc/hosts file.
  
255.255.255.255 dhcphost
  
Use the following command
  
# Route add-host dhcphost dev eth0
  
11.4.2 modify the configuration file
The default configuration file/etc/DHCPd. conf of dhcpd is a text file. A syntax analyzer in DHCPd can perform syntax analysis on this file to obtain configuration parameters. The dhcpd. conf format is recursively degraded. The keywords are case sensitive and can be annotated. The comment starts with # until the end of the line. Here is a simple example of dhcpd. conf. The service network is Class C reserved network 192.168.1.0
  
# Examples
  
# Default lease time
  
Default-lease-time 28800;
  
# Maximum lease time
  
Max-lease-time 43200;
  
# Subnet mask options
  
Option subnet-mask limit 255.0;
  
# Broadcast address
  
Option broadcast-address 192.168.1.255;
  
# Vro address
  
Option routers 192.168.1.1;
  
# DNS address
  
Option domain-name-servers 192.168.1.1;
  
# Domain Name
  
Option domain-name netreslab.org;
  
# All the above are global Parameters
  
# Subnet description and mask
  
Subnet 192.168.1.0 netmask 255.255.255.0 {
  
# Range
R

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.