DHCP中继服务配置案例

由于DHCP客户机通过网络广播消息获得DHCP服务器的响应后得到IP地址,但广播消息不能跨网段。因此当客户机和服务器不在同一网段内,就需要用到DHCP中继代理。

实验拓扑图

DHCP中继服务配置案例_第1张图片

实验目的

R1作为DHCP服务器,R1,R2上做中继服务,实现不同网段的pc获取地址

一.交换机SW1划分VLAN

[SW1]vlan batch 10 20    					##创建vlan10 20
[SW1]int e0/0/1								##进入接口e 0/0/1
[SW1-Ethernet0/0/1]port link-type access	##配置为access口
[SW1-Ethernet0/0/1]port default vlan 10		##将接口放到vlan10中
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]p l a
[SW1-Ethernet0/0/3]p d v 10
[SW1-Ethernet0/0/3]int e0/0/4
[SW1-Ethernet0/0/4]p l a
[SW1-Ethernet0/0/4]p d v 20
[SW1-Ethernet0/0/4]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all

二.路由器R1配置——接口IP,DHCP服务,DHCP地址池,DHCP全局接口,默认路由

接口IP地址配置
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 14.0.0.2 24
[R1-GigabitEthernet0/0/0]un sh
[R1-GigabitEthernet0/0/0]q

开启DHCP服务
[R1]dhcp enable

划分DHCP地址池DHCP15
[R1]ip pool DHCP15
[R1-ip-pool-DHCP15]network 15.0.0.0 mask 24
[R1-ip-pool-DHCP15]gateway-list 15.0.0.1
[R1-ip-pool-DHCP15]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-DHCP15]q

划分DHCP地址池DHCPvlan10
[R1]ip pool DHCPvlan10
[R1-ip-pool-DHCPvlan10]dns-list 8.8.8.8 2.2.2.2
[R1-ip-pool-DHCPvlan10]network 192.168.10.0 mask 24
[R1-ip-pool-DHCPvlan10]gateway-list 192.168.10.1
[R1-ip-pool-DHCPvlan10]q

划分DHCP地址池DHCPvlan20
[R1]ip pool DHCPvlan20
[R1-ip-pool-DHCPvlan20]network 192.168.20.0 mask 24
[R1-ip-pool-DHCPvlan20]gateway-list 192.168.20.1
[R1-ip-pool-DHCPvlan20]dns-list 8.8.8.8 2.2.2.2

配置DHCP全局接口
[R1-ip-pool-DHCPvlan20]int g0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global
[R1-GigabitEthernet0/0/0]q

默认路由
[R1]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1

三.路由器R2配置——接口IP,单臂路由,DHCP服务,DHCP中继,静态路由

接口IP地址配置
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R2-GigabitEthernet0/0/0]un sh
[R2]int g0/0/2
[R2-GigabitEthernet0/0/0]ip add 14.0.0.1 24
[R2-GigabitEthernet0/0/0]un sh

接口IP地址配置之单臂路由
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]un sh
[R2-GigabitEthernet0/0/1]int g0/0/1.10
[R2-GigabitEthernet0/0/1.10]dot1q termination vid 10
[R2-GigabitEthernet0/0/1.10]ip add 192.168.10.1 24
[R2-GigabitEthernet0/0/1.10]arp broadcast enable
[R2-GigabitEthernet0/0/1.10]q
[R2]int g0/0/1.20
[R2-GigabitEthernet0/0/1.20]dot1q termination vid 20
[R2-GigabitEthernet0/0/1.20]ip add 192.168.20.1 24
[R2-GigabitEthernet0/0/1.20]arp broadcast enable
[R2-GigabitEthernet0/0/1.20]q

开启DHCP服务
[R2]dhcp enable

在接口下配置中继模式及中继模式指定接口IP地址
[R2]int g0/0/1.10
[R2-GigabitEthernet0/0/1.10]dhcp select relay
[R2-GigabitEthernet0/0/1.10]dhcp relay server-ip 14.0.0.2

在接口下配置中继模式及中继模式指定接口IP地址
[R2-GigabitEthernet0/0/1.10]int g0/0/1.20
[R2-GigabitEthernet0/0/1.20]dhcp select relay
[R2-GigabitEthernet0/0/1.20]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1.20]q

静态路由
[R2]ip route-static 15.0.0.0 24 12.0.0.2

四.路由器R3配置——接口IP,DHCP服务,DHCP中继,默认路由

接口IP地址配置
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R3-GigabitEthernet0/0/0]un sh
[R3-GigabitEthernet0/0/0]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R3-GigabitEthernet0/0/1]un sh
[R3-GigabitEthernet0/0/1]q

开启DHCP服务
[R3]dhcp enable

在接口下配置中继模式及中继模式指定接口IP地址
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]dhcp select relay
[R3-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2

默认路由
[R3]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1

五.测试连通与抓包分析
输入命令ipconfig /renew获取主机地址
DHCP中继服务配置案例_第2张图片

抓包可见DHCP协议报文
在这里插入图片描述

至此,实验结束,感谢阅读!

你可能感兴趣的:(DHCP中继服务配置案例)