创建拓扑:

基本思路:
1)启用dhcp服务
2)创建三个地址池
3)设置子接口
4) 设置物理接口
5)设置静态路由
6) 配置中继代理服务器
具体操作如下:
1)启用dhcp服务
[dhcp]dhcp enable
2)创建三个地址池
[dhcp]ip pool xixi
[dhcp-ip-pool-v1]network 192.168.10.0 mask 24
[dhcp-ip-pool-v1]gateway-list 192.168.10.1
[dhcp]ip pool hehe
[dhcp-ip-pool-v2]network 192.168.20.0 mask 24
[dhcp-ip-pool-v2]gateway-list 192.168.20.1
[dhcp]ip pool haha
[dhcp-ip-pool-haha]network 192.168.2.0 mask 24
[dhcp-ip-pool-haha]gateway-list 192.168.2.1
3)设置子接口
[dhcp]int g0/0/0.1
[dhcp-GigabitEthernet0/0/0.1]dot1q termination vid 10
[dhcp-GigabitEthernet0/0/0.1]ip add 192.168.10.1 24
[dhcp-GigabitEthernet0/0/0.1]arp broadcast enable
[dhcp-GigabitEthernet0/0/0.1]dhcp select global
[dhcp-GigabitEthernet0/0/0.1]int g0/0/0.2
[dhcp-GigabitEthernet0/0/0.2]dot1q termination vid 20
[dhcp-GigabitEthernet0/0/0.2]ip add 192.168.20.1 24
[dhcp-GigabitEthernet0/0/0.2]arp broadcast enable
[dhcp-GigabitEthernet0/0/0.2]dhcp select global
4)设置物理接口
[dhcp]int g0/0/1
[dhcp-GigabitEthernet0/0/1]ip add 192.168.1.1 24
[dhcp-GigabitEthernet0/0/1]dhcp select global
5)设置静态路由
[dhcp]ip route-static 192.168.2.0 24 192.168.1.2
6)配置中继代理服务器
[relay]dhcp enable //启动dhcp服务

[relay]int g0/0/0
[relay-GigabitEthernet0/0/0]ip add 192.168.2.1 24
[relay-GigabitEthernet0/0/0]int g0/0/1
[relay-GigabitEthernet0/0/1]ip add 192.168.1.2 24

[relay]ip route-static 0.0.0.0 0.0.0.0 192.168.1.1 //设置默认路由

[relay]int g0/0/0
[relay-GigabitEthernet0/0/0]dhcp select relay //启用dhcp中继代理模式
[relay-GigabitEthernet0/0/0]dhcp relay server-ip 192.168.1.1 //指定dhcp服务器ip地址
全部配置完之后在PC机的基础配置里ipv4配置dhcp自动获取IP地址选中,点击应用

在命令行里输入“ipconfig”自动获取IP地址



自动获取IP地址的时候也可以抓包看一下“首次接入”的过程

自动获取IP地址后,三台PC机互ping,查看连通性




实验完成