Rpm-q DHCP #查看dhcp是否安装
Yum Install dhcp*-y #安装DHCP (mount the text)
vim/etc/dhcp/dhcpd.conf Opening a configuration file
#
# DHCP Server Configuration file. #DHCP服务配置文件
# see/usr/share/doc/dhcp*/dhcpd.conf.sample# Reference/usr/share/doc/dhcp*/dhcpd.conf.sample file (
#使用命令cp/usr/share/doc/dhcp*/dhcpd.conf.sample/etc/dhcp/dhcpd.conf)
# See ' Mans 5 dhcpd.conf '
Ddns-update-style Interim; #配置DHCP和DNS为互动更新模式
Ignore client-updates; #忽略客户端更新 (protect against DHCP attacks)
#配置DHCP用于单一地址池
Subnet 192.168.100.0 netmask 255.255.255.0 {
Range 192.168.100.10 192.168.100.200; #地址范围
Option Domain-name-servers 202.106.0.20; #DNS为202.106.0.20
option routers 192.168.100.4; #网关
Option broadcast-address 192.168.100.255; #广播地址
Default-lease-time; #默认租期为600s (in seconds)
Max-lease-time 7200; #最大租期为7200s
Hardware Ethernet 08:00:07:26:C0:A5; #硬件MAC地址
Fixed-address 192.168.100.2; #给它定义固定IP地址
}
#第二种方式: In the face of the big environment, each department needs an address pool. such as:
Shared-network School {
Subnet 192.168.2.0 netmask 255.255.255.0 {
Range 192.168.2.10 192.168.2.254;
Option routers 192.168.2.1;
Host pc1{
Hardware Ethernet 08:00:07:26:C0:A5;
Fixed-address 192.168.2.2;}
}
Subnet 192.168.3.0 netmask 255.255.255.0 {
Range 192.168.3.10 192.168.3.254;
Option Routers 192.168.3.1}
}
service dhcpd start #启动服务
Ps-ef | grep dhcpd #ps命令检查dhcpd进程
Cat/var/lib/dhcpd/dhcpd.leases the address released by the query
Service Iptables Stop #关闭防火墙
The following is a large environment that requires multiple DHCP, go trunk
VIM/ETC/SYSCONFIG/DHCPD #指定接口
Dhcpdargs=eth0
vim/etc/sysconfig/dhcrelay# Editing a DHCP Relay server configuration file
# Command Line Options here
Dhcrelayargs= ""
interfaces= "eth0" interface
dhcpservers="192.168.100.4" DHCP server-side address
vim/etc/sysctl.conf# turn on the server's Routing and forwarding function
Net.ipv4.ip_forward = 1
Service dhcrelay restart# start DHCP Relay service
Configuring DHCP basic operations in Linux