DHCP的作用
- 分配IP地址等网络参数,减少管理员的工作量,避免用户手工配置网络参数时造成的地址冲突
- DHCP服务器能够为大量主机分配IP地址,并能够集中管理
DHCP报文类型
DHCP DISCOVER (广播) | 客户端用来寻找DHCP服务器 |
DHCP OFFER (单播) | DHCP服务器用来响应DHCP DISCOVER报文次报文携带了各种配置信息 |
DHCP REQUEST (广播) | 客户端请求配置确认,或者续租 |
DHCP ACK (单播) | 服务器对REQUEST报文的确认响应 |
DHCP NAK | 服务器对REQUEST报文的拒绝响应 |
DHCP RELEASE | 客户端要释放地址时用来通知服务器 |
ARG3系列路由器可以划分 接口地址池 和全局地址池
接口地址池配置的方法
全局地址池配置的方法
DHCP获取IP地址在终端
调试DHCP模式 然后打开ipconfig 命令
ipconfig /renew 获取IP地址
ipconfig /release 释放IP地址
实验例题
先配置路由器
<Huawei>sys [Huawei]sys SW1 [SW1]v b 10 20 [SW1]int e0/0/1 [SW1-Ethernet0/0/1]p l a [SW1-Ethernet0/0/1]p d v 10 [SW1-Ethernet0/0/1]un sh [SW1-Ethernet0/0/1]int e0/0/2 [SW1-Ethernet0/0/2]p l a [SW1-Ethernet0/0/2]p d v 20 [SW1-Ethernet0/0/3]un sh [SW1-Ethernet0/0/2]int e0/0/3 [SW1-Ethernet0/0/3]p l a [SW1-Ethernet0/0/3]p d v 10 [SW1-Ethernet0/0/4]un sh [SW1-Ethernet0/0/2]int e0/0/4 [SW1-Ethernet0/0/3]p l a [SW1-Ethernet0/0/3]p d v 20 [SW1-Ethernet0/0/4]un sh [SW1-Ethernet0/0/4]int g0/0/1 [SW1-GigabitEthernet0/0/1]p l t [SW1-GigabitEthernet0/0/1]p t a v 10 20 [SW1-GigabitEthernet0/0/1]un sh
配置路由器R2
<Huawei>sys [Huawei]sys R2 [R2]dhcp enable [R2]int g0/0/1.10 [R2-GigabitEthernet0/0/1.10]d t v 10 [R2-GigabitEthernet0/0/1.10]ip add 192.168.10.1 24 [R2-GigabitEthernet0/0/1.10]a b e [R2-GigabitEthernet0/0/1.10]dhcp select relay [R2-GigabitEthernet0/0/1.10]dhcp relay server-ip 14.0.0.2 [R2-GigabitEthernet0/0/1.10]int g0/0/1.20 [R2-GigabitEthernet0/0/1.20]d t v 20 [R2-GigabitEthernet0/0/1.20]ip add 192.168.20.1 24 [R2-GigabitEthernet0/0/1.20]a b e [R2-GigabitEthernet0/0/1.20]dhcp select relay [R2-GigabitEthernet0/0/1.20]dhcp relay server-ip 14.0.0.2 [R2-GigabitEthernet0/0/1.10]int g0/0/0 [R2-GigabitEthernet0/0/0]ip add 12.0.0.1 24 [R2-GigabitEthernet0/0/0]un sh [R2-GigabitEthernet0/0/0]int g0/0/2 [R2-GigabitEthernet0/0/2]ip add 14.0.0.1 24 [R2-GigabitEthernet0/0/2]un sh [R2]ip route-static 0.0.0.0 0.0.0.0 12.0.0.2
配置路由器R3
<Huawei>sys [Huawei]sys R3 [R3]dhcp enable [R3]int g0/0/0 [R3-GigabitEthernet0/0/0]ip add 12.0.0.2 24 [R3-GigabitEthernet0/0/0]int g0/0/1 [R3-GigabitEthernet0/0/1]dhcp select relay [R3-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2 [R3]int g0/0/1 [R3-GigabitEthernet0/0/1]ip add 15.0.0.1 24 [R3]ip route-static 192.168.10.0 24 12.0.0.1 [R3]ip route-static 192.168.20.0 24 12.0.0.1 [R3]ip route-static 14.0.0.0 24 12.0.0.1
配置路由器R4
<Huawei>sys [Huawei]sys R4 [R4]dhcp enable [R4]int g0/0/0 [R4-GigabitEthernet0/0/0]ip add 14.0.0.2 24 [R4-GigabitEthernet0/0/0]dhcp select global [R4-GigabitEthernet0/0/0]q [R4]ip route-static 15.0.0.0 24 12.0.0.2 [R4]ip pool DHCP15 [R4-ip-pool-DHCP15]netbios-type [R4-ip-pool-DHCP15]network 15.0.0.0 mask 24 [R4-ip-pool-DHCP15]gateway-list 15.0.0.1 [R4-ip-pool-DHCP15]dns-list 8.8.8.8 2.2.2.2 [R4-ip-pool-DHCP15]ip pool DHCPvlan10 [R4-ip-pool-DHCPvlan10]network 192.168.10.0 mask 24 [R4-ip-pool-DHCPvlan10]gateway-list 192.168.10.1 [R4-ip-pool-DHCPvlan10]dns-list 8.8.8.8 2.2.2.2 [R4-ip-pool-DHCPvlan10]ip pool DHCPvlan20 [R4-ip-pool-DHCPvlan20]network 192.168.20.0 mask 24 [R4-ip-pool-DHCPvlan20]gateway-list 192.168.20.1 [R4-ip-pool-DHCPvlan20]dns-list 8.8.8.8 2.2.2.2 [R4-ip-pool-DHCPvlan20]q [R4]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1