Setting up a DHCP server in Linux (RHEL5.2)

Source: Internet
Author: User
Environment: DHCP server IP192.168.1.211 (RHEL5.2) when there are a large number of hosts in the LAN, If you manually configure IP addresses, default gateways, DNS server addresses, and other network parameters for each host, the display is very laborious. The DHCP (Dynamic Host configurationprotocol) server application can solve this problem.

Environment: DHCP server IP Address192.168.1.211(RHEL5.2)

When there are a large number of hosts in the LAN, It is very laborious to manually configure network parameters such as IP addresses, default gateways, and DNS server addresses for each host one by one. The DHCP (Dynamic Host Configuration Protocol) server application can solve this problem.

1-)DHCPProtocol working method:

(1)Client: send DHCP server request packets using Broadcast

If DHCP is configured on the client network to automatically obtain the IP address, when the client starts up or restarts the NIC, the client host sends a message to find the IP address of the DHCP server.UDPData packets are sent to computers in all physical network segments. The destination IP address of this packet will be255.255.255.255(Broadcast), so generally the host will directly discard this packet after receiving it, but if there is a DHCP server in the LAN, it will perform subsequent behavior.

(2)Server: provides lease related to the client network for selection.

After receiving a request from the client, the DHCP server performs the following operations on the client's hardware address (MAC) and its own settings:

  • Go to the server log file to check whether the user has used an IP address in the group. If the IP address is unavailable, provide the IP address to the client.

  • If the configuration file provides a specific fixed IP address for the MAC address, the fixed IP address is provided to the client.

  • If the preceding conditions are not met, IP parameters that are not currently in use are randomly selected and recorded.

In short, the server will provide a set of network parameter leases for the client to select based on the client's requirements. Because the client does not have an IP address at this time, in the packet information returned by the server, it mainly responds to the MAC of the client (unicast response client ). At this time, the server will keep the lease and wait for the client to respond.

(3)Client: select the network parameter lease provided by the DHCP server and confirm with the server.

Because not only one DHCP server is available in the LAN, the client can accept only one set of network parameter leases. If Multiple DHCP servers in the network respond to the client, the DHCP server first responds to the client, and the client will accept the network parameters provided by the DHCP server. After you decide to use the network parameter lease provided by this server, the client starts to use this set of network parameters to set its own network environment. In addition, the client sends a broadcast packet to all hosts in the physical network segment to inform the host that the lease of the server has been accepted. At this time, if there are more than two DHCP servers, the unaccepted servers will reclaim the IP lease. The accepted server performs the following actions:

(4)Server: record the lease and confirm with the client

After receiving the confirmation and selection from the client, the server will send the confirmation response packet and inform the client of the term of the network parameter lease, and start the lease countdown.

Build DHCP server http://www.linuxidc.com/Linux/2013-06/86531.htm in Linux System

 

Configure master-slave DNS server and DDNS http://www.linuxidc.com/Linux/2013-06/85634.htm under DHCP in CentOS

 

SUSE Linux 11 pxe + DHCP + tftp + ftp unattended installation http://www.linuxidc.com/Linux/2013-06/85481.htm

 

The process of setting up DHCP server in Linux and the test http://www.linuxidc.com/Linux/2013-05/84832.htm

 

Linux previous step to implement DHCP server http://www.linuxidc.com/Linux/2013-04/82244.htm

 

Build DHCP server http://www.linuxidc.com/Linux/2014-06/103203.htm in CentOS 6.5 System

 

2-) Lease Term:

Unless the client disables network interfaces, restarts, shuts down, and other offline behaviors, the server will reclaim the IP address and place it in the standby zone of the server for future use.

Since there is a lease term, does it mean you need to manually obtain a new IP address at a certain time point? No. Most DHCP client programs will apply for a new IP address (renew) based on the lease time ).

Generally, assume that the lease term isTThe client will0.5 TBWhen the request fails, the packet requesting network parameters is sent to the DHCP server (directly starting from step 1, the DHCP server will not be broadcast again ).0.85 TBSend the data packet again. Because of this, the server will start the Port67Listen for client requests, and the client starts the Port68Actively send requests to the server.

3-) ConfigurationDHCPServer:

Run the "rpm-q dhcp" command to check whether dhcp software has been installed in the system. If not, install it.

After installation, create a configuration file./Etc/dhcpd. conf(RHEL5). By default, this file does not contain valid configurations and must be manually created by the Administrator. Create a new dhcpd. conf file based on the file template. Note that the dhcp configuration file name in RHEL6.X is/Etc/dhcp/dhcpd. conf(RHEL6) will be introduced later.

3-1)/Etc/dhcpd. confFile structure:

1-)Global settings (affects the entire dhcp server)

Assume that dhcpd only manages one subnet LAN, many network parameters except IP addresses can be placed in the global settings area, this includes the lease term, the IP address of the DNS host, the IP address of the router, and the type of Dynamic DNS (DDNS) updates. When some settings are not defined in the fixed IP address and dynamic IP address, the global settings prevails.

  • Default-lease-timeTime: Default lease time, in seconds, indicates the default lease time of the IP address of the client.

  • Max-lease-timeTime: Maximum lease time, in seconds, indicates the maximum lease time allowed for client requests

  • Option domain-name"Domain name": The default search area, if in/etc/resolv. in conf, a search google.com is set. This indicates that when you are looking for a host name, the DNS system will automatically add the domain name suffix after the host name you are looking.

  • Option domain-name-serversIP1, IP2: Specifies the DNS server address used by the client to resolve the domain name. This configuration option can be used to modify the/etc/resolv of the client. conf file, that is, the dns ip address next to the nameserver. Multiple DNS addresses are separated by commas (,).

  • Ddns-update-styleType: The IP address obtained by the DHCP Client is always changed, so it is difficult to match the Host Name and IP address of a host. In this case, DHCP can use ddns to update the ing between the host name and IP address. It can be set to none.

  • Ignore client-updates: Related to the previous setting value. The client can update DNS-related information through the dhcpd server. However, we will not talk about this here, so we will set it to ignore (ignore ).

  • Option routersRouter address: Set the IP address of the router. Remember to add routersSYes!

2-)Subnet CIDR Block statement

A DHCP server can provide services for multiple CIDR blocks. Therefore, the subnet CIDR Block statement must have multiple CIDR blocks.

What are the parameters in the brackets? That is, whether the IP address is fixed or dynamic.

  • Range IP1 IP2: In this lan, a continuous IP address segment is assigned to the client. IP1 IP2 refers to the IP address range allocated to the client.

  • HostHost Name {... }: This host is the setting value corresponding to the fixed IP address to the MAC address. You can set the host name on your own. You need to specify the MAC address and the fixed IP address in braces. How can we set these two values? Check it out

For more details, refer to the highlights on the next page.: Http://www.linuxidc.com/Linux/2014-11/108899p2.htm

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.