Server tutorial of kangfire website construction Institute (bkjia.com)In Linux, the configuration of DHCP servers is described. The first step for configuring DHCP services in Linux is to install the DHCP service. First, you need to know which. rpm packages are required for the DHCP service.
1. Install the dhcp Software Package
# Rpm-ivh dhcp-3.0.1-12_EL.i386.rpm
2. configuration file dhcpd. conf
Because dhcpd. conf is not included in the software package by default
# Cp/usr/share/doc/dhcp-3.0.2/dhcpd. conf. sample/etc/dhcpd. conf
3. Edit dhcpd. conf.
# Vi/etc/dhcpd. conf
Basic configuration file format
Subnet 192.168.1.0 netmask 255.255.255.0 {range 192.168.1.100 192.168.1.200}
(Declared that the network address is 192.168.1.0 and the subnet mask is 255.255.255.0. The IP address ranges from 192.168.1.100 ~ IP addresses between 192.168.1.200 are used for Dynamic Address Allocation by DHCP clients)
The dhcpd. conf configuration file can contain three basic formats: Declaration, parameter, and option.
Subnet is a common declaration. The setting in the Declaration (Content in braces) is valid throughout the Declaration scope;
Set the Subnet network address after the Subnet keyword,
Set the subnet mask next to The netmask keyword
A parameter consists of a set item and set value. Based on the parameter location, the parameter location can be applied to the global or specified declaration. The parameter ends with ";", for example:
Default-lease-time 21600; (Default release time)
Max-lease-time 43200; (maximum release time)
The option is always guided by the option keyword, followed by the specific options and the set value of the option. The option can be applied to the global or a declaration according to the position, and the option is also "; "ended, for example:
Option routers 192.168.1.1 (GATEWAY)
Opyion subnet-mask 255.255.255.0 (subnet mask)
Use host declaration to set host properties
Host server01 {
Hardware Ethernet 0: c0: c3: 22: 46: 81;
Fixed-address 192.168.1.11;
Option subnet-mask limit 255.0
Option routers 192.168.1.1;
}
In the preceding configuration instance, host declares the host named server01. Its MAC address is 0: c0: c3: 22: 46: 81, and the IP address used for host allocation is 192.168.1.11, the subnet mask for the host is 255.255.255.0 and the gateway address is 192.168.1.1.
Files to be configured for multiple network interfaces
# Vi/etc/sysconfig/dhcpd
DHCPDARGS = eth0
Indicates that dhcp is only available on the eth0 network interface.
4. Start and Stop the dhcpd Service
The STARTUP script of the Dhcpd service is located in/etc/init. d/dhcpd
StartDhcpd Service
# Service dhcpd start
StopDhcpd Service
# Service dhcpd stop
ModifyStartup status
# Chkconfig-level 35 dhcpd on
Server Configuration
1. netconfig // Configure the server IP Address
Service ntework restart
2. mount/dev/cdrom // install software required for dhcp
Rpm-ivh dhcp-3 .........
Rpm-ivh dhcp-d .........
Umount/dev/cdrom
3. vi/etc/dhcpd. conf // configure the dhcp server configuration file (the default file does not exist and must be created manually)
Cp/usr/share/dhcp-3.0.1/dhcpd. conf. sample/etc/dhcpd. conf
Vi/etc/dhcpd. confy
4. service dhcpd restart // start dhcp service
Service dhcpd status
Client Configuration
Windows: ipconfig/release // release IP
Ipconfig/renew // obtain the IP address again
Ipconfig // view the IP address
Linux: netconfig // set the IP address to be dynamically obtained
Service network restart
Server Information view
Tail/var/lib/dhcp/dhcpd. leases // view the lease File Content
DHCP Client Configuration
1. Network Interface Configuration File
# Cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0// Specify the network interface Name
ONBOOOT = yes// Set the network interface to take effect at startup
BOOTPROTO = dhcp// Configure the network interface
2. Restart the network interface
# Ifdown eth0; ifup eth0
Determining IP informationFor eth0... done