一、单臂路由结构的DHCP
1.启动设备
2.将pc设为DHCP获取IP地址
3.交换机创建vlan并设置模式
[SW1]vlan batch 10 20
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]port link-type access
[SW1-GigabitEthernet0/0/2]port default vlan 10
[SW1-GigabitEthernet0/0/2]int g0/0/3
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 20
4.配置DHCP
[AR1]dhcp enable //启动DHCP服务
[AR1]int g0/0/0.1
[AR1-GigabitEthernet0/0/0.1]dot1q termination vid 10
[AR1-GigabitEthernet0/0/0.1]ip add 192.168.1.1 24
[AR1-GigabitEthernet0/0/0.1]dhcp select global //开启全局模式
[AR1-GigabitEthernet0/0/0.1]arp broadcast enable //开启子接口广播
[AR1-GigabitEthernet0/0/0.1]int g0/0/0.2
[AR1-GigabitEthernet0/0/0.2]dot1q termination vid 20
[AR1-GigabitEthernet0/0/0.2]ip add 192.168.2.1 24
[AR1-GigabitEthernet0/0/0.2]dhcp select global //开启全局模式
[AR1-GigabitEthernet0/0/0.2]arp broadcast enable //开启子接口广播
[AR1-GigabitEthernet0/0/0.2]quit
[AR1]ip pool vlan10 //设置地址池
[AR1-ip-pool-vlan10]network 192.168.1.0 mask 24 //设置地址范围
[AR1-ip-pool-vlan10]gateway-list 192.168.1.1 //设置网关地址
[AR1-ip-pool-vlan10]quit
[AR1]ip pool vlan20 //设置地址池
[AR1-ip-pool-vlan20]network 192.168.2.0 mask 24 //设置地址范围
[AR1-ip-pool-vlan20]gateway-list 192.168.2.1 //设置网关地址
[AR1-ip-pool-vlan20]q
验证:
使用ipconfig查看pc获取到的IP地址
使用pc1ping通192.168.1.1、192.168.2.1、pc2(192.168.2.254)
二、DHCP中继代理
1.启动设备
2.将pc设为DHCP获取IP地址
3.配置交换机
[SW2]vlan batch 10 20 100
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 100
[SW2-GigabitEthernet0/0/1]int g0/0/2
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 10
[SW2-GigabitEthernet0/0/2]int g0/0/3
[SW2-GigabitEthernet0/0/3]port link-type access
[SW2-GigabitEthernet0/0/3]port default vlan 20
[SW2-GigabitEthernet0/0/3]q
[SW2]int Vlanif 10
[SW2-Vlanif10]ip add 192.168.10.1 24
[SW2-Vlanif10]int vl 20
[SW2-Vlanif20]ip add 192.168.20.1 24
[SW2-Vlanif20]int vl 100
[SW2-Vlanif100]ip add 10.10.10.1 30
[SW2-Vlanif100]q
[SW2]ip route-static 0.0.0.0 0.0.0.0 10.10.10.2
[SW1]vlan 100
[SW1-vlan100]q
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 100
[SW1-GigabitEthernet0/0/1]int vl 100
[SW1-Vlanif100]ip add 10.10.10.2 30
[SW1-Vlanif100]q
[SW1]ip route-static 192.168.10.0 255.255.255.0 10.10.10.1
[SW1]ip route-static 192.168.20.0 255.255.255.0 10.10.10.1
4.配置HDCP中继
[SW2]dhcp enable //启动DHCP服务
[SW2]int Vlanif 10
[SW2-Vlanif10]dhcp select relay //启动中继模式
[SW2-Vlanif10]dhcp relay server-ip 10.10.10.2 //设置中继转发服务器地址
[SW2-Vlanif10]int vl 20
[SW2-Vlanif20]dhcp select relay //启动中继模式
[SW2-Vlanif20]dhcp relay server-ip 10.10.10.2 //设置中继转发服务器地址
5.配置DHCP
[SW1]dhcp enable //启动DHCP服务
[SW1]int Vlanif 100
[SW1-Vlanif100]dhcp select global //开启全局模式
[SW1-Vlanif100]q
[SW1]ip pool vlan10 //设置地址池
[SW1-ip-pool-vlan10]network 192.168.10.0 mask 24 //设置地址范围
[SW1-ip-pool-vlan10]gateway-list 192.168.10.1 //设置网关地址
[SW1-ip-pool-vlan10]q
[SW1]ip pool vlan20 //设置地址池
[SW1-ip-pool-vlan20]network 192.168.20.0 mask 24 //设置地址范围
[SW1-ip-pool-vlan20]gateway-list 192.168.20.1 //设置网关地址
验证:
使用ipconfig查看pc是否获得IP地址