DHCP服务器安装及配置案例
2013-08-17 20:27
344 查看
1.DHCP协议 动态主机配置协议(Dynamic Host Configuration Protocol)是用来给主机分配TCP/IP信息的网络协议。 DHCP 客户连接到 DHCP 服务器,该服务器会返回包括 IP 地址、子网掩码、网关和 DNS 服务器信息的客户网络配置。2.DHCP的作用动态管理ip地址等参数 包括ip地址 子网掩码 和dns指向3.DHCP的工作模式 A.manual (手动获取) 管理员手动绑定mac和ip地址,当客户端连接上DHCP服务器是,DHCP服务器根据客户端的mac地址分给其相应的ip地址。 特点:能够动态分配 但管理员工作量大 地址利用率低 B.automatic(自动获取) DHCP服务器中一个地址池 ,地址池中有起始地址和结束地址。当客户端获取ip地址之后 ,服务器有一个mac---》ip 的记录 ,这个记录是一个永久关系 ,其他客户端是无法获得这个地址的。 特点:能够动态分配 管理员工作量低 但地址利用率低(地址无法回收再利用) C.dynamic(动态获取) DHCP服务器中一个地址池 ,地址池中有起始地址和结束地址。当客户端获取ip地址之后 ,服务器有一个mac---》ip 的记录 ,这个记录是有租期,租期到期的话地址会被回收。特点:能够动态分配 管理员工作量低 地址利用率高4.DHCP的租约过程DHCP租约过程分为4步:①客户机请求IP(客户机发DHCPDISCOVER广播包);当一个客户机接入网络会将自己的ip地址配置成0.0.0.0,但该地址无法正常通讯,所以该客户机通过dhcp服务器申请获取一个合法地址.但客户端不知道dhcp服务器的地址,故而发送一个DHCPDISCOVER广播包,广播包内包括客户机的MAC地址和机器名②服务器响应(服务器发DHCPOFFER广播包); Dhcp服务器收到DHCPDISCOVER广播包后,会从自己的地址池中找查找是否有一个合法的地址提供给客户机,有的话就会广播一条DHCPOFFER广播包③客户机选择IP(客户机发DHCPREQUEST广播包);DHCP客户机从接收到的第一个DHCPOFFER消息中选择IP地址,发出IP地址的DHCP服务器将该地址保留,这样该地址就不能提供给另一个DHCP客户机。其他的dhcp服务器则收回自己的地址。④服务器确定租约(服务器发DHCPACK/DHCPNAK广播包)。DHCP服务器接收到DHCPREQUEST消息后,以DHCPACK消息的形式向客户机广播成功的确认,该消息包含有IP地址的有效租约和其他可能配置的信息5.IP地址租约和更新A.租约:① 由管理员设置的IP地址的租约时间如果客户端在租约时间到期前没有更新租约,则DHCP服务器会收回给客户端的IP地址,并将该IP地址提供给其它客户端使用② 被DHCP服务器收回IP地址的客户端,如果还需要IP地址,则必须重新向DHCP服务器申请IP地址③ 永久租约客户端从DHCP服务器获得IP地址后,该IP地址就永久分配给该客户端固定使用。(只有有足够IP地址的情况下才使用永久租约给客户端分配IP地址)B:更新①IP地址租约过50%时时,就必须更新该租期客户端以单播形式发送DHCP Request给DHCP服务器,询问是否可以继续使用客户端所配置的IP地址DHCP服务器以单播形式发送DHCP Acknowledge给客户端,表示同意客户端的请求,客户端获得新的管理员设置的租期②重新捆绑IP地址租约过87.5%时,客户端如果在前一次请求中没能更新租期,再次启动更新租约请求过程,如果成功就IP地址租期更新;如果失败则等到IP地址失效时启动重新申请过程。案例一:配置单作用域dhcp服务器 实验环境:linux READHAT 5.4 服务器端 Windows 客户端实验拓扑:
![](http://img1.51cto.com/attachment/201308/200447642.png)
实验步骤:①DHCP软件包安装挂载光盘镜像:[root@localhost ~]# mount /dev/cdrom /mnt/cdrom安装dhcp软件包:[root@localhost ~]# cd /mnt/cdrom/Server/[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm
![](http://img1.51cto.com/attachment/201308/195701487.png)
查看安装后的文件[root@localhost Server]# rpm -ql dhcp-3.0.5-21.el5
![](http://img1.51cto.com/attachment/201308/195714582.png)
②配置配置文件
![](http://img1.51cto.com/attachment/201308/195738323.png)
![](http://img1.51cto.com/attachment/201308/195740285.png)
③重新启动dhcp服务[root@localhost ~]# service dhcpd restart
![](http://img1.51cto.com/attachment/201308/195755170.png)
④验证阶段
![](http://img1.51cto.com/attachment/201308/195807914.png)
案例二:超级作用域: 超级作用域是 DHCP 服务中的一种管理功能,您可以通过 DHCP 控制台创建和管理超级作用域。使用超级作用域,可以将多个作用域组合为单个管理实体实验拓扑:
![](http://img1.51cto.com/attachment/201308/200722226.png)
实验步骤:①DHCP软件包安装挂载光盘镜像:[root@localhost ~]# mount /dev/cdrom /mnt/cdrom安装dhcp软件包:[root@localhost ~]# cd /mnt/cdrom/Server/[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm
![](http://img1.51cto.com/attachment/201308/195819414.png)
查看安装后的文件[root@localhost Server]# rpm -ql dhcp-3.0.5-21.el5
![](http://img1.51cto.com/attachment/201308/195831694.png)
②配置配置文件
![](http://img1.51cto.com/attachment/201308/195842482.png)
编辑配置文件格式如下:shared-network name {作用域一{} 作用域二{} }[root@localhost ~]# vim /etc/dhcpd.conf
![](http://img1.51cto.com/attachment/201308/195854382.png)
重新启动dhcp服务器[root@localhost ~]# service dhcpd restart
![](http://img1.51cto.com/attachment/201308/195904317.png)
验证:
![](http://img1.51cto.com/attachment/201308/195943538.png)
案例三:Dhcp中继: 如果DHCP客户机与DHCP服务器在同一个物理网段,则客户机可以正确地获得动态分配的ip地址。如果不在同一个物理网段,则需要DHCP Relay Agent(中继代理)。用DHCP Relay代理可以去掉在每个物理的网段都要有DHCP服务器的必要,它可以传递消息到不在同一个物理子网的DHCP服务器,也可以将服务器的消息传回给不在同一个物理子网的DHCP客户机实验拓扑:
![](http://img1.51cto.com/attachment/201308/201850265.png)
实验器材:h3c防火墙 ,华为s2000交换机,READHAT 5.4
DHCP服务器端配置:
实验步骤:①DHCP软件包安装挂载光盘镜像:[root@localhost ~]# mount /dev/cdrom /mnt/cdrom安装dhcp软件包:[root@localhost ~]# cd /mnt/cdrom/Server/[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm 查看安装后的文件[root@localhost Server]# rpm -ql dhcp-3.0.5-21.el5 ②配置配置文件编辑配置文件[root@localhost ~]# vim /etc/dhcpd.conf
![](http://img1.51cto.com/attachment/201308/200003487.png)
物理设备配置命令如图:防火墙[r1]dis cu# sysname r1# firewall packet-filter enable firewall packet-filter default permit# undo insulate# firewall statistic system enable#radius scheme system server-type extended#domain system#local-user admin password cipher .]@USE=B,53Q=^Q`MAF4<1!! service-type telnet terminal level 3 service-type ftp#interface Aux0 async mode flow#interface Ethernet0/0 ip address 192.168.0.1 255.255.255.0 dhcp select relay # interface Ethernet0/0.10 ip address 192.168.10.1 255.255.255.0 ip relay address 192.168.30.2 dhcp select relay vlan-type dot1q vid 10 # interface Ethernet0/0.20 ip address 192.168.20.1 255.255.255.0 ip relay address 192.168.30.2 dhcp select relay vlan-type dot1q vid 20 # interface Ethernet0/0.30 ip address 192.168.30.1 255.255.255.0 dhcp select relay vlan-type dot1q vid 30 # firewall zone local set priority 100 # firewall zone trust add interface Ethernet0/0 add interface Ethernet0/0.10 add interface Ethernet0/0.20 add interface Ethernet0/0.30 set priority 85 # firewall zone untrust set priority 5 # firewall zone DMZ set priority 50 # firewall interzone local trust # firewall interzone local untrust # user-interface con 0 user-interface aux 0 user-interface vty 0 4 authentication-mode scheme # return 交换机:<SW1>dis cu# sysname SW1#radius scheme system#domain system#vlan 1#vlan 10#vlan 20#vlan 30#interface Aux1/0/0# interface Ethernet1/0/10 port access vlan 10 # interface Ethernet1/0/20 port access vlan 20 # interface Ethernet1/0/23 port access vlan 30 # interface Ethernet1/0/24 port link-type trunk port trunk permit vlan all # interface NULL0 # user-interface aux 0 user-interface vty 0 4 # return 验证:
![](http://img1.51cto.com/attachment/201308/200045135.png)
![](http://img1.51cto.com/attachment/201308/200047246.png)
本文出自 “linux的学习笔记” 博客,谢绝转载!
![](http://img1.51cto.com/attachment/201308/200447642.png)
实验步骤:①DHCP软件包安装挂载光盘镜像:[root@localhost ~]# mount /dev/cdrom /mnt/cdrom安装dhcp软件包:[root@localhost ~]# cd /mnt/cdrom/Server/[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm
![](http://img1.51cto.com/attachment/201308/195701487.png)
查看安装后的文件[root@localhost Server]# rpm -ql dhcp-3.0.5-21.el5
![](http://img1.51cto.com/attachment/201308/195714582.png)
②配置配置文件
![](http://img1.51cto.com/attachment/201308/195738323.png)
![](http://img1.51cto.com/attachment/201308/195740285.png)
③重新启动dhcp服务[root@localhost ~]# service dhcpd restart
![](http://img1.51cto.com/attachment/201308/195755170.png)
④验证阶段
![](http://img1.51cto.com/attachment/201308/195807914.png)
案例二:超级作用域: 超级作用域是 DHCP 服务中的一种管理功能,您可以通过 DHCP 控制台创建和管理超级作用域。使用超级作用域,可以将多个作用域组合为单个管理实体实验拓扑:
![](http://img1.51cto.com/attachment/201308/200722226.png)
实验步骤:①DHCP软件包安装挂载光盘镜像:[root@localhost ~]# mount /dev/cdrom /mnt/cdrom安装dhcp软件包:[root@localhost ~]# cd /mnt/cdrom/Server/[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm
![](http://img1.51cto.com/attachment/201308/195819414.png)
查看安装后的文件[root@localhost Server]# rpm -ql dhcp-3.0.5-21.el5
![](http://img1.51cto.com/attachment/201308/195831694.png)
②配置配置文件
![](http://img1.51cto.com/attachment/201308/195842482.png)
编辑配置文件格式如下:shared-network name {作用域一{} 作用域二{} }[root@localhost ~]# vim /etc/dhcpd.conf
![](http://img1.51cto.com/attachment/201308/195854382.png)
重新启动dhcp服务器[root@localhost ~]# service dhcpd restart
![](http://img1.51cto.com/attachment/201308/195904317.png)
验证:
![](http://img1.51cto.com/attachment/201308/195943538.png)
案例三:Dhcp中继: 如果DHCP客户机与DHCP服务器在同一个物理网段,则客户机可以正确地获得动态分配的ip地址。如果不在同一个物理网段,则需要DHCP Relay Agent(中继代理)。用DHCP Relay代理可以去掉在每个物理的网段都要有DHCP服务器的必要,它可以传递消息到不在同一个物理子网的DHCP服务器,也可以将服务器的消息传回给不在同一个物理子网的DHCP客户机实验拓扑:
![](http://img1.51cto.com/attachment/201308/201850265.png)
实验器材:h3c防火墙 ,华为s2000交换机,READHAT 5.4
DHCP服务器端配置:
实验步骤:①DHCP软件包安装挂载光盘镜像:[root@localhost ~]# mount /dev/cdrom /mnt/cdrom安装dhcp软件包:[root@localhost ~]# cd /mnt/cdrom/Server/[root@localhost Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm 查看安装后的文件[root@localhost Server]# rpm -ql dhcp-3.0.5-21.el5 ②配置配置文件编辑配置文件[root@localhost ~]# vim /etc/dhcpd.conf
![](http://img1.51cto.com/attachment/201308/200003487.png)
物理设备配置命令如图:防火墙[r1]dis cu# sysname r1# firewall packet-filter enable firewall packet-filter default permit# undo insulate# firewall statistic system enable#radius scheme system server-type extended#domain system#local-user admin password cipher .]@USE=B,53Q=^Q`MAF4<1!! service-type telnet terminal level 3 service-type ftp#interface Aux0 async mode flow#interface Ethernet0/0 ip address 192.168.0.1 255.255.255.0 dhcp select relay # interface Ethernet0/0.10 ip address 192.168.10.1 255.255.255.0 ip relay address 192.168.30.2 dhcp select relay vlan-type dot1q vid 10 # interface Ethernet0/0.20 ip address 192.168.20.1 255.255.255.0 ip relay address 192.168.30.2 dhcp select relay vlan-type dot1q vid 20 # interface Ethernet0/0.30 ip address 192.168.30.1 255.255.255.0 dhcp select relay vlan-type dot1q vid 30 # firewall zone local set priority 100 # firewall zone trust add interface Ethernet0/0 add interface Ethernet0/0.10 add interface Ethernet0/0.20 add interface Ethernet0/0.30 set priority 85 # firewall zone untrust set priority 5 # firewall zone DMZ set priority 50 # firewall interzone local trust # firewall interzone local untrust # user-interface con 0 user-interface aux 0 user-interface vty 0 4 authentication-mode scheme # return 交换机:<SW1>dis cu# sysname SW1#radius scheme system#domain system#vlan 1#vlan 10#vlan 20#vlan 30#interface Aux1/0/0# interface Ethernet1/0/10 port access vlan 10 # interface Ethernet1/0/20 port access vlan 20 # interface Ethernet1/0/23 port access vlan 30 # interface Ethernet1/0/24 port link-type trunk port trunk permit vlan all # interface NULL0 # user-interface aux 0 user-interface vty 0 4 # return 验证:
![](http://img1.51cto.com/attachment/201308/200045135.png)
![](http://img1.51cto.com/attachment/201308/200047246.png)
本文出自 “linux的学习笔记” 博客,谢绝转载!
相关文章推荐
- Windows Server 2008 R2 DHCP服务器安装和配置案例
- linux笔记 第十五天 系统安装详解、DHCP、配置PXE服务器
- DHCP服务器配置案例分析之一
- Linux 安装配置DHCP服务器
- 安装配置dhcp服务器
- 如何在Ubuntu服务器上安装和配置DHCP服务(转载)
- Windows Server 2012 R2 NAP服务器安装与配置03之 NPS服务器DHCP访问控制配置 2014-02-26 22:39:15 标签:nap windows server 20
- 安装配置dhcp服务器
- 计算机网络技术组网实习报告(二)——DHCP服务器的安装和配置
- 域中安装和配置DHCP服务器
- Windows Server 2012 R2 NAP服务器安装与配置04之 NPS应用DHCP相关设置 2014-02-27 21:08:11 标签:nap nap server Windows S
- 构建DHCP服务器及配置DHCP中继的安装过程
- CentOS5.3安装配置dhcp服务器及dhcp中继服务器
- 实战:在单网段环境中配置安装和配置DHCP服务器
- dhcp服务器安装与配置
- 烂泥:centos安装及配置DHCP服务器
- redhat enterprixe 5.0 下DHCP服务器rpm安装配置及其测试
- DHCP服务器安装与配置
- Windows Server 2012 R2 NAP服务器安装与配置04之 NPS应用DHCP相关设置
- Windows Server 2012 R2 NAP服务器安装与配置06之 测试NAP DHCP