首页 > 代码库 > Cisco dhcp 服务器配置
Cisco dhcp 服务器配置
R1 假设为客户端,向远端dhcp服务器请求分配IP,
在GNS3中用路由代替PC作为客户端,需要关闭R1上的路由功能
通过命令 no ip routing 关闭路由功能
R2 假设为dhcp中继代理
R3 假设为dhcp 服务器,通过预先设定的地址池,从地址池中分配IP给客户端
作为服务器,需要关闭路由器的路由功能
通过命令 no ip routing 关闭路由功能
思路:
分别在R2 、R3 的端口配置上IP地址
在 dhcp 服务器上开启dhcp服务:service dhcp,并且创建并配置地址池,最后设置默认路由出口
在dhcp中继代理上,fa0/0 端口上,配置helper-address 指向dhcp服务器端口IP:2.2.2.3
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int fa 0/0
R3(config-if)#ip add 2.2.2.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#exit
R3(config)#service dhcp
R3(config)#ip dhcp pool cisco
R3(dhcp-config)#network 1.1.1.0 255.255.255.0
R3(dhcp-config)#default-router 2.2.2.2
R3(dhcp-config)#exit
R3(config)#no ip routing
R3(config)#do sh ip dhcp pool //查看dhcp 地址池
Pool cisco :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 0 //在未对客户端进行配置时,dhcp服务器还没发地址分配出去
Pending event : none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
1.1.1.1 1.1.1.1 - 1.1.1.254 0
R3(config)#end
R2(config)#int fa 0/0
R2(config-if)#ip add 1.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#int fa 1/0
R2(config-if)#ip add 2.2.2.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#exit
R2(config)#
R2(config)#int fa 0/0
R2(config-if)#ip help
R2(config-if)#ip helper-address 2.2.2.3
R2(config-if)#end
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#no ip routing
R1(config)#int fa 0/0
R1(config-if)#ip add dhcp
R1(config-if)#no sh
*Mar 1 00:10:51.235: %DHCP-6-ADDRESS_ASSIGN: Interface FastEthernet0/0 assigned DHCP address 1.1.1.1, mask 255.255.255.0, hostname R1 //获取到dhcp服务器分配的地址
此时再回到dhcp服务器查看地址池的情况
R3#sh ip dhcp pool
Pool cisco :
Utilization mark (high/low) : 100 / 0
Subnet size (first/next) : 0 / 0
Total addresses : 254
Leased addresses : 1 //已经分配出去一个IP地址
Pending event : none
1 subnet is currently in the pool :
Current index IP address range Leased addresses
1.1.1.2 1.1.1.1 - 1.1.1.254 1
本文出自 “Im a rOOkie” 博客,请务必保留此出处http://imarookie.blog.51cto.com/3123643/1541983