当前位置: 首页 > news >正文

DHCP中继实验

DHCP中继实验

DHCP 中继实验简介

DHCP 中继(DHCP Relay) 用于跨子网或跨 VLAN 的环境中,帮助客户端通过路由器或三层交换机将 DHCP 请求转发到远程 DHCP 服务器。
实验目标:验证 DHCP 中继代理的功能,实现不同子网间的动态 IP 分配。


实验原理

核心问题
  • DHCP 请求(Discover/Request)以广播形式发送,但广播包默认无法跨越路由器或三层设备。
  • 中继代理的作用是将客户端的广播请求转换为单播,并转发至指定 DHCP 服务器。
工作流程
  1. 客户端发送广播请求
    • 客户端在子网 A(如 192.168.1.0/24)广播 DHCP Discover
  2. 中继代理接收并转发
    • 中继代理(配置在路由器或三层交换机上)捕获广播包,将其封装为单播报文:
      • 修改目标 IP 为 DHCP 服务器地址(如 10.0.0.100)。
      • 在报文头插入中继代理的 IP 地址(giaddr 字段),供服务器识别客户端所在子网。
  3. 服务器响应
    • 服务器根据 giaddr 判断客户端子网,从对应地址池分配 IP,通过单播返回 DHCP Offer 给中继代理。
  4. 中继代理转发响应
    • 中继代理将响应报文广播回客户端子网,完成地址分配。

实验拓扑

在这里插入图片描述

实验需求

  1. 按照图示配置IP地址
  2. 配置DHCP_server路由器为DHCP服务器,能够跨网段为192.168.2.0/24网段自动分配IP地址。要求分配DNS地址为202.103.24.68202.103.0.117
  3. PC3获取IP地址后,能够访问到192.168.1.1

实验步骤

1.给DHCP_server和中继路由器配置IP地址
在DHCP_server上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname DHCP_server
[DHCP_server]int g0/0
[DHCP_server-GigabitEthernet0/0]ip address 192.168.1.1 24
[DHCP_server-GigabitEthernet0/0]display ip interface brief
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.1.1/24     --           --
GE0/1               down     down     --                 --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
[DHCP_server-GigabitEthernet0/0]
在中继路由器上
<H3C>system-view 
System View: return to User View with Ctrl+Z.
[H3C]sysname 中继路由器
[中继路由器]int g0/0
[中继路由器-GigabitEthernet0/0]ip address 192.168.1.2 24
[中继路由器-GigabitEthernet0/0]int g0/1
[中继路由器-GigabitEthernet0/1]ip address 192.168.2.254 24
[中继路由器-GigabitEthernet0/1]display ip interface brief
*down: administratively down
(s): spoofing  (l): loopback
Interface           Physical Protocol IP address/Mask    VPN instance Description  
GE0/0               up       up       192.168.1.2/24     --           --
GE0/1               down     down     192.168.2.254/24   --           --
GE0/2               down     down     --                 --           --
GE5/0               down     down     --                 --           --
GE5/1               down     down     --                 --           --
GE6/0               down     down     --                 --           --
GE6/1               down     down     --                 --           --
Ser1/0              down     down     --                 --           --
Ser2/0              down     down     --                 --           --
Ser3/0              down     down     --                 --           --
Ser4/0              down     down     --                 --           --
[中继路由器-GigabitEthernet0/1]
2.配置R1为DHCP服务器,能够跨网段为192.168.2.0/24网段自动分配IP地址
注:默认情况下,DHCP只能为和本机处于同一网段的PC客户端分配IP地址。而我们现在却要求去跨网段给pc机分配IP地址,就需要配置DHCP中继来实现,在DHCP_server上创建的地址池必须要宣告192.168.2.0/24网段。DHCP分配的网关地址应该是192.168.2.0/24网段的真实网关,那根据上述拓扑可知,网关就是中继路由器的g0/1接口,IP地址为192.168.2.254,DHCP的IP地址请求和应答报文都是广播形式发送,默认情况下,是无法穿越路由器的,所以需要在中继路由器上开启DHCP中继功能,使DHCP报文能够跨网段转发,另外,192.168.2.0/24网段对DHCP_server来说,是非直连网段,要使DHCP_server和PC3连通,DHCP_server上必须具有到达192.168.2.0/24网段的路由信息
在DHCP_server
[DHCP_server]dhcp enable 
[DHCP_server]dhcp server ip-pool 1
[DHCP_server-dhcp-pool-1]network 192.168.2.0 mask 255.255.255.0
[DHCP_server-dhcp-pool-1]gateway-list 192.168.2.254
[DHCP_server-dhcp-pool-1]dns-list 202.103.24.68 202.103.0.117
[DHCP_server-dhcp-pool-1]
3.在中继路由器上开启DHCP功能,并在连接客户端的接口(g0/1)上开启DHCP中继功能,并指定DHCP服务器的IP地址
[中继路由器]dhcp enable 
[中继路由器]interface g0/1
[中继路由器-GigabitEthernet0/1]dhcp select relay 
[中继路由器-GigabitEthernet0/1]dhcp relay server-address 192.168.1.1
[中继路由器-GigabitEthernet0/1]
4.在R1上配置默认路由,使R1的DHCP协议报文能够到达PC3
在DHCP_server上
[DHCP_server]ip route-static 0.0.0.0 0 192.168.1.2   //配置默认路由
[DHCP_server]
5.在PC3上Ping 192.168.1.1,确认可以Ping通
在pc3上
<H3C>ping 192.168.1.1
Ping 192.168.1.1 (192.168.1.1): 56 data bytes, press CTRL_C to break
56 bytes from 192.168.1.1: icmp_seq=0 ttl=254 time=0.703 ms
56 bytes from 192.168.1.1: icmp_seq=1 ttl=254 time=0.678 ms
56 bytes from 192.168.1.1: icmp_seq=2 ttl=254 time=0.556 ms
56 bytes from 192.168.1.1: icmp_seq=3 ttl=254 time=0.733 ms
56 bytes from 192.168.1.1: icmp_seq=4 ttl=254 time=0.633 ms

--- Ping statistics for 192.168.1.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.556/0.661/0.733/0.062 ms
<H3C>%Mar 14 16:55:09:206 2025 H3C PING/6/PING_STATISTICS: Ping statistics for 192.168.1.1: 5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss, round-trip min/avg/max/std-dev = 0.556/0.661/0.733/0.062 ms.


文章转载自:

http://rqIQmJC4.fcwxs.cn
http://wZ5j3dIM.fcwxs.cn
http://9Py6xgmd.fcwxs.cn
http://lKNBOYuO.fcwxs.cn
http://fFQkWY6P.fcwxs.cn
http://5YpVwAkl.fcwxs.cn
http://RdwcfpBM.fcwxs.cn
http://RRe9HDPf.fcwxs.cn
http://Wm6eELlP.fcwxs.cn
http://Trk0qG7N.fcwxs.cn
http://0laDkwmG.fcwxs.cn
http://uHcRcR5Q.fcwxs.cn
http://O57KX1Yg.fcwxs.cn
http://iRGdx5sj.fcwxs.cn
http://jeaBdiS2.fcwxs.cn
http://beO6oMUT.fcwxs.cn
http://mN292QS9.fcwxs.cn
http://YBaBl6SW.fcwxs.cn
http://58V4lveL.fcwxs.cn
http://6RzcG8mp.fcwxs.cn
http://zi5tYhlm.fcwxs.cn
http://fTJwP6F6.fcwxs.cn
http://SEk3h1FZ.fcwxs.cn
http://lJQICIn2.fcwxs.cn
http://gzE3RBJn.fcwxs.cn
http://96ewck7J.fcwxs.cn
http://gGVUKxvk.fcwxs.cn
http://MRslB3W6.fcwxs.cn
http://27g42c5M.fcwxs.cn
http://0JUMpPIm.fcwxs.cn
http://www.dtcms.com/a/69592.html

相关文章:

  • 设计模式--单例模式(Singleton)【Go】
  • SAP Commerce(Hybris)营销模块(一):商城产品折扣配置
  • Android LeakCanary 使用 · 原理详解
  • Centos7阿里云yum源
  • Go语言入门基础详解
  • 使用docker部署宝塔环境
  • c#实现添加和删除Windows系统环境变量
  • 本地知识库RAG总结
  • Elasticsearch:语义文本 - 更简单、更好、更精炼、更强大 8.18
  • 使用mvn archetype命令,构建自定义springboot archetype脚手架创建工程的方法
  • 2.JVM-通俗易懂理解类加载过程
  • Java vs Go:SaaS 系统架构选型解析与最佳实践
  • 【FreeRTOS】FreeRTOS操作系统在嵌入式单片机上裸机移植
  • CSS 的 inherit、initial、revert 和 unset区别
  • mysql安装与使用
  • 深入理解 ALSA 声卡驱动:从理论到实践,解决嵌入式 Linux 声卡无声问题
  • 辉芒单片机FLASH->ACR导致的问题
  • Springboot+Netty+WebSocket搭建简单的消息通知
  • 大一新生备战蓝桥杯c/c++B组——2024年省赛真题解题+心得分享
  • 数仓建模和标签体系之间存在着密切的依赖关系
  • 27_Java2DRenderer结合freemarker动态生成图片
  • 可视化图解算法:合并k个已排序(升序)的链表
  • LeetCode——560. 和为 K 的子数组
  • 目前人工智能的发展,判断10年、20年后的人工智能发展的主要方向,或者带动的主要产业
  • 【openwebui 搭建本地知识库(RAG搭建本地知识库)】
  • 软件测试之测试用例
  • Microsoft Edge “无法更新” 解决办法
  • 学习笔记之车票搜索为什么用Redis而不是ES?
  • 32单片机——LED
  • 通过 Python 爬虫提高股票选股胜率