欢迎光临
我们一直在努力

三层交换机下的DHCP中继(DHCP Relay)配置:跨VLAN网络自动分配IP方案

一、DHCP中继原理与适用场景

DHCP中继(DHCP Relay)是一种网络技术,允许DHCP客户端通过三层设备(如路由器或三层交换机)获取IP地址,即使DHCP服务器与客户端不在同一子网。当客户端发送DHCP Discover广播包时,三层设备会将其转换为单播包转发到DHCP服务器,并将服务器的响应转发回客户端。

#publish-mermaid-0-1793725528980{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-0-1793725528980 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-0-1793725528980 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-0-1793725528980 .error-icon{fill:#552222;}#publish-mermaid-0-1793725528980 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-0-1793725528980 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-0-1793725528980 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-0-1793725528980 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-0-1793725528980 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-0-1793725528980 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-0-1793725528980 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-0-1793725528980 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-0-1793725528980 .marker.cross{stroke:#333333;}#publish-mermaid-0-1793725528980 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-0-1793725528980 p{margin:0;}#publish-mermaid-0-1793725528980 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-0-1793725528980 .cluster-label text{fill:#333;}#publish-mermaid-0-1793725528980 .cluster-label span{color:#333;}#publish-mermaid-0-1793725528980 .cluster-label span p{background-color:transparent;}#publish-mermaid-0-1793725528980 .label text,#publish-mermaid-0-1793725528980 span{fill:#333;color:#333;}#publish-mermaid-0-1793725528980 .node rect,#publish-mermaid-0-1793725528980 .node circle,#publish-mermaid-0-1793725528980 .node ellipse,#publish-mermaid-0-1793725528980 .node polygon,#publish-mermaid-0-1793725528980 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-0-1793725528980 .rough-node .label text,#publish-mermaid-0-1793725528980 .node .label text,#publish-mermaid-0-1793725528980 .image-shape .label,#publish-mermaid-0-1793725528980 .icon-shape .label{text-anchor:middle;}#publish-mermaid-0-1793725528980 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-0-1793725528980 .rough-node .label,#publish-mermaid-0-1793725528980 .node .label,#publish-mermaid-0-1793725528980 .image-shape .label,#publish-mermaid-0-1793725528980 .icon-shape .label{text-align:center;}#publish-mermaid-0-1793725528980 .node.clickable{cursor:pointer;}#publish-mermaid-0-1793725528980 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-0-1793725528980 .arrowheadPath{fill:#333333;}#publish-mermaid-0-1793725528980 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-0-1793725528980 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-0-1793725528980 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-0-1793725528980 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-0-1793725528980 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-0-1793725528980 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-0-1793725528980 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-0-1793725528980 .cluster text{fill:#333;}#publish-mermaid-0-1793725528980 .cluster span{color:#333;}#publish-mermaid-0-1793725528980 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-0-1793725528980 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-0-1793725528980 rect.text{fill:none;stroke-width:0;}#publish-mermaid-0-1793725528980 .icon-shape,#publish-mermaid-0-1793725528980 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-0-1793725528980 .icon-shape p,#publish-mermaid-0-1793725528980 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-0-1793725528980 .icon-shape .label rect,#publish-mermaid-0-1793725528980 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-0-1793725528980 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-0-1793725528980 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-0-1793725528980 .node .neo-node{stroke:#9370DB;}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node rect,#publish-mermaid-0-1793725528980 [data-look=\”neo\”].cluster rect,#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793725528980 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-0-1793725528980 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

客户端发送DHCP Discover广播

三层交换机收到广播

交换机将广播转换为单播

转发到DHCP服务器

服务器发送DHCPOffer

交换机转发响应到客户端

客户端接收并请求IP

如上图所示,DHCP中继的工作流程是:客户端发送DHCP Discover广播包,三层交换机收到后将其转换为单播包转发到DHCP服务器,服务器响应后,交换机再将响应转发回客户端。这种机制解决了DHCP广播包无法跨VLAN传播的问题。

DHCP中继主要适用于以下场景:

  • 企业网络中,DHCP服务器集中部署在核心层,而客户端分布在多个VLAN
  • 需要统一管理IP地址分配,避免在每个VLAN部署DHCP服务器
  • 网络规模较大,需要集中式IP地址管理
  • 二、网络拓扑规划

    在配置DHCP中继前,需要明确网络拓扑结构。以下是一个典型的三层交换机DHCP中继网络拓扑:

    #publish-mermaid-1-1793725529040{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-1-1793725529040 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-1-1793725529040 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-1-1793725529040 .error-icon{fill:#552222;}#publish-mermaid-1-1793725529040 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-1-1793725529040 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-1-1793725529040 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-1-1793725529040 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-1-1793725529040 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-1-1793725529040 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-1-1793725529040 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-1-1793725529040 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-1-1793725529040 .marker.cross{stroke:#333333;}#publish-mermaid-1-1793725529040 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-1-1793725529040 p{margin:0;}#publish-mermaid-1-1793725529040 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-1-1793725529040 .cluster-label text{fill:#333;}#publish-mermaid-1-1793725529040 .cluster-label span{color:#333;}#publish-mermaid-1-1793725529040 .cluster-label span p{background-color:transparent;}#publish-mermaid-1-1793725529040 .label text,#publish-mermaid-1-1793725529040 span{fill:#333;color:#333;}#publish-mermaid-1-1793725529040 .node rect,#publish-mermaid-1-1793725529040 .node circle,#publish-mermaid-1-1793725529040 .node ellipse,#publish-mermaid-1-1793725529040 .node polygon,#publish-mermaid-1-1793725529040 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1-1793725529040 .rough-node .label text,#publish-mermaid-1-1793725529040 .node .label text,#publish-mermaid-1-1793725529040 .image-shape .label,#publish-mermaid-1-1793725529040 .icon-shape .label{text-anchor:middle;}#publish-mermaid-1-1793725529040 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-1-1793725529040 .rough-node .label,#publish-mermaid-1-1793725529040 .node .label,#publish-mermaid-1-1793725529040 .image-shape .label,#publish-mermaid-1-1793725529040 .icon-shape .label{text-align:center;}#publish-mermaid-1-1793725529040 .node.clickable{cursor:pointer;}#publish-mermaid-1-1793725529040 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-1-1793725529040 .arrowheadPath{fill:#333333;}#publish-mermaid-1-1793725529040 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-1-1793725529040 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-1-1793725529040 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1-1793725529040 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-1-1793725529040 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1-1793725529040 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-1-1793725529040 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-1-1793725529040 .cluster text{fill:#333;}#publish-mermaid-1-1793725529040 .cluster span{color:#333;}#publish-mermaid-1-1793725529040 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-1-1793725529040 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-1-1793725529040 rect.text{fill:none;stroke-width:0;}#publish-mermaid-1-1793725529040 .icon-shape,#publish-mermaid-1-1793725529040 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-1-1793725529040 .icon-shape p,#publish-mermaid-1-1793725529040 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-1-1793725529040 .icon-shape .label rect,#publish-mermaid-1-1793725529040 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-1-1793725529040 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-1-1793725529040 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-1-1793725529040 .node .neo-node{stroke:#9370DB;}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node rect,#publish-mermaid-1-1793725529040 [data-look=\”neo\”].cluster rect,#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793725529040 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-1-1793725529040 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}客户端服务器区接入层核心层trunktrunktrunkaccessaccess

    三层交换机

    接入交换机1

    接入交换机2

    DHCP服务器

    PC 192.168.1.0/24

    PC 192.168.2.0/24

    在这个拓扑中,三层交换机作为DHCP中继,连接多个VLAN和DHCP服务器。客户端位于不同的VLAN(192.168.1.0/24和192.168.2.0/24),通过接入交换机连接到核心三层交换机。

    规划时需要考虑:

  • 确定DHCP服务器的IP地址和位置
  • 划分VLAN并分配IP地址段
  • 配置VLAN间路由
  • 确定DHCP中继代理的IP地址
  • 三、三层交换机DHCP中继配置步骤

    1. 基础网络配置

    首先配置三层交换机的基本网络参数,包括VLAN划分和接口配置:

    #publish-mermaid-2-1793725529116{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-2-1793725529116 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-2-1793725529116 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-2-1793725529116 .error-icon{fill:#552222;}#publish-mermaid-2-1793725529116 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-2-1793725529116 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-2-1793725529116 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-2-1793725529116 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-2-1793725529116 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-2-1793725529116 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-2-1793725529116 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-2-1793725529116 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-2-1793725529116 .marker.cross{stroke:#333333;}#publish-mermaid-2-1793725529116 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-2-1793725529116 p{margin:0;}#publish-mermaid-2-1793725529116 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-2-1793725529116 .cluster-label text{fill:#333;}#publish-mermaid-2-1793725529116 .cluster-label span{color:#333;}#publish-mermaid-2-1793725529116 .cluster-label span p{background-color:transparent;}#publish-mermaid-2-1793725529116 .label text,#publish-mermaid-2-1793725529116 span{fill:#333;color:#333;}#publish-mermaid-2-1793725529116 .node rect,#publish-mermaid-2-1793725529116 .node circle,#publish-mermaid-2-1793725529116 .node ellipse,#publish-mermaid-2-1793725529116 .node polygon,#publish-mermaid-2-1793725529116 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-2-1793725529116 .rough-node .label text,#publish-mermaid-2-1793725529116 .node .label text,#publish-mermaid-2-1793725529116 .image-shape .label,#publish-mermaid-2-1793725529116 .icon-shape .label{text-anchor:middle;}#publish-mermaid-2-1793725529116 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-2-1793725529116 .rough-node .label,#publish-mermaid-2-1793725529116 .node .label,#publish-mermaid-2-1793725529116 .image-shape .label,#publish-mermaid-2-1793725529116 .icon-shape .label{text-align:center;}#publish-mermaid-2-1793725529116 .node.clickable{cursor:pointer;}#publish-mermaid-2-1793725529116 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-2-1793725529116 .arrowheadPath{fill:#333333;}#publish-mermaid-2-1793725529116 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-2-1793725529116 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-2-1793725529116 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-2-1793725529116 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-2-1793725529116 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-2-1793725529116 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-2-1793725529116 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-2-1793725529116 .cluster text{fill:#333;}#publish-mermaid-2-1793725529116 .cluster span{color:#333;}#publish-mermaid-2-1793725529116 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-2-1793725529116 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-2-1793725529116 rect.text{fill:none;stroke-width:0;}#publish-mermaid-2-1793725529116 .icon-shape,#publish-mermaid-2-1793725529116 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-2-1793725529116 .icon-shape p,#publish-mermaid-2-1793725529116 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-2-1793725529116 .icon-shape .label rect,#publish-mermaid-2-1793725529116 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-2-1793725529116 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-2-1793725529116 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-2-1793725529116 .node .neo-node{stroke:#9370DB;}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node rect,#publish-mermaid-2-1793725529116 [data-look=\”neo\”].cluster rect,#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793725529116 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-2-1793725529116 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

    进入全局配置模式

    创建VLAN

    配置VLAN接口IP

    配置 trunk接口

    配置 access接口

    配置默认路由

    具体配置步骤:

  • 进入全局配置模式:configure terminal
  • 创建VLAN:vlan 10 和 vlan 20
  • 配置VLAN接口IP:interface vlan 10,ip address 192.168.1.1 255.255.255.0
  • 配置trunk接口:interface gigabitethernet 0/1,switchport mode trunk
  • 配置access接口:interface gigabitethernet 0/2,switchport mode access,switchport access vlan 10
  • 配置默认路由:ip route 0.0.0.0 0.0.0.0 192.168.1.254
  • 2. DHCP中继配置

    配置DHCP中继代理,指定DHCP服务器的IP地址:

    #publish-mermaid-3-1793725529161{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-3-1793725529161 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-3-1793725529161 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-3-1793725529161 .error-icon{fill:#552222;}#publish-mermaid-3-1793725529161 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-3-1793725529161 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-3-1793725529161 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-3-1793725529161 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-3-1793725529161 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-3-1793725529161 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-3-1793725529161 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-3-1793725529161 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-3-1793725529161 .marker.cross{stroke:#333333;}#publish-mermaid-3-1793725529161 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-3-1793725529161 p{margin:0;}#publish-mermaid-3-1793725529161 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-3-1793725529161 .cluster-label text{fill:#333;}#publish-mermaid-3-1793725529161 .cluster-label span{color:#333;}#publish-mermaid-3-1793725529161 .cluster-label span p{background-color:transparent;}#publish-mermaid-3-1793725529161 .label text,#publish-mermaid-3-1793725529161 span{fill:#333;color:#333;}#publish-mermaid-3-1793725529161 .node rect,#publish-mermaid-3-1793725529161 .node circle,#publish-mermaid-3-1793725529161 .node ellipse,#publish-mermaid-3-1793725529161 .node polygon,#publish-mermaid-3-1793725529161 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-3-1793725529161 .rough-node .label text,#publish-mermaid-3-1793725529161 .node .label text,#publish-mermaid-3-1793725529161 .image-shape .label,#publish-mermaid-3-1793725529161 .icon-shape .label{text-anchor:middle;}#publish-mermaid-3-1793725529161 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-3-1793725529161 .rough-node .label,#publish-mermaid-3-1793725529161 .node .label,#publish-mermaid-3-1793725529161 .image-shape .label,#publish-mermaid-3-1793725529161 .icon-shape .label{text-align:center;}#publish-mermaid-3-1793725529161 .node.clickable{cursor:pointer;}#publish-mermaid-3-1793725529161 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-3-1793725529161 .arrowheadPath{fill:#333333;}#publish-mermaid-3-1793725529161 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-3-1793725529161 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-3-1793725529161 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-3-1793725529161 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-3-1793725529161 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-3-1793725529161 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-3-1793725529161 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-3-1793725529161 .cluster text{fill:#333;}#publish-mermaid-3-1793725529161 .cluster span{color:#333;}#publish-mermaid-3-1793725529161 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-3-1793725529161 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-3-1793725529161 rect.text{fill:none;stroke-width:0;}#publish-mermaid-3-1793725529161 .icon-shape,#publish-mermaid-3-1793725529161 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-3-1793725529161 .icon-shape p,#publish-mermaid-3-1793725529161 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-3-1793725529161 .icon-shape .label rect,#publish-mermaid-3-1793725529161 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-3-1793725529161 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-3-1793725529161 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-3-1793725529161 .node .neo-node{stroke:#9370DB;}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node rect,#publish-mermaid-3-1793725529161 [data-look=\”neo\”].cluster rect,#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793725529161 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-3-1793725529161 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

    进入全局配置模式

    启用DHCP服务

    配置DHCP中继

    指定DHCP服务器

    配置中继接口

    保存配置

    具体配置步骤:

  • 进入全局配置模式:configure terminal
  • 启用DHCP服务:service dhcp
  • 配置DHCP中继:ip dhcp relay information option
  • 指定DHCP服务器:ip dhcp relay address 192.168.1.100
  • 配置中继接口:interface vlan 10,ip helper-address 192.168.1.100
  • 保存配置:write memory
  • 3. 验证配置

    配置完成后,需要验证DHCP中继是否正常工作:

    DHCP服务器三层交换机客户端DHCP服务器三层交换机客户端#publish-mermaid-4-1793725529204{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-4-1793725529204 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-4-1793725529204 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-4-1793725529204 .error-icon{fill:#552222;}#publish-mermaid-4-1793725529204 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-4-1793725529204 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-4-1793725529204 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-4-1793725529204 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-4-1793725529204 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-4-1793725529204 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-4-1793725529204 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-4-1793725529204 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-4-1793725529204 .marker.cross{stroke:#333333;}#publish-mermaid-4-1793725529204 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-4-1793725529204 p{margin:0;}#publish-mermaid-4-1793725529204 .actor{stroke:#9370DB;fill:#ECECFF;stroke-width:1;}#publish-mermaid-4-1793725529204 rect.actor.outer-path[data-look=\”neo\”]{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 rect.note[data-look=\”neo\”]{stroke:#aaaa33;fill:#fff5ad;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 text.actor>tspan{fill:black;stroke:none;}#publish-mermaid-4-1793725529204 .actor-line{stroke:#9370DB;}#publish-mermaid-4-1793725529204 .innerArc{stroke-width:1.5;stroke-dasharray:none;}#publish-mermaid-4-1793725529204 .messageLine0{stroke-width:1.5;stroke-dasharray:none;stroke:#333;}#publish-mermaid-4-1793725529204 .messageLine1{stroke-width:1.5;stroke-dasharray:2,2;stroke:#333;}#publish-mermaid-4-1793725529204 [id$=\”-arrowhead\”] path{fill:#333;stroke:#333;}#publish-mermaid-4-1793725529204 .sequenceNumber{fill:white;}#publish-mermaid-4-1793725529204 [id$=\”-sequencenumber\”]{fill:#333;}#publish-mermaid-4-1793725529204 [id$=\”-crosshead\”] path{fill:#333;stroke:#333;}#publish-mermaid-4-1793725529204 .messageText{fill:#333;stroke:none;}#publish-mermaid-4-1793725529204 .labelBox{stroke:#9370DB;fill:#ECECFF;filter:none;}#publish-mermaid-4-1793725529204 .labelText,#publish-mermaid-4-1793725529204 .labelText>tspan{fill:black;stroke:none;}#publish-mermaid-4-1793725529204 .loopText,#publish-mermaid-4-1793725529204 .loopText>tspan{fill:black;stroke:none;}#publish-mermaid-4-1793725529204 .sectionTitle,#publish-mermaid-4-1793725529204 .sectionTitle>tspan{fill:black;stroke:none;}#publish-mermaid-4-1793725529204 .loopLine{stroke-width:2px;stroke-dasharray:2,2;stroke:#9370DB;fill:#9370DB;}#publish-mermaid-4-1793725529204 .note{stroke:#aaaa33;fill:#fff5ad;}#publish-mermaid-4-1793725529204 .noteText,#publish-mermaid-4-1793725529204 .noteText>tspan{fill:black;stroke:none;font-weight:normal;}#publish-mermaid-4-1793725529204 .activation0{fill:#f4f4f4;stroke:#666;}#publish-mermaid-4-1793725529204 .activation1{fill:#f4f4f4;stroke:#666;}#publish-mermaid-4-1793725529204 .activation2{fill:#f4f4f4;stroke:#666;}#publish-mermaid-4-1793725529204 .actorPopupMenu{position:absolute;}#publish-mermaid-4-1793725529204 .actorPopupMenuPanel{position:absolute;fill:#ECECFF;box-shadow:0px 8px 16px 0px rgba(0,0,0,0.2);filter:drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));}#publish-mermaid-4-1793725529204 .actor-man circle,#publish-mermaid-4-1793725529204 line{fill:#ECECFF;stroke-width:2px;}#publish-mermaid-4-1793725529204 g rect.rect{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));stroke:#9370DB;}#publish-mermaid-4-1793725529204 .node .neo-node{stroke:#9370DB;}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node rect,#publish-mermaid-4-1793725529204 [data-look=\”neo\”].cluster rect,#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-4-1793725529204 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}发送DHCP Discover广播转发单播DHCP Discover发送DHCPOffer转发DHCPOffer发送DHCP Request转发单播DHCP Request发送DHCP Ack转发DHCP Ack

    验证步骤:

  • 在客户端上执行ipconfig /renew或dhclient -r重新获取IP地址
  • 检查客户端是否获得正确的IP地址
  • 在三层交换机上查看DHCP中继统计信息:show ip dhcp relay
  • 在DHCP服务器上查看租约信息
  • 四、故障排查与解决方案

    当DHCP中继配置完成后,可能会遇到各种问题。以下是一些常见问题和解决方案:

    #publish-mermaid-5-1793725529235{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-5-1793725529235 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-5-1793725529235 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-5-1793725529235 .error-icon{fill:#552222;}#publish-mermaid-5-1793725529235 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-5-1793725529235 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-5-1793725529235 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-5-1793725529235 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-5-1793725529235 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-5-1793725529235 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-5-1793725529235 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-5-1793725529235 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-5-1793725529235 .marker.cross{stroke:#333333;}#publish-mermaid-5-1793725529235 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-5-1793725529235 p{margin:0;}#publish-mermaid-5-1793725529235 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-5-1793725529235 .cluster-label text{fill:#333;}#publish-mermaid-5-1793725529235 .cluster-label span{color:#333;}#publish-mermaid-5-1793725529235 .cluster-label span p{background-color:transparent;}#publish-mermaid-5-1793725529235 .label text,#publish-mermaid-5-1793725529235 span{fill:#333;color:#333;}#publish-mermaid-5-1793725529235 .node rect,#publish-mermaid-5-1793725529235 .node circle,#publish-mermaid-5-1793725529235 .node ellipse,#publish-mermaid-5-1793725529235 .node polygon,#publish-mermaid-5-1793725529235 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-5-1793725529235 .rough-node .label text,#publish-mermaid-5-1793725529235 .node .label text,#publish-mermaid-5-1793725529235 .image-shape .label,#publish-mermaid-5-1793725529235 .icon-shape .label{text-anchor:middle;}#publish-mermaid-5-1793725529235 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-5-1793725529235 .rough-node .label,#publish-mermaid-5-1793725529235 .node .label,#publish-mermaid-5-1793725529235 .image-shape .label,#publish-mermaid-5-1793725529235 .icon-shape .label{text-align:center;}#publish-mermaid-5-1793725529235 .node.clickable{cursor:pointer;}#publish-mermaid-5-1793725529235 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-5-1793725529235 .arrowheadPath{fill:#333333;}#publish-mermaid-5-1793725529235 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-5-1793725529235 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-5-1793725529235 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-5-1793725529235 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-5-1793725529235 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-5-1793725529235 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-5-1793725529235 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-5-1793725529235 .cluster text{fill:#333;}#publish-mermaid-5-1793725529235 .cluster span{color:#333;}#publish-mermaid-5-1793725529235 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-5-1793725529235 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-5-1793725529235 rect.text{fill:none;stroke-width:0;}#publish-mermaid-5-1793725529235 .icon-shape,#publish-mermaid-5-1793725529235 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-5-1793725529235 .icon-shape p,#publish-mermaid-5-1793725529235 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-5-1793725529235 .icon-shape .label rect,#publish-mermaid-5-1793725529235 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-5-1793725529235 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-5-1793725529235 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-5-1793725529235 .node .neo-node{stroke:#9370DB;}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node rect,#publish-mermaid-5-1793725529235 [data-look=\”neo\”].cluster rect,#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793725529235 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-5-1793725529235 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}是否

    客户端无法获取IP

    检查网络连通性

    检查DHCP中继配置

    检查VLAN和trunk配置

    检查DHCP服务器可达性

    检查防火墙规则

    检查DHCP服务器配置

    检查VLAN接口状态

    检查trunk协商

    常见问题和解决方案:

  • 客户端无法获取IP地址
    • 检查三层交换机与DHCP服务器的网络连通性
    • 验证DHCP中继配置是否正确
    • 确认DHCP服务器是否正常工作
  • 客户端获取错误IP地址
    • 检查VLAN接口配置
    • 验证DHCP服务器的作用域配置
    • 确认DHCP中继的helper-address配置
  • DHCP中继统计信息异常
    • 检查三层交换机的CPU和内存使用情况
    • 验证DHCP服务器的负载情况
    • 检查网络带宽和延迟

    五、最小配置示例

    以下是一个可直接运行的最小配置示例,假设三层交换机IP地址为192.168.1.1,DHCP服务器IP地址为192.168.1.100:

    #publish-mermaid-6-1793725529297{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#publish-mermaid-6-1793725529297 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#publish-mermaid-6-1793725529297 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#publish-mermaid-6-1793725529297 .error-icon{fill:#552222;}#publish-mermaid-6-1793725529297 .error-text{fill:#552222;stroke:#552222;}#publish-mermaid-6-1793725529297 .edge-thickness-normal{stroke-width:1px;}#publish-mermaid-6-1793725529297 .edge-thickness-thick{stroke-width:3.5px;}#publish-mermaid-6-1793725529297 .edge-pattern-solid{stroke-dasharray:0;}#publish-mermaid-6-1793725529297 .edge-thickness-invisible{stroke-width:0;fill:none;}#publish-mermaid-6-1793725529297 .edge-pattern-dashed{stroke-dasharray:3;}#publish-mermaid-6-1793725529297 .edge-pattern-dotted{stroke-dasharray:2;}#publish-mermaid-6-1793725529297 .marker{fill:#333333;stroke:#333333;}#publish-mermaid-6-1793725529297 .marker.cross{stroke:#333333;}#publish-mermaid-6-1793725529297 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#publish-mermaid-6-1793725529297 p{margin:0;}#publish-mermaid-6-1793725529297 .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#publish-mermaid-6-1793725529297 .cluster-label text{fill:#333;}#publish-mermaid-6-1793725529297 .cluster-label span{color:#333;}#publish-mermaid-6-1793725529297 .cluster-label span p{background-color:transparent;}#publish-mermaid-6-1793725529297 .label text,#publish-mermaid-6-1793725529297 span{fill:#333;color:#333;}#publish-mermaid-6-1793725529297 .node rect,#publish-mermaid-6-1793725529297 .node circle,#publish-mermaid-6-1793725529297 .node ellipse,#publish-mermaid-6-1793725529297 .node polygon,#publish-mermaid-6-1793725529297 .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#publish-mermaid-6-1793725529297 .rough-node .label text,#publish-mermaid-6-1793725529297 .node .label text,#publish-mermaid-6-1793725529297 .image-shape .label,#publish-mermaid-6-1793725529297 .icon-shape .label{text-anchor:middle;}#publish-mermaid-6-1793725529297 .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#publish-mermaid-6-1793725529297 .rough-node .label,#publish-mermaid-6-1793725529297 .node .label,#publish-mermaid-6-1793725529297 .image-shape .label,#publish-mermaid-6-1793725529297 .icon-shape .label{text-align:center;}#publish-mermaid-6-1793725529297 .node.clickable{cursor:pointer;}#publish-mermaid-6-1793725529297 .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#publish-mermaid-6-1793725529297 .arrowheadPath{fill:#333333;}#publish-mermaid-6-1793725529297 .edgePath .path{stroke:#333333;stroke-width:1px;}#publish-mermaid-6-1793725529297 .flowchart-link{stroke:#333333;fill:none;}#publish-mermaid-6-1793725529297 .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-6-1793725529297 .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#publish-mermaid-6-1793725529297 .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-6-1793725529297 .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#publish-mermaid-6-1793725529297 .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#publish-mermaid-6-1793725529297 .cluster text{fill:#333;}#publish-mermaid-6-1793725529297 .cluster span{color:#333;}#publish-mermaid-6-1793725529297 div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#publish-mermaid-6-1793725529297 .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#publish-mermaid-6-1793725529297 rect.text{fill:none;stroke-width:0;}#publish-mermaid-6-1793725529297 .icon-shape,#publish-mermaid-6-1793725529297 .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#publish-mermaid-6-1793725529297 .icon-shape p,#publish-mermaid-6-1793725529297 .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#publish-mermaid-6-1793725529297 .icon-shape .label rect,#publish-mermaid-6-1793725529297 .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#publish-mermaid-6-1793725529297 .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#publish-mermaid-6-1793725529297 .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#publish-mermaid-6-1793725529297 .node .neo-node{stroke:#9370DB;}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node rect,#publish-mermaid-6-1793725529297 [data-look=\”neo\”].cluster rect,#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node polygon{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].swimlane.cluster rect{filter:none;}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node path{stroke:#9370DB;stroke-width:1px;}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node .outer-path{filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node .neo-line path{stroke:#9370DB;filter:none;}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node circle{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].node circle .state-start{fill:#000000;}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].icon-shape .icon{fill:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-6-1793725529297 [data-look=\”neo\”].icon-shape .icon-neo path{stroke:#9370DB;filter:drop-shadow(1px 2px 2px rgba(185, 185, 185, 1));}#publish-mermaid-6-1793725529297 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

    三层交换机配置

    创建VLAN 10

    配置VLAN 10接口

    配置DHCP中继

    保存配置

    具体配置命令:

    enable
    configure terminal
    vlan 10
    exit
    interface vlan 10
    ip address 192.168.1.1 255.255.255.0
    no shutdown
    exit
    ip dhcp relay information option
    interface vlan 10
    ip helper-address 192.168.1.100
    exit
    write memory

    验证配置:

    show running-config | include dhcp
    show ip dhcp relay
    show ip interface brief

    六、注意事项与最佳实践

  • DHCP服务器位置选择
    • 建议将DHCP服务器放置在核心层,确保高可用性
    • 考虑DHCP服务器的负载均衡,避免单点故障
  • 安全考虑
    • 配置DHCP snooping防止DHCP欺骗攻击
    • 限制DHCP中继接口,只允许必要的VLAN使用
    • 启用DHCP选项82记录客户端位置信息
  • 性能优化
    • 根据网络规模调整DHCP服务器的租约时间
    • 考虑使用DHCP Failover实现高可用性
    • 监控DHCP服务器的性能和资源使用情况
  • 监控与维护
    • 定期检查DHCP中继统计信息
    • 监控DHCP服务器的日志和错误信息
    • 定期备份DHCP服务器配置

    通过以上配置和注意事项,可以确保三层交换机上的DHCP中继正常工作,实现跨VLAN网络的自动IP地址分配。

    赞(0)
    未经允许不得转载:171主机测评 » 三层交换机下的DHCP中继(DHCP Relay)配置:跨VLAN网络自动分配IP方案
    分享到: 更多 (0)

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址