前言
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途:给内部网络或网络服务供应商自动分配IP地址,给用户或者内部网络管理员作为对所有计算机作中央管理的手段
一:实验环境
1.1:基本原理
# 第一步:客户端通过广播发送DHCP Discover 报文寻找服务器端
# 第二步:服务器通过单播发送dhcp向客户端提供ip地址
# 第三步:客户端通过广播DHCP Request 报文告知服务器端本地选择IP
# 第四步 :服务器通过DHCP Ack报文告知客户端IP地址是合法可用的
1.2:实验目的
通过路由器DHCP自动分配地址
实现不同vlan 主机之间互联互通
1.3 华为DHCP实验拓扑图
二:实验过程
2.1:交换机sw1设置
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW1
[SW1]V B 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[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
Info: Interface Ethernet0/0/1 is not shutdown.
[SW1]int e0/0/2
[SW1-Ethernet0/0/2]p l a
[SW1-Ethernet0/0/2]p d v 20
[SW1-Ethernet0/0/2]un sh
Info: Interface Ethernet0/0/2 is not shutdown.
[SW1]int e0/0/3
[SW1-Ethernet0/0/3]p l a
[SW1-Ethernet0/0/3]p d v 10
[SW1-Ethernet0/0/3]un sh
Info: Interface Ethernet0/0/3 is not shutdown.
[SW1]int e0/0/4
[SW1-Ethernet0/0/4]p l a
[SW1-Ethernet0/0/4]p d v 20
[SW1-Ethernet0/0/4]un sh
Info: Interface Ethernet0/0/4 is not shutdown.
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]p l t
[SW1-GigabitEthernet0/0/1]p t a v a
[SW1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
2.2路由器R1
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]int g0/0/1.1
[R1-GigabitEthernet0/0/1.1]dot1q termination vid 10
[R1-GigabitEthernet0/0/1.1]ip add 192.168.10.1 24
[R1-GigabitEthernet0/0/1.1]a b e
[R1-GigabitEthernet0/0/1.1]dhcp select relay
[R1-GigabitEthernet0/0/1.1]dhcp relay server-ip 13.0.0.2
[R1-GigabitEthernet0/0/1.1]un sh
Info: Interface GigabitEthernet0/0/1.1 is not shutdown.
[R1]int g0/0/1.2
[R1-GigabitEthernet0/0/1.2]
[R1-GigabitEthernet0/0/1.2]dot1q termination vid 20
[R1-GigabitEthernet0/0/1.2]ip add 192.168.20.1 24
[R1-GigabitEthernet0/0/1.2]arp broadcast enable
[R1-GigabitEthernet0/0/1.2]dhcp select relay
[R1-GigabitEthernet0/0/1.2]dhcp relay server-ip 13.0.0.2
[R1-GigabitEthernet0/0/1.2]un sh
Info: Interface GigabitEthernet0/0/1.2 is not shutdown.
R1]ip route-static 15.0.0.1 24 12.0.0.2
2.3 路由器R3
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn
[Huawei]sysname R3
[R3]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 13.0.0.2 24
[R3-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[R3]ip pool 15
[R3-ip-pool-15]gateway-list 15.0.0.1
[R3-ip-pool-15]network 15.0.0.0 mask 24
[R3-ip-pool-15]dns-list 8.8.8.8 2.2.2.2
[R3]ip pool v10
[R3-ip-pool-v10]network 192.168.10.0 mask 24
[R3-ip-pool-v10]gateway-list 192.168.10.1
[R3-ip-pool-v10]dns-list 8.8.8.8 2.2.2.2
[R3]ip pool v20
[R3-ip-pool-v20]network 192.168.20.0 mask 24
[R3-ip-pool-v20]gateway-list 192.168.20.1
[R3-GigabitEthernet0/0/2]dhcp select global
[R3-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[R3]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1
2.4路由器R2
<Huawei>sys
[Huawei]sysname R2
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]UN SH
Info: Interface GigabitEthernet0/0/0 is not shutdown.
R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R2-GigabitEthernet0/0/1]un sh
[R2-GigabitEthernet0/0/1]dhcp select global
[R2-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2
[R2]ip route-static 14.0.0.0 255.255.255.0 12.0.0.1
[R2]ip route-static 192.168.10.0 255.255.255.0 12.0.0.1
[R2]ip route-static 192.168.20.0 255.255.255.0 12.0.0.1
三:实验结果
dhcp分配给每人客户机地址并全网通