wKioL1j2-BCz8HhlAADH2rI0oIQ344.png

一、首先PC需要启用DHCP获取IP地址


二、配置路由器的接口IP


三、配置DHCP server


R1(中继)配置如下:

dhcp enable


interface GigabitEthernet0/0/0

 ip address 10.1.1.254 255.255.255.0 

 dhcp select relay

 dhcp relay server-ip 12.1.1.2


interface GigabitEthernet0/0/1

 ip address 12.1.1.1 255.255.255.0   #和服务器相连接口的IP,同一网段


interface GigabitEthernet0/0/2

 ip address 20.1.1.254 255.255.255.0 

 dhcp select relay

 dhcp relay server-ip 12.1.1.2


R2(服务器)配置如下:

dhcp enable


ip pool 10

 gateway-list 10.1.1.254 

 network 10.1.1.0 mask 255.255.255.0 

 static-bind ip-address 10.1.1.10 mac-address 5489-984d-804d   #PC4的IP和MAC地址绑定

 dns-list 10.10.10.10 


ip pool 20

 gateway-list 20.1.1.254 

 network 20.1.1.0 mask 255.255.255.0 


interface GigabitEthernet0/0/1

 ip address 12.1.1.2 255.255.255.0 

 dhcp select global


ip route-static 10.1.1.0 255.255.255.0 12.1.1.1

ip route-static 20.1.1.0 255.255.255.0 12.1.1.1


dis ip routing-table查看配置的两条路由

wKioL1j2_ALhLQSIAABWgoiN14k997.pngdis ip pool name 10 used查看地址池10已用的IP地址

wKiom1j2_OiAAeEjAABNOVxApYY353.png

结果验证:

wKioL1j2-2zC_gMUAACxNLRcA8U967.png

wKiom1j2-27j597uAAEMj-Rd6pQ446.png