dhcp服务器架设培训资料_第1页
dhcp服务器架设培训资料_第2页
dhcp服务器架设培训资料_第3页
dhcp服务器架设培训资料_第4页
dhcp服务器架设培训资料_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

- 出自:crazylinux工作室 网址: 时间:2007.12.26转载请保留此信息 - 实验环境:AS4默认安装实验目标:架设DHCP服务器联系方式: 一,DHCP服务器rpm包的配置大家好!这次我们来学习Linux系统中的DHCP服务器的配置。主要目标有两个:1,配置DHCP服务器给客户端计算机分配IP地址,网络地址,DNS和网关地址2,为某台客户机保留IP地址下面我们开始了!首先我们检查是否已经安装了DHCP服务器端的软件rootlocalhost # rpm -qa | grep dhcp 查询DHCP没有安装dhcpv6_client-0.10-8rootlocalhost # mount /media/cdrom/ 挂载AS4第4张盘我们服务器上要安装的是dhcp-3.0.1-12_EL.i386.rpm,那么下面我们来安装。 rootlocalhost # rpm -ivh /media/cdrom/RedHat/RPMS/dhcp-3.0.1-12_EL.i386.rpmDHCP服务器的配置文件为/etc/dhcpd.conf,默认情况下此文件不存在,不过当DHCP软件包安装之后会提供一个配置模板:/usr/share/doc/dhcp-3.0.1/dhcpd.conf.samplerootlocalhost RPMS# rpm -ql dhcp/usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample (模版配置文件)rootlocalhost RPMS# cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample /etc/dhcpd.conf将模板拷贝到/etc/目录下命名为dhcpd.conf,然后在该文件上进行相关的配置即可。到现在为止,我们的准备工作已经OK,下面我们就正式开始架设DHCP服务器实例:目前我的内部网段设定为 /24 这一段,且默认网关为 ,此外,DNS主机的IP为,所分配的网段内的子网掩码是我想要让每个使用者默认租约时间为21600s,最大租约时间为43200s;局域网内所有主机的域名为“” 我只想要分配的 IP 只有 00 到 00 这几个,其它的 IP 则保留下来; 我的主机的 MAC 是 00:0C:29:F7:DB:70 ,我要给主机名称为crazylinux IP 为 0 这个。 以下为修改之后的dhcpd.conf文件的内容:rootlocalhost RPMS# cat /etc/dhcpd.conf ddns-update-style interim;ignore client-updates; #dhcp服务器不要为它分配ip地址更新本地域名的dns记录subnet netmask #申明分配ip的子网范围# - default gateway option routers ; #定义网关 option subnet-mask ; #定义子网掩码 option nis-domain ; #定义nis域名 option domain-name ;#定义dns服务器域名 option domain-name-servers ;#定义dns服务器的ip option time-offset -18000; # Eastern Standard Time# option ntp-servers ;# option netbios-name-servers ;# - Selects point-to-point node (default is hybrid). Dont change this unless# - you understand Netbios very well# option netbios-node-type 2; range dynamic-bootp 00 00; #分配ip地址的范围 default-lease-time 21600;#定义的默认租约时间6小时 max-lease-time 43200;#定义的最大租约时间12小时 # we want the nameserver to appear at a fixed address host crazylinux #定义为客户机绑定ip的主机名 hardware ethernet 00:0C:29:F7:DB:70;#所绑定主机的mac地址 fixed-address 0;#所绑定的ip 完成之后重启服务:service dhcpd restart,若服务启动成功则可以使用一台客户机进行测试。这样一台最简单的DHCP服务器就架设完毕。3,租约文件在DHCP服务器上,/var/lib/dhcp/dhcpd.leases文件中存放着DHCP客户租期数据库。只要DHCP服务器能够成功启动,该数据库就可以自动创建。并且,所有通过该DHCP服务器分配到地址的客户机的地址信息都会存储于该文件中。该租期数据库文件经常被重建,但是不应该手工修改。另外如果主机上安装了两个网卡,但是只想让DHCP服务在其中的一个网卡上监听,则需要配置DHCP服务器只在那个设备上启动。在/etc/sysconfig/dhcpd中,把网卡接口的名称添加到DHCPDARGS列表中。#Command line options here最后在客户端上使用netconfig命令设置客户端自动获取地址,完成后重启服务即可。rootlocalhost RPMS# cat /var/lib/dhcp/dhcpd.leases 在服务器上查看已经分配出去的IP# All times in this file are in UTC (GMT), not your local timezone. This is# not a bug, so please dont ask about it. There is no portable way to# store leases in the local timezone, so please dont request this as a# feature. If this is inconvenient or confusing to you, we sincerely# apologize. Seriously, though - dont ask.# The format of this file is documented in the dhcpd.leases(5) manual page.# This lease file was written by isc-dhcp-V3.0.1lease 00 starts 6 2007/03/17 04:36:31; ends 6 2007/03/17 10:36:31; binding state active; next binding state free; hardware ethernet 00:0c:29:67:57:c1;lease 99 starts 6 2007/03/17 04:37:13; ends 6 2007/03/17 10:37:13; binding state active; next binding state free; hardware ethernet 00:0c:29:ef:cc:aa; uid 001000014)357314252; client-hostname cheshi-eeb7e489;嘿嘿 成功。二,DHCP服务器源码包配置还是和上面的rpm包一样,我们这次用源码包来设置dhcp服务器,在配置之前首先准备工作:软件:gccdhcp-4.0.0.tar.gz1,先安装gccrootlocalhost cdrom# rpm -ivh gcc* -aid2,安装dhcp源码包首先确定系统上没安装rpm包rootlocalhost dhcp-3.0.2# rpm -q dhcppackage dhcp is not installedrootlocalhost pub# tar -zxvf dhcp-4.0.0.tar.gz -C /usr/local/src/ rootlocalhost pub# cd /usr/local/src/dhcp-4.0.0/ rootlocalhost dhcp-4.0.0# ./configurerootlocalhost dhcp-4.0.0# makerootlocalhost dhcp-4.0.0# make installrootlocalhost dhcp-4.0.0# find / -name dhcpd.conf#查找dhcp主配置文件/etc/log.d/conf/services/dhcpd.conf/usr/local/etc/dhcpd.conf/usr/local/src/dhcp-4.0.0/server/dhcpd.conf rootlocalhost dhcp-4.0.0# cp /usr/local/etc/dhcpd.conf /etc/dhcpd.conf3,dhcp服务器的配置rootlocalhost dhcp-4.0.0# cat /etc/dhcpd.conf # dhcpd.conf# Sample configuration file for ISC dhcpd# option definitions common to all supported networks.#option domain-name ;#option domain-name-servers , ;#default-lease-time 600;#max-lease-time 7200;# Use this to enble / disable dynamic dns updates globally.#ddns-update-style none;# If this DHCP server is the official DHCP server for the local# network, the authoritative directive should be uncommented.#authoritative;# Use this to send dhcp log messages to a different log file (you also# have to hack syslog.conf to complete the redirection).log-facility local7;# No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology.#subnet netmask # This is a very basic subnet declaration.#subnet netmask 24 # range 0 0;# option routers , ;# This declaration allows BOOTP clients to get dynamic addresses,# which we dont really recommend.#subnet 2 netmask 24 # range dynamic-bootp 0 0;# option broadcast-address 1;# option routers ;# A slightly different configuration for an internal subnet.subnet netmask range 00 00; option domain-name-servers 53; option domain-name ; option routers 53; option subnet-mask ; option broadcast-address 55; default-lease-time 21600; max-lease-time 43200;# Hosts which require special configuration options can be listed in# host statements. If no address is specified, the address will be# allocated dynamically (if possible), but the host-specific information# will still come from the host declaration.#host passacaglia # hardware ethernet 0:0:c0:5d:bd:95;# filename vmunix.passacaglia;# server-name ;# Fixed IP addresses can also be specified for hosts. These addresses# should not also be listed as being available for dynamic assignment.# Hosts for which fixed IP addresses have been specified can boot using# BOOTP or DHCP. Hosts for which no fixed address is specified can only# be booted with DHCP, unless there is an address range on the subnet# to which a BOOTP client is connected which has the dynamic-bootp flag# set.host crazylinux hardware ethernet 00:0C:29:3B:68:25; fixed-address 50;# You can declare a class of clients and then do address allocation# based on that. The example below shows a case where all clients# in a certain class get addresses on the 10.17.224/24 subnet, and all# other clients get addresses on the 10.0.29/24 subnet.class foo match if substring (option vendor-class-identifier, 0, 4) = SUNW;shared-network 224-29 subnet netmask option routers ; subnet netmask option routers ; pool allow members of foo; range 0 50; pool deny members of foo; range 0 30; 4,服务启动rootlocalhost dhcp-4.0.0# touch /var/db/dhcpd.leasesrootlocalhost dhcp-4.0.0# dhcpd三,RH AS4 dhcp 中继代理如图所示:Eth0:48DHCP Server ClientEth0:48DHCP RelayEth1:451、 如图所示,配置dhcp server ip 地址,eth0:48;网关为:452、 安装dhcp server ,用linux RPM包安装;3、 编辑 /etc/dhcpd.conf 内容如下:ddns-update-styleinterim;ignoreclient-updates;optionsubnet-mask;;;optiontime-offset-18000;#EasternStandardTimedefault-lease-time259200;max-lease-time777600;optiondomain-name-servers8,8;optionbroadcast-address55;#网通DNS服务器地址#下面配置超级作用域shared-neworkmynetsubnetnetmaskoptionrouters45rangedynamic-bootp00;subnetnetmask optionrouters48;rangedynamic-bootp00;4、 编辑/etc/sysconfig/dhcpd ,DHCPDARGS=eth05、 启动dhcp 服务,关闭防火墙。6、 配置,dhcp relay ip 如下:eth0:48,网关可不设;eth1:45 ,网关为:487、 启动ip_forward : echo “1”/proc/sys/net/ipv4/ip_forward(我在rhel4中实验不需要此步骤)或者在/etc/sysctl.conf中查看net.ipv4.ip_forward = 1#sysctl p 立即生效8、 安装dhcp 软件9、 编辑:/etc/sysconfig/dhcrelay INTERFACES=”eth0 eth1” DHCPSERVERS=”48”10, 启动dhcrelay:service dhcrelay start, 关闭防火墙11, 用XP做 client 去自动获取ip12, 查看 dhcp server 租期数据库:/var/lib/dhcp/dhcp.leases,可以看到已经租出的ip信息13, 在XP可以获取到ip。四,使用ether-wake实现远程自动开机1, 首先在客户机bios中设置网络唤醒功能2, 连网3, 记录客户机的MAC地址,关机在dhcp主机中下载ether-wake.c开始编译:#gcc -0 Wall o ether-wake ether-wake.c#./ether-wake 11:22:33:44:55:66 (唤醒主机)#./ether-wake u (查看帮助)五,DHCP原理两台连接到互联网上的电脑相互之间通信,必须有各自的IP地址,但由于现在的IP地址资源有限,宽带接入运营商不能做到给每个报装宽带的用户都能分配一个固定的IP地址(所谓固定IP就是即使在你不上网的时候,别人也不能用这个IP地址,这个资源一直被你所独占),所以要采用DHCP方式对上网的用户进行临时的地址分配。也就是你的电脑连上网,DHCP服务器才从地址池里临时分配一个IP地址给你,每次上网分配的IP地址可能会不一样,这跟当时IP地址资源有关。当你下线的时候,DHCP服务器可能就会把这个地址分配给之后上线的其他电脑。这样就可以有效节约IP地址,既保证了你的通信,又提高IP地址的使用率。 要申请固定IP上网,资费高很多的,所以对于普通客户,一般都是通过DHCP动态分配地址的。如果你不是商业用户,基本上是必须装DHCP才能上网的。DHCP(Dynamic Host Configure Protocol), 是被广泛应用于TCP/IP协议的网络中的动态主机配置协议,使用dhcp协议,有很多简单、易用的优点,主要表现在:网络管理员可以验证IP地址和其它配置参数,而不用去检查每个主机;DHCP不会同时租借相同的IP地址给两台主机;DHCP管理员可以约束特定的计算机使用特定的IP地址;可以为每个DHCP作用域设置很多选项;客户机在不同子网间移动时不需要重新设置IP地址。 dhcp协议的工作流程 1、DHCP客户机寻找DHCP服务器的阶段,可以称为发现阶段:DHCP客户机以广播方式(因为DHCP服务器的IP地址对于客户机来说是未知的)发送DHCP discover发现信息来寻找DHCP服务器,即向地址55发送特定的广播信息。网络上每一台安装了TCP/IP协议的主机都会接收到这种广播信息,但只有DHCP服务器才会做出响应。 udp 68 udp 672、DHCP服务器提供IP地址的

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论