DHCP configuration for dhcp server Learning

Source: Internet
Author: User

To learn about the content of a DHCP server, we must be clear about its basic concepts and configurations. Let's take a look at DHCP. DHCP is based on the customer/Server mode. When the DHCP Client is started, it automatically communicates with the DHCP server. The DHCP server provides the DHCP client with a service that automatically allocates IP addresses. Of course, advanced DHCP is not just as simple as allocating addresses. Today, we only set up a normal DHCP server for our courses. The client can obtain the necessary network configuration information for accessing the Internet. A server installed with the DHCP service software is called a DHCP server, while a client with the DHCP function enabled is called a DHCP client. a DHCP server provides services for a DHCP Client by means of address lease, it can be either of the following methods: limited lease term or permanent lease. To learn about a DHCP server, you must know how the DHCP server works:

Dhcp discoverdhcp discovery)

Provided by dhcp offerdhcp)

DHCPREQUESTDHCP request)

DHCPACKDHCP confirmation)

The four steps are necessary for the client to obtain the IP address.

When DHCP is provided, the server has allocated an IP address to the client. The IP address assigned to the client in the second part is temporary. After the client obtains the IP address, it will send a DHCP request to lease the address, after receiving the request, the server will officially allocate the address to the client and then send DHCP confirmation to the client. The four steps mainly deal with Multiple DHCP servers in the same network.

Background process: dhcpd

Script:/etc/rc. d/init. d/dhcpd

Port: 67

Required RPM package: dhcp

Related RPM packages:

 
 
  1. dhcp-devel-3.0.5-7.el5.i386.rpm   
  2. dhcpv6-0.10-33.el5.i386.rpm   
  3. dhcpv6_client-0.10-33.el5.i386.rpm  

Configuration File:/etc/dhcpd. conf

Log:/var/log/xferlog

Let's try again. The network startup method is also called bootpc. The obtained IP address will not be restricted by the server's lease period. It will always work well. We should first install the DHCP server.

1. Download or find the DHCP service installation package from the CD.

Ii. Installation (dhcp * indicates the installation package name ):

 
 
  1. # rpm -ivh dhcp* 

3. Configure the DHCP file:

 
 
  1. Copy/usr/share/doc/dhcp */dhcpd. conf. sample to the/etc directory and change it to dhcpd. conf.
  2. # Cp/usr/share/doc/dhcp */dhcpd. conf. sample/etc/dhcpd. conf
  3. Of course, you can also First vi/etc/dhcpd. conf, and then run the following command in the last line mode:
  4. R/usr/share/doc/dhcp */dhcpd. conf. sample
  5. In this way, the content of the dhcpd. conf. sample file will be imported.
  6. Open dhcpd. conf and modify the following items:
  7. Subnet is followed by the network segment you defined. It must be the same as the IP address of the local machine,
  8. Each statement ends with a semicolon (;). Do not forget it.
  9. For example, if my IP address is "192.168.2.11", the following is my configuration file:
  10. Ddns-update-style interim;
  11. Ignore client-updates;
  12. Subnet 192.168.2.0 netmask 255.255.255.0 {
  13. Option routers 192.168.2.1;
  14. Option subnet-mask limit 255.0;
  15. Option nis-domain "domain.org ";
  16. Option domain-name "domain.org ";
  17. Option domain-name-servers 192.168.2.1;
  18. Option time-offset-18000;
  19. Range dynamic-bootp 192.168.2.100 192.168.2.254
  20. Default-lease-time 21600;
  21. Max-lease-time 43200;
  22. Filename "/pxelinux.0 ";
  23. Next-server 192.168.2.11;
  24. Host ns {
  25. Next-server marvin.redhat.com;
  26. Hardware ethernet 12: 34: 56: 78: AB: CD;
  27. Fixed-address 207.175.42.254;
  28. }
  29. }

Iv. Detailed notes:

 
 
  1. Ddns-update-style interim; # It is required to define the supported DNS dynamic update types.) generally, we set it to disabled,
  2. # Interim and none both mean to disable
  3. Allow/ignore client-updates; # allow/ignore clients to update DNS records
  4. Allow/deny unknown-clients; # Whether to dynamically allocate IP addresses to unknown users
  5. Allow/deny bootp; # whether to respond to the activation Query
  6. Allow/deny booting; # whether to respond to user queries
  7. Subnet 192.168.2.0 netmask 255.255.255.0 {# Set the subnet Declaration
  8. # --- Default gateway
  9. Option routers 192.168.2.1; # Set the default gateway to 192.168.2.1
  10. Option subnet-mask subnet mask 255.255.0; # Set the client subnet mask
  11. Option nis-domain "domain.org"; # Set the NIS domain for the customer
  12. Option domain-name "domain.org"; # Set a domain name for the customer
  13. Option domain-name-servers 192.168.2.1; # Set the domain name Server for the customer
  14. Option time-offset-18000; # Eastern Standard Time # specify the Greenwich Mean time offset Time for the client, in seconds,
  15. # This option can be used in both global and local configurations.
  16. # Option ntp-servers 192.168.2.1; # NTP is a time server
  17. # Option netbios-name-servers 192.168.2.1; set the wins Server
  18. # --- Selects point-to-point node (default is hybrid). Don't change this unless
  19. # -- You understand Netbios very well
  20. # Option netbios-node-type 2; # setting the netbios node type I don't know what this netbios node is.
  21. Range dynamic-bootp 192.168.2.28 192.168.2.254; # Set a dynamic address pool
  22. Default-lease-time 21600; # Set the default address lease period
  23. Max-lease-time 43200; # set the maximum client address lease period
  24. # We want the nameserver to appear at a fixed address
  25. Filename "/pxelinux.0"; # Name of the Startup file, which is applied to diskless installation. It can be the relative or absolute path of tftp.
  26. Next-server 192.168.2.11; # This is the name of the server they shocould get it from
  27. # Tftp server, which can be different from the dhcp server. This parameter is generally used by PXE networks.
  28. # Set host Declaration
  29. Host ns {
  30. Next-server marvin.redhat.com;
  31. Hardware ethernet 12: 34: 56: 78: AB: CD; # specify the mac address of a dhcp Client
  32. Fixed-address 207.175.42.254; # assign an ip address to the specified mac address
  33. }
  34. }

5. After configuring the dhcpd. conf file, you can start the dhcp service:

# Service dhcpd restart

You can run the "netstat-nlutp" command to check whether the dhcp service has been started.

6. Other related documents:

1. This file/var/lib/dhcpd. leases can view the rented IP address and related information.

2. This file/etc/sysconfig/dhcpd is the network card that the DHCP server listens to. If there is only one network card, you do not need to set DHCPDARGS = eth0 or eth1.

3. This file/etc/sysconfig/dhcrelay is the file for configuring DHCP relay. Open it. Interfaces is the dhcp discover request from this port) will be forwarded to the subsequent DHCPSERVERS server. If DHCP relay is set, you need to start the relay service: service dhcrelay start.

7. Under the linux client, you can manually configure your dhcp:

Check your network configuration file. If you are not set to enable the network automatically, modify the network configuration file.

 
 
  1. # Vi/etc/sysconfig/network
  2. Add "NETWORKING = yes" to enable network connection during boot)
  3. Or use
  4. # @ Echo "NETWORKING = yes">/etc/sysconfig/network
  5. Then modify your Nic configuration file.
  6. The/etc/sysconfig/network-scriptes/ifcfg-eth0 file should contain these lines:
  7. DEVICE = eth0
  8. BOOTPROTO = dhcp
  9. ONBOOT = yes

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.