实验环境,如下图。vlan10 ,vlan20 ,vlan30
实验1:为vlan10配置基于接口的DHCP功能,分配的网段默认和网关一样
[LSW4]dhcp enable 首先在全局模式下开启dhcp功能
[LSW4-Vlanif10]dhcp select interface 开启此接口的dhcp服务
[LSW4-Vlanif10]dhcp server dns-list 114.114.114.114 8.8.8.8 配置dns服务
实验2:用全局地址池的方法为vlan20配置DHCP功能
[LSW4]dhcp enable 首先在全局模式下开启dhcp功能
[LSW4]ip pool dhcpv20 创建地址池 取名为dhcpv20
配置地址池:
[LSW4-ip-pool-dhcpv20]network 192.168.20.0 mask 24 指定要分配的网段和子网掩码
[LSW4-ip-pool-dhcpv20]gateway-list 192.168.20.1 为dhcp配置要分配的网关
[LSW4-ip-pool-dhcpv20]dns-list 114.114.114.114 8.8.8.8 配置要分配的DNS
[LSW4-ip-pool-dhcpv20]lease day 9 配置默认租约时间
让vlan20的dhcp使用全局地址池来分配:他会根据网关从多个地址池中选取网关相同的地址池进行分配
[LSW4-Vlanif20]dhcp select global
DHCP的4个报文:
实验3:使用DHCP的中继代理,为vlan20和30分配IP
创建两个地址池:
[AR1]ip pool dhcpv20
[AR1-ip-pool-dhcpv20]network 192.168.2.0 mask 24
[AR1-ip-pool-dhcpv20]gateway-list 192.168.20.1
[AR1-ip-pool-dhcpv20]dns-list 114.114.114.114 8.8.8.8
[AR1-ip-pool-dhcpv20]lease day 9
[AR1]ip pool dhcpv30
[AR1-ip-pool-dhcpv30]network 192.168.30.0 mask 24
[AR1-ip-pool-dhcpv30]gateway-list 192.168.30.1
[AR1-ip-pool-dhcpv30]dns-list 114.114.114.114 8.8.8.8
[AR1-ip-pool-dhcpv30]lease day 9
配置三层交换的DHCP中继
[LSW4-Vlanif20]dhcp select relay 使用中继的方式来获取IP
[LSW4-Vlanif20]dhcp relay server-ip 12.0.0.2 指定dhcp的位置
[LSW4-Vlanif30]dhcp select relay
[LSW4-Vlanif30]dhcp relay server-ip 12.0.0.2
开启路由器的dhcp功能,及dhcp全局地址池的方式
[AR1]dhcp enable
[AR1-GigabitEthernet0/0/0]dhcp select global
实验4:以服务器组的方式让vlan10获得IP
[LSW4]dhcp server group test 为组dhcp组命名为test
[LSW4-dhcp-server-group-test]dhcp-server 12.0.0.2 在组里面添加dhcp服务器,可以添加多个
[LSW4-Vlanif10]dhcp select relay
[LSW4-Vlanif10]dhcp relay server-select test