利用路由器模拟DHCP服务器
拓扑:
在3台路由器上模拟:cisco 路由器的IOS可以模拟DHCP功能 、DHCP中继代理
说明:
1.在DHCP-SERVER 模拟DHCP服务器实现IP地址的自动分配;2个路由器上运行eigrp路由协议!
2.dhcp为udp的广播,但当dhcp与客户端不在同一网段时,需要help-address把广播以单播方式转发到目的ip或网段上。
必需在中继理由器上配置IP help-address
dhcp客户端的配置过程:
PC ------ DHCPDISCOVER -----> SERVER 广播
PC <----- DHCPOFFER ------ SERVER 广播 (之前ICMP地址池检查ip是否冲突 )
PC ------ DHCPREQUST -----> SERVER 广播
PC <----- DHCPACK ------ SERVER 广播
help-address的说明:
help-address 缺省转发的8个udp服务:time37 , tacacs49 , dns53 , boot/dhcp服务器67 , boot/dhcp客户端68 , tftp69 , netbios名字服务137, netbios数据报服务138 。
除此之外,可以用全局命令 ip forward-protocol udp 端口号 来转发任意端口。
ip help-address 172.16.1.255 用于指定一个网段的ip(服务器网段)
前提是打开接口下的 ip directed-broadcast
配置:
DHCP-SERVER
在上面配置DHCP服务,并运行路由协议使 路由器DHCP-server 与 路由器RELAY间有路由:
DHCP-SERVER#show run
Building configuration...
Current configuration : 983 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname DHCP-SERVER
!
!
ip subnet-zero
!
!
ip dhcp excluded-address 192.168.1.1 192.168.1.10 //不用于动态地址分配的地址
!
ip dhcp pool cisco
network 192.168.1.0 255.255.255.0 //为所有客户机动态分配的地址段
dns-server 210.34.120.3 //为客户机配置DNS服务器
domain-name laoda.qd.com //为客户机配置域后缀
netbios-name-server 192.168.1.1
default-router 192.168.1.1 //为客户机配置默认的网关
lease 10 10 10 //配置地址租用期
!
interface Serial1/1
ip address 10.1.12.1 255.255.255.0
serial restart-delay 0
!
router eigrp 100
network 10.1.12.0 0.0.0.255
network 192.168.1.0
no auto-summary
!
中继路由器RELAY 的配置:
RELAY#show run
Building configuration...
Current configuration : 770 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname RELAY
!
!
ip subnet-zero
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
ip helper-address 10.1.12.1
duplex auto
speed auto
!
interface Serial1/0
ip address 10.1.12.2 255.255.255.0
serial restart-delay 0
!
!
router eigrp 100
network 10.1.12.0 0.0.0.255
network 192.168.1.0
no auto-summary
!
ip classless
ip http server
!
!
line con 0
exec-timeout 0 0
logging synchronous
line aux 0
line vty 0 4
!
end
PC的接口上配置为DHCP自动分配:
PC#show run int fa0/0
Building configuration...
Current configuration : 75 bytes
!
interface FastEthernet0/0
ip address dhcp
duplex auto
speed auto
end
效果:
DHCP-SERVER#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.1.11 0063.6973.636f.2d63. Mar 11 1993 10:25 AM Automatic
6330.322e.3037.6430.
2e30.3030.302d.4661.
302f.30
PC#show ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.11 YES DHCP up up
Serial1/0 unassigned YES unset administratively down down
相关的DHCP调试命令:
no service dhcp //停止DHCP服务[默认为启用DHCP服务]
sh ip dhcp binding //显示地址分配情况
show ip dhcp conflict //显示地址冲突情况
debug ip dhcp server {events | packets | linkage} //观察DHCP服务器工作情况
实验到此结束!!!