ITEducation&TrainingDate:24January2020Linux系统管理•第7章DHCP服务器配置ITEducation&TrainingDate:24January2020DHCP服务器•DHCP简介•DHCP软件安装•DHCP配置ITEducation&TrainingDate:24January2020DHCP简介•DHCP:动态主机配置协议,动态分配IP地址。•作用:简化大规模网络环境下为每台机器设置IP的工作,IP自动分配。ITEducation&TrainingDate:24January2020DHCP的C/S结构•DHCP被设计成为客户端/服务器模式,DHCP服务器负责为DHCP客户端自动分配IP地址。•DHCP服务器收到DHCP客户端向网络发送的IP地址请求后,会为客户端分配包括IP地址、子网掩码、默认网关及DNS服务器的IP地址等。ITEducation&TrainingDate:24January2020DHCP工作过程客户端首次接入我是新来的,谁有IP?我有IP(Linuxserver)我也有IP(其他Linuxserver)我还有IP(其他server)我要的一个IP确认(Linuxserver)ITEducation&TrainingDate:24January2020DHCP软件安装dhcp-3.0pl1-23.i386.rpm服务器端第二张盘dhclient-3.0pl1-23.i386.rpm客户端第一张盘dhcp-devel-3.0pl1-23.i386.rpm开发包第二张盘注意安装顺序!ITEducation&TrainingDate:24January2020DHCP软件安装•rpm–qdhcpd查询是否安装了dhcp•rpm–ivhdhcp-3.0pl1-23.i386.rpm•rpm–ivhdhclient-3.0pl1-23.i386.rpmITEducation&TrainingDate:24January2020DHCP服务器配置(案例)•情景要求:要为某局域网配置dhcp服务器,为192.168.0.0/24网段的用户提供IP动态分配服务。IP范围在192.168.0.60~192.168.0.240,默认网关192.168.0.1,该网段其他地址保留为静态分配•另外,物理地址00:0C:09:04:ED:35设置静态IP192.168.0.101ITEducation&TrainingDate:24January2020DHCP服务器配置(案例)1.设置/etc/dhcpd.conf文件cp/usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample/etc/dhcpd.conf2.编辑/etc/dhcp.conf文件(vi)ITEducation&TrainingDate:24January2020subnet192.168.0.0netmask255.255.255.0{range192.168.0.60192.168.0.240;optionrouters192.168.0.1;}子网子网掩码地址范围,可以有多个网关ITEducation&TrainingDate:24January2020•group{•optionrouters192.168.0.1;•hoststaticiphost1{•hardwareethernet00:0C:09:04:ED:35;•fixed-address192.168.0.101;•}•}•按Esc按:按wq退出vi.某个机器特殊设置,可以有多个个别机器特殊设置,在group中ITEducation&TrainingDate:24January2020步骤总结•1.设置自动分配IP的子网网段和网关•2.设置个别主机的例外情况,如物理网卡地址固定设置固定IPITEducation&TrainingDate:24January2020步骤总结•3.DHCP启动servicedhcpdstart•4.DHCP测试客户端Linux在netcofig当中选择其IP为自动获取,使用ifconfig查看ITEducation&TrainingDate:24January2020DNS与DHCP服务器配置引导项目达成—DHCP•root为某局域网配置DHCP服务器:为192.168.167.0/24网段的用户提供IP动态分配服务。IP范围在192.168.167.20~192.168.167.100,默认网关192.168.167.2并且192.168.167.120~192.168.167.220,默认网关192.168.167.2,该网段其他地址保留为静态分配ITEducation&TrainingDate:24January2020DNS与DHCP服务器配置引导项目达成—DHCP#rpm–ivhdhcp-3.0pl1-23.i386.rpm//安装dhcp#rpm–ivhdhclient-3.0pl1-23.i386.rpm#cp/usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample/etc/dhcpd.conf#vi/etc/dhcp.confsubnet192.168.167.0netmask255.255.255.0{range192.168.167.20192.168.167.100;optionrouters192.168.167.2;}subnet192.168.167.0netmask255.255.255.0{range192.168.167.120192.168.167.220optionrouters192.168.167.2;}ITEducation&TrainingDate:24January2020DNS与DHCP服务器配置引导项目达成—DHCP测试:客户端Linux在netcofig当中选择其IP为自动获取,使用ifconfig查看Thankyou谢谢