Dhcp中继ensp

拓扑图

<Huawei>system-view

Huaweisysname SW1

SW1vlan batch 10 20

SW1int e0/0/1 #配置access接口

SW1-Ethernet0/0/1port link-type access

SW1-Ethernet0/0/1port default vlan 10

SW1-Ethernet0/0/1undo shut

SW1-Ethernet0/0/1q

SW1int e0/0/2 #配置access接口

SW1-Ethernet0/0/2port link-type access

SW1-Ethernet0/0/2port default vlan 20

SW1-Ethernet0/0/2undo shutdown

SW1-Ethernet0/0/2int e0/0/3 #配置access接口

SW1-Ethernet0/0/3port link-type access

SW1-Ethernet0/0/3port default vlan 10

SW1-Ethernet0/0/3undo shutdown

SW1-Ethernet0/0/3q

SW1int e0/0/4 #配置access接口

SW1-Ethernet0/0/4port link-type access

SW1-Ethernet0/0/4port default vlan 20

SW1-Ethernet0/0/4undo shutdown

SW1-Ethernet0/0/4q

SW1int g0/0/1 #配置trunk接口

SW1-GigabitEthernet0/0/1port link-type trunk

SW1-GigabitEthernet0/0/1port trunk allow-pass vlan all

SW1-GigabitEthernet0/0/1undo shutdown

<Huawei>system-view

Huaweisysname R1

#开启dhcp功能

R1dhcp enable

#配置第一个虚拟子接口1.1

R1int g0/0/1.1

#选择封装类型及vlan

R1-GigabitEthernet0/0/1.1dot1q termination vid 10

#开启arp广播功能

R1-GigabitEthernet0/0/1.1arp broadcast enable

#配置IP地址

R1-GigabitEthernet0/0/1.1ip add 192.168.10.1 24

#指向DHCP服务器

R1-GigabitEthernet0/0/1.1dhcp select relay

R1-GigabitEthernet0/0/1.1dhcp relay server-ip 14.0.0.2

R1-GigabitEthernet0/0/1.1undo shutdown

R1-GigabitEthernet0/0/1.1q

#同理配置第二个虚拟接口1.2

R1int g0/0/1.2

R1-GigabitEthernet0/0/1.2dot1q termination vid 20

R1-GigabitEthernet0/0/1.2arp broadcast enable

R1-GigabitEthernet0/0/1.2ip add 192.168.20.1 24

R1-GigabitEthernet0/0/1.2dhcp select relay

R1-GigabitEthernet0/0/1.2dhcp relay server-ip 14.0.0.2

R1-GigabitEthernet0/0/1.2q

#配置IP地址即可

R1int g0/0/3

R1-GigabitEthernet0/0/3ip add 14.0.0.1 24

R1-GigabitEthernet0/0/3undo shutdown

R1-GigabitEthernet0/0/3q

#配置IP地址即可

R1int g0/0/2

R1-GigabitEthernet0/0/2ip add 12.0.0.1 24

R1-GigabitEthernet0/0/2undo shutdown

R1-GigabitEthernet0/0/2q

#配置指向PC7的默认路由

R1ip route-static 0.0.0.0 0.0.0.0 12.0.0.2

<Huawei>system-view

Huaweisysname R2

#在全局模式下开启dhcp功能

R2dhcp enable

#配置IP地址

R2int g0/0/2

R2-GigabitEthernet0/0/2ip add 12.0.0.2 24

R2-GigabitEthernet0/0/2undo shutdown

R2-GigabitEthernet0/0/2q

#配置IP地址、指向DHCP服务器

R2int g0/0/0

R2-GigabitEthernet0/0/0ip add 15.0.0.1 24

<Huawei>sys

Huaweisysname R3

#在全局模式下开启dhcp功能

R3dhcp enable

#配置IP地址、宣告DHCP地址池

R3interface g0/0/3

R3-GigabitEthernet0/0/3ip add 14.0.0.2 24

#选择全局的地址池给DHCP客户端使用,而"dhcp select interface"则是选择接口的地址池给DHCP客户端使用

R3-GigabitEthernet0/0/3dhcp select global

R3-GigabitEthernet0/0/3undo shutdown

R3-GigabitEthernet0/0/3q

#配置主机PC7的地址池(名称:pc7)

R3ip pool dhcp-pc7

#设置IP地址网段

R3-ip-pool-dhcp-pc7network 15.0.0.0 mask 24

#设置网关

R3-ip-pool-dhcp-pc7gateway-list 15.0.0.1

#DNS服务器地址

R3-ip-pool-dhcp-pc7dns-list 8.8.8.8 114.114.114.114

R3-ip-pool-dhcp-pc7q

#配置VLAN10的IP地址池

R3ip pool dhcp-vlan10

R3-ip-pool-dhcp-vlan10network 192.168.10.0 mask 24

R3-ip-pool-dhcp-vlan10gateway-list 192.168.10.1

R3-ip-pool-dhcp-vlan10dns-list 8.8.8.8 114.114.114.114

R3-ip-pool-dhcp-vlan10q

#配置VLAN20的IP地址池

R3ip pool dhcp-vlan20

R3-ip-pool-dhcp-vlan20network 192.168.20.0 mask 24

R3-ip-pool-dhcp-vlan20gateway-list 192.168.20.1

R3-ip-pool-dhcp-vlan20dns-list 8.8.8.8 114.114.114.114

R3-ip-pool-dhcp-vlan20q

#配置静态路由

R3ip route-static 192.168.10.0 24 14.0.0.1

R3ip route-static 192.168.20.0 24 14.0.0.1

R3ip route-static 15.0.0.0 24 14.0.0.1

#指向DHCP服务器

R2-GigabitEthernet0/0/0dhcp select relay

R2-GigabitEthernet0/0/0dhcp relay server-ip 14.0.0.2

R2-GigabitEthernet0/0/0undo shut

R2-GigabitEthernet0/0/0q

#配置向左流通的静态路由

R2ip route-static 192.168.10.0 24 12.0.0.1

R2ip route-static 192.168.20.0 24 12.0.0.1

R2ip route-static 14.0.0.0 24 12.0.0.1

测试pc自动获得IP地址

相关推荐
liulilittle6 小时前
关于拥塞控制的几点思考
网络·c++·tcp/ip·计算机网络·信息与通信·tcp·通信
AOwhisky6 小时前
MySQL 学习笔记(第四期):SQL 语言之多表查询
linux·运维·网络·数据库·笔记·学习·mysql
Phantom Void6 小时前
服务器处理客户端请求的设计方法
linux·运维·网络
王码码20356 小时前
办了500M宽带看视频还是卡?我用NAS搭了个测速服务器,宽带有没有缩水一测便知
网络·接口·nas
ylscode6 小时前
Anthropic Claude Oceanus意外泄露:Mythos系列AI红队测试遭遇API代理滥用危机
网络·人工智能·安全·web安全·安全威胁分析
myenjoy_18 小时前
MQTT 与 Sparkplug B——从车间到云端的最后一公里
网络·python
2401_873479409 小时前
企业安全运营中,如何用IP离线库提前发现失陷主机?三步实现风险画像
网络·数据库·python·tcp/ip·ip
代码中介商11 小时前
HTTP 完全指南(最终篇):CORS 跨域资源共享深度详解
网络·网络协议·http
liulilittle11 小时前
过冲:拥塞控制的呼吸与盲行
linux·网络·c++·tcp/ip·计算机网络·tcp·通信
兮动人11 小时前
服务器流量监控与性能优化实战
服务器·网络·性能优化·服务器流量监控与性能优化实战