DHCP service installation configuration under Linux

Source: Internet
Author: User
Tags ack domain server dchp

    1. Brief introduction
    2. Installation configuration

Brief introduction

DHCP (Dynamic Host Configuration Protocol) is a UDP-based network protocol that is limited to local area networks, and is primarily used to automatically assign IP addresses to internal LAN devices or network providers. Usually used in large-scale LAN environment or local area network has more mobile office equipment, DHCP protocol can achieve centralized management, assign IP address.

The DHCP service program can automatically and dynamically obtain the IP address, the subnet mask, the gateway address and the DNS server address and so on, and can effectively improve the address utilization, improve the efficiency of the configuration, reduce the management and maintenance costs.

Working principle

  1. The DHCP client sends out DHCP discover messages in a broadcast manner.
  2. The DHCP server responds by sending a DHCP offer message to the DHCP client. DHCP server will have a record of the assigned IP address after this message is issued.
  3. The DHCP client processes the first received DHCP offer message. The DHCP client issues a broadcast DHCP request message that is added to the selected DHCP server's IP address and the required IP address in the Options field.
  4. After the DHCP server receives the DHCP request message, it determines whether the IP address in the Options field is the same as its own address. If not, DHCP server does not do any processing to clear only the corresponding IP address assignment records, and if the same, DHCP server responds to a DHCP ACK message to the DHCP client and adds the use lease information for the IP address in the option field.
  5. After the DHCP client receives the DHCP ACK message, check that the IP address assigned by the DHCP server is available. If it is available, the DHCP client successfully obtains an IP address and automatically initiates the renewal process based on the IP address using the lease; If the DHCP client discovers that the assigned IP address is already in use, the DHCP client sends a DHCP decline message to the DHCPServer , notify DHCP server to disable this IP address, and then DHCP client to start the new address application process.
  6. After the DHCP client obtains the IP address successfully, it can release its IP address at any time by sending the DHCP release message, and the DHCP server will reclaim the corresponding IP address and redistribute it after receiving the DHCP release message.

Client--> DHCP DISCOVER

DHCP offer <--Server

Client--> DCHP REQUEST

DCHP ACK <--Server

client-getting the correct IP address information

client--> DCHP Release (IP of lease expiration release request)

Lease : The time at which the DHCP client is able to use dynamically assigned IP addresses.

Installation configuration

    1. Installation

      # yum Install DHCP

    2. Configuration

      under/etc/dhcp/dhcpd.conf , the default is only comment statements, you need to refer to the template file
      #mv/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example/etc/dhcp/dhcpd.conf (here My DHCP version is 4.2.5, different versions are different)

The standard DHCP configuration file includes global configuration parameters, subnet segment declarations, address configuration options, and address configuration parameters :

Host configures the private address of the specific MAC address master

Global configuration parameters are used to define global parameters for the entire configuration file, while the subnet segment declaration is used to configure the address properties of the entire subnet segment , with the following parameters:

Parameters

Role

Ddns-update-style type

Defines the type of dynamic update for the DNS service, including:
None (dynamic update not supported), interim (interactive update mode) and AD-HOC (Special update mode).

Allow/ignore client-updates

Allow/Ignore clients to update DNS records.

Default-lease-time 21600

The default time-out.

Max-lease-time 43200

The maximum timeout time.

Option Domain-name-servers 8.8.8.8

Defines the DNS server address.

Option Domain-name "Domain.org"

Defines the DNS domain name.

Range

Defines the pool of IP addresses used for allocation.

Option Subnet-mask

Defines the subnet mask for the client.

Option routers

Defines the gateway address of the client.

Broadcase-address Broadcast Address

Defines the broadcast address of the client.

Ntp-server IP Address

Defines the network time server (NTP) for the client.

Nis-servers IP Address

Defines the address of the client's NIS domain server.

Hardware hardware type MAC address

Specifies the type and MAC address of the NIC interface.

Server-name Host Name

Notifies the DHCP client server of the host name.

Fixed-address IP Address

Assigns a fixed IP address to the specified host.

Time-offset Offset Difference

Specifies the offset difference between the client and GMT.

  1. To modify the configuration file as required, I'll experiment with the host configuration (the private address of the host configuration specific MAC address) is modified as follows:

    The client's MAC address is filled in, and the client's IP address is changed to DHCP.

  2. Restart the server DHCPD, restart the client network, and view the client IP:

    You can see that the client gets successful.

  3. Then experiment with the configuration of the subnet segment declaration (configuration parameters as in step 3). The virtual machine settings are adjusted here:

    Both the client and server are set to the same (this option is a virtual machine-specific virtual network that is set up in the same LAN, reducing conflicts).

  4. Restart the server DHCPD, client network, you can see the client IP address as follows:

    Here you can see the success of the acquisition.

    Check the/var/lib/dhcpd/dhcpd.leases~ file on the service side for information such as lease time:

    The general DHCP relay function is less used in daily work, or the router is responsible for the relay function, rarely built with Linux system, here is not much to say.

DHCP service installation configuration under Linux

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.