Dhcp中继ensp

拓扑图

<Huawei>system-view

Huawei\]sysname SW1 \[SW1\]vlan batch 10 20 \[SW1\]int e0/0/1 #配置access接口 \[SW1-Ethernet0/0/1\]port link-type access \[SW1-Ethernet0/0/1\]port default vlan 10 \[SW1-Ethernet0/0/1\]undo shut \[SW1-Ethernet0/0/1\]q \[SW1\]int e0/0/2 #配置access接口 \[SW1-Ethernet0/0/2\]port link-type access \[SW1-Ethernet0/0/2\]port default vlan 20 \[SW1-Ethernet0/0/2\]undo shutdown \[SW1-Ethernet0/0/2\]int e0/0/3 #配置access接口 \[SW1-Ethernet0/0/3\]port link-type access \[SW1-Ethernet0/0/3\]port default vlan 10 \[SW1-Ethernet0/0/3\]undo shutdown \[SW1-Ethernet0/0/3\]q \[SW1\]int e0/0/4 #配置access接口 \[SW1-Ethernet0/0/4\]port link-type access \[SW1-Ethernet0/0/4\]port default vlan 20 \[SW1-Ethernet0/0/4\]undo shutdown \[SW1-Ethernet0/0/4\]q \[SW1\]int g0/0/1 #配置trunk接口 \[SW1-GigabitEthernet0/0/1\]port link-type trunk \[SW1-GigabitEthernet0/0/1\]port trunk allow-pass vlan all \[SW1-GigabitEthernet0/0/1\]undo shutdown \system-view \[Huawei\]sysname R1 #开启dhcp功能 \[R1\]dhcp enable #配置第一个虚拟子接口1.1 \[R1\]int g0/0/1.1 #选择封装类型及vlan \[R1-GigabitEthernet0/0/1.1\]dot1q termination vid 10 #开启arp广播功能 \[R1-GigabitEthernet0/0/1.1\]arp broadcast enable #配置IP地址 \[R1-GigabitEthernet0/0/1.1\]ip add 192.168.10.1 24 #指向DHCP服务器 \[R1-GigabitEthernet0/0/1.1\]dhcp select relay \[R1-GigabitEthernet0/0/1.1\]dhcp relay server-ip 14.0.0.2 \[R1-GigabitEthernet0/0/1.1\]undo shutdown \[R1-GigabitEthernet0/0/1.1\]q #同理配置第二个虚拟接口1.2 \[R1\]int g0/0/1.2 \[R1-GigabitEthernet0/0/1.2\]dot1q termination vid 20 \[R1-GigabitEthernet0/0/1.2\]arp broadcast enable \[R1-GigabitEthernet0/0/1.2\]ip add 192.168.20.1 24 \[R1-GigabitEthernet0/0/1.2\]dhcp select relay \[R1-GigabitEthernet0/0/1.2\]dhcp relay server-ip 14.0.0.2 \[R1-GigabitEthernet0/0/1.2\]q #配置IP地址即可 \[R1\]int g0/0/3 \[R1-GigabitEthernet0/0/3\]ip add 14.0.0.1 24 \[R1-GigabitEthernet0/0/3\]undo shutdown \[R1-GigabitEthernet0/0/3\]q #配置IP地址即可 \[R1\]int g0/0/2 \[R1-GigabitEthernet0/0/2\]ip add 12.0.0.1 24 \[R1-GigabitEthernet0/0/2\]undo shutdown \[R1-GigabitEthernet0/0/2\]q #配置指向PC7的默认路由 \[R1\]ip route-static 0.0.0.0 0.0.0.0 12.0.0.2 \system-view \[Huawei\]sysname R2 #在全局模式下开启dhcp功能 \[R2\]dhcp enable #配置IP地址 \[R2\]int g0/0/2 \[R2-GigabitEthernet0/0/2\]ip add 12.0.0.2 24 \[R2-GigabitEthernet0/0/2\]undo shutdown \[R2-GigabitEthernet0/0/2\]q #配置IP地址、指向DHCP服务器 \[R2\]int g0/0/0 \[R2-GigabitEthernet0/0/0\]ip add 15.0.0.1 24 \sys \[Huawei\]sysname R3 #在全局模式下开启dhcp功能 \[R3\]dhcp enable #配置IP地址、宣告DHCP地址池 \[R3\]interface g0/0/3 \[R3-GigabitEthernet0/0/3\]ip add 14.0.0.2 24 #选择全局的地址池给DHCP客户端使用,而"dhcp select interface"则是选择接口的地址池给DHCP客户端使用 \[R3-GigabitEthernet0/0/3\]dhcp select global \[R3-GigabitEthernet0/0/3\]undo shutdown \[R3-GigabitEthernet0/0/3\]q #配置主机PC7的地址池(名称:pc7) \[R3\]ip pool dhcp-pc7 #设置IP地址网段 \[R3-ip-pool-dhcp-pc7\]network 15.0.0.0 mask 24 #设置网关 \[R3-ip-pool-dhcp-pc7\]gateway-list 15.0.0.1 #DNS服务器地址 \[R3-ip-pool-dhcp-pc7\]dns-list 8.8.8.8 114.114.114.114 \[R3-ip-pool-dhcp-pc7\]q #配置VLAN10的IP地址池 \[R3\]ip pool dhcp-vlan10 \[R3-ip-pool-dhcp-vlan10\]network 192.168.10.0 mask 24 \[R3-ip-pool-dhcp-vlan10\]gateway-list 192.168.10.1 \[R3-ip-pool-dhcp-vlan10\]dns-list 8.8.8.8 114.114.114.114 \[R3-ip-pool-dhcp-vlan10\]q #配置VLAN20的IP地址池 \[R3\]ip pool dhcp-vlan20 \[R3-ip-pool-dhcp-vlan20\]network 192.168.20.0 mask 24 \[R3-ip-pool-dhcp-vlan20\]gateway-list 192.168.20.1 \[R3-ip-pool-dhcp-vlan20\]dns-list 8.8.8.8 114.114.114.114 \[R3-ip-pool-dhcp-vlan20\]q #配置静态路由 \[R3\]ip route-static 192.168.10.0 24 14.0.0.1 \[R3\]ip route-static 192.168.20.0 24 14.0.0.1 \[R3\]ip route-static 15.0.0.0 24 14.0.0.1 #指向DHCP服务器 \[R2-GigabitEthernet0/0/0\]dhcp select relay \[R2-GigabitEthernet0/0/0\]dhcp relay server-ip 14.0.0.2 \[R2-GigabitEthernet0/0/0\]undo shut \[R2-GigabitEthernet0/0/0\]q #配置向左流通的静态路由 \[R2\]ip route-static 192.168.10.0 24 12.0.0.1 \[R2\]ip route-static 192.168.20.0 24 12.0.0.1 \[R2\]ip route-static 14.0.0.0 24 12.0.0.1 测试pc自动获得IP地址

相关推荐
秃了也弱了。6 小时前
WireShark:非常好用的网络抓包工具
网络·测试工具·wireshark
清源妙木真菌7 小时前
应用层协议——HTTP
网络·网络协议·http
网硕互联的小客服11 小时前
Apache 如何支持SHTML(SSI)的配置方法
运维·服务器·网络·windows·php
共享家952713 小时前
linux-数据链路层
linux·网络·macos
1892280486116 小时前
NY243NY253美光固态闪存NY257NY260
大数据·网络·人工智能·缓存
玩转以太网17 小时前
3 种方式玩转网络继电器!W55MH32 实现网页 + 阿里云 + 本地控制互通
网络·物联网·阿里云
How_doyou_do19 小时前
关于casdoor重定向问题
网络
小木话安全19 小时前
ISO27001 高阶架构 之 支持 -2
网络·安全·职场和发展·学习方法
破刺不会编程1 天前
socket编程UDP
linux·运维·服务器·网络·c++·网络协议·udp
Warren981 天前
Lua 脚本在 Redis 中的应用
java·前端·网络·vue.js·redis·junit·lua