Shows the test environment:
Server ip: 192.168.0.1
Test requirements: the linux dhcp server is required to assign an IP address to the linux client.
Server Software Package: dhcp-3.0.1-12_EL.I386 (which is acceptable for other versions, of course) packages are by default in the fourth installation disc of RHEL4.
Main configuration file: dhcp. conf is not included in the dhcp software package by default, and must be created manually.
Server Configuration:
1. Mount and install the dhcp software package, as shown in:
2. Edit the configuration file (because the software package is not automatically created after the configuration file is installed, you only need to run the following commands to create a blank configuration file.
Vi/etc/dhcpd. conf
For the convenience of future explanations, we will fill in the file content, and I will talk about the specific meaning of the configuration file right away.
Global settings: we usually make the content above subnet 192.168.0.0 netmask 255.255.255.0 (excluding the content in the subnet line) Global. The meaning of each line is as follows:
Ddns-update-style interim;: indicates the dynamic information update mode of the dhcp server and dns server. This line must have a dhcp server before it can be started.
Default-lease-time 21600; Default lease time
Max-lease-time 43200; Max lease time
Option domain-name "123.com"; domain name Server name
Option domaini-servers 192.168.0.1 default Domain Name Service IP Address
Sub starts from "{" and ends with the last. The main configuration is only valid for the content in braces. A configuration file can have multiple subnet attributes.
Sub 192.168.0.0 netmask 255.255.255.0;
The subnet mask for 192.168.0.0 is 255.255.255.0)
Range 192.168.0.2 192.168.0.100; (the assigned IP address ranges from 192.168.0.2
192.168.0.100)
Option subnet-mask 255.255.255.255.0; (the subnet mask assigned to the IP address is 255.255.255.0.
Option routers 192.168.0.3; (the gateway assigned to the client is 192.168.0.3) MASTER: The option router in the figure should be changed to option routers.
Sometimes we need to configure a fixed IP address for a machine, and the following configuration options meet this requirement:
Host server01 {
Hardware ethernet b0: c0: 12: f2: a3: a4;
Fixed-address 192.168.0.100;
}
The specific meaning and simple meaning are "the IP address we configured for the client mac address is b0; c0; 12; f2; a3; a4 is 192.168.0.100 ".
The following figure shows the restart of the dhcp service. When we have just configured the dhcpd. conf file, we need to start the dhcpd service.
After the server is configured, how can the client obtain the IP address. It is actually very simple. Here we call two commands, which have the same effect. The command is dhclint or the interface is down and then up. The figure is as follows:
We have obtained the IP address 192.168.0.99. Different from windows, linux obtains IP addresses from a large range to a small range.
This article is from the "humbly seeking for advice" blog