DHCP server configuration in Linux (2)

Source: Internet
Author: User

A. Introduction
 
A.1, DHCP
 
DHCP: The Dynamic Host Configuration Protocol is a LAN network protocol that uses UDP for two purposes: an IP address is automatically assigned to an internal network or network service provider to the user as a central management means for all computers.
 
A.2. ddns
 
Ddns (Dynamic Domain Name Server) is the abbreviation of dynamic Domain Name Service! Ddns maps users' Dynamic IP addresses to a fixed domain name resolution service, each time a user connects to the network, the client program transmits the dynamic IP address of the host to the server program on the host of the service provider, the server program is responsible for providing DNS services and implementing dynamic domain name resolution. That is to say, ddns captures the IP address that the user changes each time and maps it to the domain name so that other online users can communicate through the domain name.
 
 
B. installation and configuration
 
B .1 install DHCP
 
Yum-y install DHCP
 
B .2. Configure DHCP
 
The DHCP configuration file is/etc/DHCPD. conf, but this file has no content by default. You can copy one from the DHCP installation directory to/etc.
 
CP/usr/share/doc/dhcp-3.0.5/DHCPD. conf. Sample/etc/DHCPD. conf
 
VI/etc/DHCPD. conf
 
B .2.1 Configure/etc/DHCPD. conf
 
Ddns-Update-style none;
 
# Do not update ddns settings
 
Ignore client-updates;
 
 
 
Subnet 192.168.0.0 netmask 255.255.255.0 {
 
Option routers 192.168.0.1;
 
# --- Default Gateway
 
# Gateway
 
Option subnet-mask limit 255.0;
 
# Subnet Mask
 
Option Nis-domain "domain.org ";
 
Option domain-name "domain.org ";
 
# Domain Name
 
Option domain-name-servers 202.96.209.20., 116.228.111.18;
 
# Domain Name Server address
 
Option time-offset-18000;
 
# Eastern Standard Time
 
# Standard Eastern Time
 
# Option NTP-servers 192.168.1.1;
 
# Option NetBIOS-name-servers 192.168.1.1;
 
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- You understand NetBIOS very well
 
# Select a point-to-point node (mixed by default ). Do not change it unless you are very familiar with NetBIOS.
 
# Option NetBIOS-node-type 2;
 
 
 
Range dynamic-BOOTP 192.168.0.128 192.168.0.254;
 
# Provided IP Address
 
Default-lease-time 21600;
 
# Default lease period
 
Max-lease-time 43200;
 
# Maximum lease period
 
 
 
# We want the nameserver to appear at a fixed address
 
# The following content reserves IP addresses for specific machines
 
Host NS {
 
Next-server marvin.redhat.com;
 
Hardware Ethernet 12: 34: 56: 78: AB: CD;
 
Fixed-address 207.175.42.254;
 
}
 
}
 
B .2.2. Configure/etc/sysconfig/DHCPD.
 
# Command line options here
 
Dhcpdargs = eth0
 
B .3. Start DHCP
 
Service DHCPD start
 
# Start The Dhcp Service
 
Chkconfig DHCPD on
 
# Enable the DHCP service along with the System

This article from the Linux community website (www.linuxidc.com) original link: http://www.linuxidc.com/Linux/2012-01/51399.htm

 

 

 

**************************************** **************************************** **************************************** **************************************** ********

**************************************** **************************************** **************************************** **************************************** ********

1. Modify the network parameters in the configuration file to change the IP address to a static IP address. [Root @ localhost ~] # Vi/etc/sysconfig/network-scripts/ifcfg-eth0DEVICE = eth0onboot = yesbootproto = static ..... when "DHCP" is used, the IP address ipaddr = static IP address of the specified DCHP server metmask = subnet mask of the specified DCHP Server Gateway = gateway of the specified DCHP server is automatically obtained through DHCP and then restarted. network Service Program, make the new Nic Configuration File Effective [root @ localhost ~] # Service network restart2. install the DHCP server software first use the RPM command to check whether the system has installed the DHCP software package, if not installed, you can directly mount the rhel5 system CD, and then install the dhcp-3.0.5-3.el5.i386.rpm software package. [Root @ localhost ~] # Rpm-q dhcp [root @ localhost ~] # Mount/dev/CDROM/Media/CDROM [root @ localhost ~] # Rpm-IVH/Media/CDROM/Server/dhcp-3.0.5-3.el5.i683.rpm after installing the play DHCP software package, the relevant configuration files will be created in the system, execute scripts, service scripts, help documentation and so on. The software also installs the programs and script files required by the DHCP relay service. [Root @ localhost ~] # Rpm-ql dhcp/etc/DHCPD. conf ........ the master configuration file/etc/rc of the DHCP server. d/init. d/DHCPD ........ dhcp Service Startup Script/etc/rc. d/init. d/dhcrelay ........ DHCP relay STARTUP script/etc/sysconfig/DHCPD ........ DHCP command parameter configuration file/etc/sysconfig/dhcrelay ........ DHCP relay service configuration file/usr/sbin/DHCPD ........ DHCP server execution Program/usr/sbin/dhcrelay ........ DHCP relay server execution Program/var/lib/DHCPD. leases ........ DHCP server lease file 3. main configuration file DHCPD. the main configuration file location of the confdhcpd service "/etc/DHCPD. conf ", but the file is It does not contain any valid configurations and must be manually created by the Administrator. You can copy the configuration in the template to the main configuration file "/etc/DHCPD. conf. [Root @ localhost ~] # Copy/usr/share/doc/dhcp-3.0.5/DHCPD. conf. Sample/etc/DHCP. confcp: overwrite "/etc/DHCPD. conf "? Y [root @ localhost ~] # Description of content in the main configuration file: Declaration: Subnet is DHCPD. the most common declaration in the conf file is used to dynamically allocate addresses and related network segment attributes in a subnet. The subnet declaration can include other parameters and options. Sunbet 192.168.4.0 netmask 255.255.255.0 {range 192.168.4.128 192.168.4.small; Option subnet-mask 255.255.255.0; Option router 192.168.4.1; Option domain-name Baidu.com; Option domain-name-servers 202.106.0.20 ;} host declaration is used to set the Network Properties of a single host. It is usually used to assign a fixed IP address (Reserved IP address) to a network printer or individual servers ). Use the "host" keyword to specify the name of the DHCP client that needs to be assigned a reserved address, and use the "Hardware Ethernet" parameter to specify the MAC address that matches the host, use the fixed-address parameter to specify the corresponding reserved IP address. Host prinetserver {hardware Ethernet 00: C0: C3: 22: 56: 88; fixed-address 192.168.4.11;} parameter: rang parameter is used for dynamically assigned IP address ranges, there can be multiple rang parameter lines, but the set IP address range must correspond to the ddns-Update-style and Dynamic DNS update modes in the subnet set in the subnet declaration. This parameter is used to set the dynamic update mode of DNS data associated with the DCHP service. It is rarely used. This value is usually okdefault-lease-time by default, and the default lease time. The Unit is seconds, indicating that the client can lease an IP address from the DHCP server. The default time is Max-lease-time and the maximum lease time. The Unit is seconds, indicating the maximum lease time allowed for DHCP client requests. When the client does not request a clear lease time, the server uses the default lease time. Option: Guided by "option, the option router option, followed by the specific configuration keyword and corresponding value, specifies the address of the default gateway allocated to the client. The option subnet-mask option specifies the subnet mask address option domain-name assigned to the client, the default search area specifies the default search domain when the host name is resolved for the client. This configuration option will be reflected in the "/etc/resolv. in the conf configuration file, option domain-name-servers is used to specify the DNS server address used for domain name resolution for the client, this configuration option agrees to be reflected in the "/etc/resolv. conf "configuration file. If multiple DNS server addresses are set, separate them with commas. 4. by default, the DHCP server opens services for multiple available network interfaces at the same time. If you need to provide services on one of the network interfaces, you can modify the "/etc/sysconfig/DHCPD" file and use "dhcpdargs =" to configure the line to specify command parameters. [Root @ localhost ~] # Cat/etc/sysconfig/dhcpddhcpdargs = "eth0 eth1" 5. before starting the DHCPD service, make sure that the network interface of the DHCP server provided has a static IP address, at least one IP address of the network interface corresponds to one subnet network segment in the DHCP server. Otherwise, the DHCPD service cannot be started normally. The STARTUP script of the DHCPD service is located in "/etc/init. d/DHCPD". You can call this script to start, stop, and restart the DHCPD service. [Root @ localhost ~] # Service DHCPD start [root @ localhost ~] # Service DHCPD stop [root @ localhost ~] # Service DHCPD restart [root @ localhost ~] # Netstat-anptu | grep DHCPD if the service fails to be started, check the day records at the end of the "/var/log/messages" file and troubleshoot the error as prompted. After the DHCPD service is successfully started, you can view the lease file "/var/lib/DHCPD. leases" to learn about the IP Address Allocation of the server. The lease file records the information of each assigned IP address, including the IP address, client MAC address, lease start time, and end time. [Root @ localhost ~] # Tail-7/var/lib/DHCPD. Leases

 

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.