One of Linux DHCP servers

Source: Internet
Author: User
Article Title: One of Linux DHCP servers. 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.
I. DHCP Overview
  
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.
  
Main functions of v2.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.
  
Ii. How DHCP works
  
1. Several 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.
  
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, which is the message operation code. If the value is 1, it indicates that BOOTREQUEST (self-raising request) is 2, it indicates BOOTREPLY (self-raising 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 random number for all client requests and server responses in 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
  
2.1 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 connect to the client before the IP address is not configured.
The Unicast response is received, and the remaining low bits are 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.
  
2.2 about 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.
  
2.3 encoding format of DHCP options
  
Code Length value
  
26, 2, 1 m2
  
  
  
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:
  
Code Length Subnet Mask
  
1 4 m 1 M2 m3 m4
  
  
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.
  
  
Code Length Type
  
53 1 1-7
  
   
  
Value Message Type
1 DHCPDISCOVER
2 DHCPOFFER
3 DHCPREQUEST
4 DHCPDECLINE
5 DHCPACK
6 DHCPNAK
7 DHCPRELEASE
  
  
  
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.

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.