【实验拓扑】
【基本配置】
R5充当DHCP 服务器
ip dhcp pool VLAN146
network 155.1.146.0 /24
default-router 155.1.146.4
dns 202.106.46.151
exit
!
ip dhcp excluded-address 155.1.146.4 //排除地址
如果是一个核心交换机配置DHCP,存在多个网段怎么办呢?
首选我们会在交换机上配置多个VLAN,然后给VLAN设置地址,把相应接口放入VLAN,然后再针对不同的VLAN设置不同的 pool,例如我们再增加1个Pool
ip dhcp pool VLAN10
network 192.168.10.0 /24
default-router 192.168.10.254
dns 202.106.46.151
exit
ip dhcp excluded-address 192.168.10.1 192.168.10.254 //排除地址
【DHCP中继,DHCP服务器在其他网段】
按照上图,如果R1与R6想通过R5自动获得IP地址,需要在R4上进行如下配置
R4:
interface Ethernet 0/0
ip add 155.1.146.4 255.255.255.0
ip helper-address 155.1.0.5
【IP与MAC地址绑定配置】
如何配置R6获得的IP地址就为155.1.146.6 呢?
R5:
ip dhcp pool R6
host 155.1.146.6 255.255.255.0
client-identifier 0063.6973.636f.2d63.3030.332e.3035.6334.2e30.3030.302d.4661.302f.30
注意:以上的client-id 是路由器的,如何获取R6的client-id呢?首先上R6自动获得IP地址,然后再R5上使用如下命令,其中infinite 代表无限期,Manual代表手工设置了绑定
R5#show ip dhcp binding
Bindings from all pools not associated with VRF:
IP address Client-ID/ Lease expiration Type
Hardware address/
User name
155.1.146.1 0063.6973.636f.2d63. Mar 02 2002 12:10 AM Automatic
3030.312e.3063.3738.
2e30.3030.302d.4661.
302f.30
155.1.146.6 0063.6973.636f.2d63.
Infinite
Manual
3030.332e.3035.6334.
2e30.3030.302d.4661.
302f.30
在实际网络环境中我们是用的MAC地址,如下图所示
CS4507R#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.8.62 0100.1558.db39 Apr 11 2012 02:58 PM Automatic
192.168.10.33 01c8.bcc8.3c05 Apr 12 2012 02:54 AM Automatic
192.168.10.35 40a6.d992.c97a
Infinite
Manual
192.168.10.105 0114.8fc6.dc0e Apr 11 2012 10:26 PM Automatic
本文转自zcm8483 51CTO博客,原文链接:http://blog.51cto.com/haolun/993086