working principle:
1, client looking for server: Broadcast send Discover packet, look for DHCP server
2, the server responds to the request: the single advertisement sends the offer package, responds to the client. Provides client network-related leases for selection
when the server receives the client's request, it will work on the client's MAC address and its own set data:
A, to the server's login file to find the user's previous used IP, if there is no one to use this IP, which provides this IP for the client
B, if there is an additional fixed IP in the configuration file for the Mac, and the IP is not used, provide this IP to the client
C, if the above two conditions are not met, the IP parameters that are not currently used are randomly taken to the client and logged to the leases file.
3, the client sends IP request: Broadcast request packet, select a server to provide the network parameter lease return server.
In addition, the customer is given the opportunity to send a broadcast packet to all hosts within the LAN, informing them that they have accepted the server's lease.
4. The server confirms the lease: Unicast ACK packet, the server confirms the lease relationship with the client and logs it to the server's leases file.
the client opens port 68th and the server opens port # 67th.
Five steps
1. Fixed IP
2. Rights users
3. Package Confirmation
4. Modify the configuration file
5. Start the server test
Here's how:
1. Use Rpm–qa|grep dhcpd See if you have installed DHCP Service: The system has not yet installed a DHCP server, as the figure indicates.
2. mount and install the DHCP software package as shown in:
3.
DHCP configuration file--/etc/dhcpd.conf
RHEL5 after installation, this file is a blank file by default.
The template for this file is:/usr/share/doc/dhcp-3.0.5/dhcpd.conf. sample
Cp/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample/etc/dhcpd.conf
Cat/etc/dhcpd.conf as shown.
Ddns-update-style Interim; Defines the supported DNS dynamic update types, (required), generally set to off, interim and none are closed (interim or ad-hoc or none)
Ignore client-updates; Ignore client updates and do not allow dynamic DNS updates
Subnet 172.16.210.0 netmask 255.255.255.0 {//Declare a network segment
#---Default gateway
Option routers 172.16.210.254; The gateway address or routing IP address assigned to the client
Option Subnet-mask 255.255.255.0; Subnet mask assigned to the client
Option Nis-domain "domain.org"; Setting up NIS domain names
Option Domain-name "domain.org"; Set the DNS domain name to match the DNS domain name
Option Domain-name-servers 172.16.210.1; IP address of the DNS server
Option time-offset-18000; Set the offset time for the client and GMT
# option Ntp-servers 172.16.210.1; Set the network time server IP address for the client
# option Netbios-name-servers 172.16.210.1; Set the default WINS server
#---Selects point-to-point node (default is hybrid). Don ' t change this nless
#--You understand Netbios very well
# option Netbios-node-type 2;
Range DYNAMIC-BOOTP 172.16.210.210 172.16.210.240; Assignable IP Range
Default-lease-time 21600; Default Lease Time 6 hours
Max-lease-time 43200; Maximum lease time 12 hours
# We want the nameserver to appear at a fixed address
Host NS {//hosts with host name NS set IP assignment to specific NIC
Next-server marvin.redhat.com; #设置由于定义服务器从引导文件中装入的主机名, for diskless stations.
Hardware Ethernet 12:34:56:78:AB:CD; MAC address of the host
Fixed-address 172.16.210.222; The address is always assigned to the host
}
}
3. Start the DHCP server
Start
# service DHCPD Start
Restart
Service DHCPD Restart
Querying the startup status of a service
Service DHCPD Status
Stop Service
Service DHCPD Stop
chkconfig dhcpd on start DHCP service chkconfig dhcpd off stop DHCP service
NOTE: chkconfig * * * on/off start/stop * * * service, only after restarting the computer to take effect.
4. Testing the DHCP server
Start the DHCP service
Set the IP address to auto-get on the physical machine
Open "Run" → enter "cmd"
Release IP address: ipconfig/release
Re-apply IP address: ipconfig/renew
Execution: Ipconfig/all
If you see the IP address, default gateway, and DNS server address assigned to it, the DHCP server is working properly and the configuration is successful
The server configures how the Linux client obtains the IP address. It's actually very simple. Here I call you two orders, the effect is the same. The command is: Dhclint or down the interface and then up the interface can be.
View IP and Client correspondence list
Files under the/usr/lib/dhcpd/directory
Query port number
Netstat-natup|grep DHCPD