一、 DHCP:动态主机配置协议
1. 作用:实现企业大量主机IP的动态配置和集中管理。减少工作量,减少人为配置错误。
2. DHCP工作原理:
a) 发现阶段---发送DHCP discover 报文
b) 提供阶段---服务器回应offer
c) 选择阶段----发送request请求 报文
d) 确认阶段---服务器回应 ack确认
二、DHCP中继:当DHCP客户端 与 DHCP 服务器不在同一个网段的时候,我们需要配置 DHCP 中继
DHCP中继实例
实验准备:
- 设备:路由器一台 三层交换机一台 三个PC分属不同的VLAN
- 交换机创建VLAN 20 30 40 88,将端口加入所属VLAN
- 主机ip配置为DHCP
实验目的:实现主机通过DHCP获取IP地址;同时实现不同VLAN主机通信。
实现步骤:
创建交换机VLAN,同时将端口加入到相应的VLAN中
[H1]vlan batch 20 30 40 88
[H1]port-group group-member Gi 0/0/1 to gi 0/0/4
[H1-port-group]port link-type access
[H1-GigabitEthernet0/0/1]port default vlan 88
[H1-GigabitEthernet0/0/2]port default vlan 20
[H1-GigabitEthernet0/0/3]port default vlan 30
[H1-GigabitEthernet0/0/4]port default vlan 40
Dhcp服务器开启dhcp,创建三个 地址池
[R1]dhcp enable
[R1]ip pool 20
[R1-ip-pool-20]network 192.168.20.0 mask 255.255.255.0
[R1-ip-pool-20]gateway-list 192.168.20.254
[R1-ip-pool-20]dns-list 8.8.8.8
[R1]ip pool 30
[R1-ip-pool-30]network 192.168.30.0 mask 255.255.255.0
[R1-ip-pool-30]gateway-list 192.168.30.254
[R1-ip-pool-30]dns-list 8.8.8.8
[R1]ip pool 40
[R1-ip-pool-40]network 192.168.40.0 mask 255.255.255.0
[R1-ip-pool-40]gateway-list 192.168.40.254
[R1-ip-pool-40]dns-list 8.8.8.8
[R1-GigabitEthernet0/0/0]ip add 192.168.88.1 24
[R1-GigabitEthernet0/0/0]dhcp select global
把VLAN加IP,设置DHCP中继模式
[H1]int vlan 20
[H1-Vlanif20]ip add 192.168.20.254 24
[H1-Vlanif20]dhcp select relay
[H1-Vlanif20]dhcp relay server-ip 192.168.88.1
[H1-Vlanif30] ip add 192.168.30.254 24
[H1-Vlanif30]dhcp select relay
[H1-Vlanif30]dhcp relay server-ip 192.168.88.1
[H1-Vlanif40]ip address 192.168.40.254 24
[H1-Vlanif40]dhcp select relay
[H1-Vlanif40]dhcp relay server-ip 192.168.88.1
[H1-Vlanif88]ip add 192.168.88.254 24
实验验证一:
打开pc1 pc2 pc3 运行:ipconfig:查看地址获取情况
实验验证二:验证主机间通信
原文地址:http://blog.51cto.com/8149087/2114163