DHCP服务器配置及DHCP客户端动态获取IP

时间:2024-03-28 21:33:04

实验拓扑

DHCP服务器配置及DHCP客户端动态获取IP

实验步骤

[AR1]interface GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0]ip address 10.10.10.1 8 //配置接口IP 

[AR2]interface GigabitEthernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 10.10.10.2 8 //配置接口IP

[AR2]interface GigabitEthernet 0/0/1
[AR2-GigabitEthernet0/0/1]ip address 192.168.1.254 24 //配置接口IP

[AR1]ip pool keke  //建地址池
[AR1-ip-pool-keke]network 192.168.1.0 mask 255.255.255.0 //设置网段
[AR1-ip-pool-keke]gateway-list 192.168.1.254  //设置网关
[AR1-ip-pool-keke]dns-list 8.8.8.8  //设置DNS
[AR1-ip-pool-keke]lease day 6      //租约时间
[AR1-ip-pool-keke]excluded-ip-address 192.168.1.200 192.168.1.253//保留地址

[AR1]dhcp enable //开启DHCP
[AR1]interface GigabitEthernet 0/0/0
[AR1-GigabitEthernet0/0/0]dhcp select global //全局DHCP

[AR2]dhcp enable  //开启DHCP
[AR2]interface GigabitEthernet 0/0/1  
[AR2-GigabitEthernet0/0/1]dhcp select relay //DHCP中继功能
[AR2-GigabitEthernet0/0/1]dhcp relay server-ip 10.10.10.1 //指向DHCP服务器IP

[AR1]ip route-static 192.168.1.0 255.255.255.0 10.10.10.2 //设置静态路由

PC ipconfig /release //释放IP
PC ipconfig /renew   //从新获取IP

实验结果 :  DHCP客户端 通过 DHCP中继  指向  DHCP服务器  所获取的IP