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地址

相关推荐
FreeBuf_7 小时前
黄金旋律IAB组织利用暴露的ASP.NET机器密钥实施未授权访问
网络·后端·asp.net
Tanecious.9 小时前
C++--红黑树封装实现set和map
网络·c++
yqcoder10 小时前
7. TCP 和 UDP 的区别
网络·网络协议·http
weixin_4567325910 小时前
tcpdump交叉编译
网络·测试工具·tcpdump
IT WorryFree12 小时前
macos安装iper3
网络·macos·iperf·打流
hrrrrb12 小时前
【TCP/IP】14. 远程登录协议
网络·网络协议·tcp/ip
别枫了12 小时前
TCP的连接
服务器·网络·tcp/ip
小镇敲码人13 小时前
【实习篇】之Http头部字段之Disposition介绍
网络·网络协议·http
黎相思13 小时前
应用层协议HTTP
网络·网络协议·http
(Charon)13 小时前
【C语言网络编程】HTTP 客户端请求(域名解析过程)
网络