进阶!中型网络架构DHCP详解、实验步骤
DHCP :
dynamic host configuration protocol
动态 主机 配置 协议
-动态的为主机配置IP地址等相关信息;
DHCP 定义:动态主机配置协议;
DHCP 作用:
对大量的终端主机,实现IP地址自动配置以及集中管理;
节省了工作量,降低了人为配置错误;
DHCP工作过程:
-设备角色
- DHCP服务器
-
DHCP客户端
-工作原理:
1.DHCP客户端发送 discover 报文;广播方式;
2.DHCP服务器接收以后,返回一个 offer 报文;广播方式;
3.DHCP客户端发送 request 报文;广播方式;
4.DHCP服务器接收以后,返回一个 ack 报文;广播方式;
DHCP的配置思路:
1.配置 DHCP 客户端
2.配置 DHCP 服务器
#开启 DHCP 功能
[R2] dhcp enable
#创建 DHCP 地址池
*全局的地址池
[R2] ip pool ABC
[R2-ip-pool-ABC] network 192.168.1.0 mask 255.255.255.0
[R2-ip-pool-ABC] gateway-list 192.168.1.254
[R2-ip-pool-ABC] dns-list 8.8.8.8
#确定 DHCP 选择模式
-需要在接收 DHCP 客户端发送来的报文的端口上配置;
-命令:
[R2]interface gi0/0/0
[R2-gi0/0/0] dhcp select global ->从这个接口上
收到的 DHCP 请求,都直接在本地设备的
地址池( ip pool ) 中拿地址用;
DHCP服务器配置:接口地址池
#开启 DHCP 功能
[R2] dhcp enable
#创建 DHCP 地址池 :
接口的地址池
-使用接收 DHCP 报文的那个端口的IP地址
所在的网段,当做 DHCP 客户端所要的IP
地址空间;
-配置命令:
interface gi0/0/0
dhcp server dns-list 8.8.8.8
#确定 DHCP 选择模式
当我们在 DHCP 服务器上配置的地址池是
属于“接口类型”的时候,我们在“接收DHCP
报文”的端口上的 DHCP 选择模式,应该按
照如下命令配置:
interface gi0/0/0
dhcp select interface
========================================================
DHCP中继:
当DHCP客户端 与 DHCP 服务器不在同一个网段的时候,
我们需要配置 DHCP 中继;
并且一般情况下,是在一个 VLAN 的网关接口下配置的;
配置命令:
-启用 DHCP 功能;
dhcp enable
-配置 DHCP 中继 (网关接口下)
interface vlanif 10
ip address 192.168.1.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.12.2
- 创建交换机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 19创建交换机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 242.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
最后用主机分配获取ip验证实验
转载于:https://blog.51cto.com/13698450/2115372