DHCP及相关企业拓扑
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了DHCP及相关企业拓扑相关的知识,希望对你有一定的参考价值。
DHCP
Dynamic host configuration protocol 动态主机配置协议
一、为什么会有dhcp
在现在的企业网络中,有大量的主机或设备需要获取ip地址,如果使用手工配置,工作量大、容易出错且不好管理;如果采用用户擅自更改,还有可能会造成ip地址冲突等问题。
因此,使用DHCP来分配ip地址等网络参数,可以减少管理员的工作量,避免出错
二、作用:
用于实现企业用户ip地址的动态分配和集中管理,避免繁琐的手工配置,快速适应网络的变化
三、角色:
DHCP客户端:通过dhcp协议请求获取ip地址的设备,例如pc,手机,ip电话
DHCP服务器:负责为DHCP客户端分配网络参数的设备
DHCP中继:负责转发DHCP服务器和DHCP客户端之间的DHCP报文,协助DHCP服务器向DHCP客户端动态分配网络参数的设备
四、工作过程:
(1)首次接入
(2)地址重用
(3)更新租期
前提:
PC机开启DHCP
方法一:
基于全局的dhcp(路由器):
1.开启dhcp
[Huawei]dhcp enable
2.建立地址池abc
[Huawei]ip pool abc
3.设置网段,网关,dns地址
[Huawei-ip-pool-abc]network 192.168.2.0 mask 255.255.255.0
[Huawei-ip-pool-abc]gateway-list 192.168.2.254
[Huawei-ip-pool-abc]dns-list 1.1.1.1
[Huawei-ip-pool-abc]q
4.进入接口配置ip
[Huawei]interface gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.2.254 24
5.dhcp选择全局模式
[Huawei-GigabitEthernet0/0/0]dhcp select global
方法二:基于接口的dhcp:
PC机开启DHCP
路由器:
1.开启dhcp [Huawei]dhcp enable
2.进入接口配置ip
[Huawei]interface gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.254 24
3.让dhcp选择接口模式
[Huawei-GigabitEthernet0/0/0]dhcp select interface
4.设置dns地址
[Huawei-GigabitEthernet0/0/0]dhcp server dns-list 1.2.3.0
五:实验
实验1:交换机充当server服务器
PC5:VLAN10
PC6:VLAN 20
[Huawei]dhcp enable
[Huawei]vlan batch 10 20
[Huawei]interface gi0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ip pool abc
[Huawei-ip-pool-abc]network 192.168.1.0 mask 255.255.255.0
[Huawei-ip-pool-abc]gateway-list 192.168.1.254
[Huawei-ip-pool-abc]dns-list 1.1.1.1
[Huawei-ip-pool-abc]q
[Huawei]interface vlanif 10
[Huawei-Vlanif10]ip add 192.168.1.254 24
[Huawei-Vlanif10]dhcp select global
PC6再设一个地址池
[Huawei]ip pool bcd
[Huawei-ip-pool-bcd]network 192.168.2.0 mask 255.255.255.0
[Huawei-ip-pool-bcd]gateway-list 192.168.2.254
[Huawei-ip-pool-bcd]dns-list 1.1.1.1
[Huawei-ip-pool-bcd]q
[Huawei]interface gi0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 20
[Huawei-GigabitEthernet0/0/2]q
[Huawei]interface vlanif 20
[Huawei-Vlanif20]ip add 192.168.2.254 24
[Huawei-Vlanif20]dhcp select global
将PC5 PC6设置好自动获取dhcp
验证:
实验二:路由充当server服务器,通过一个路由器来配置ip
[AR14]interface gi0/0/0
[AR14-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[AR14-GigabitEthernet0/0/0]q
[AR14]dhcp enable
[AR14]ip pool abc
[AR14-ip-pool-abc]network 192.168.1.0 mask 255.255.255.0
[AR14-ip-pool-abc]gateway-list 192.168.1.254
[AR14-ip-pool-abc]dns-list 1.1.1.1
[AR14-ip-pool-abc]q
[AR14]interface gi0/0/0
[AR14-GigabitEthernet0/0/0]dhcp select global
[AR14-GigabitEthernet0/0/0]q
[AR14]ip route-static 192.168.1.0 24 192.168.2.1
[AR15]interface gi0/0/1
[AR15-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[AR15-GigabitEthernet0/0/1]q
[AR15]interface gi 0/0/0
[AR15-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[AR15-GigabitEthernet0/0/0]q
[AR15]dhcp enable
[AR15]inter gi0/0/0
[AR15-GigabitEthernet0/0/0]dhcp select relay
[AR15-GigabitEthernet0/0/0]dhcp relay server-ip 192.168.2.2
验证:
实验三:路由器充当server服务器,中间通过交换机分配
AR17:
[Huawei]dhcp enable
[Huawei]interface gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.20.2 24
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ip pool v17
Info: It‘s successful to create an IP address pool.
[Huawei-ip-pool-v17]network 192.168.17.0 mask 255.255.255.0
[Huawei-ip-pool-v17]gateway-list 192.168.17.254
[Huawei-ip-pool-v17]dns-list 1.1.1.1
[Huawei-ip-pool-v17]q
[Huawei]interface gi 0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.20.1
LW4:
[Huawei]dhcp enable
[Huawei]vlan batch 17 to 20
[Huawei]interface gi0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 17
[Huawei-GigabitEthernet0/0/1]q
[Huawei]interface vlanif 17
[Huawei-Vlanif17]ip add 192.168.17.254 24
[Huawei-Vlanif17]dhcp select relay
[Huawei-Vlanif17]dhcp relay server-ip 192.168.20.2
[Huawei-Vlanif17]q
[Huawei]interface gi 0/0/4
[Huawei-GigabitEthernet0/0/4]port link-type access
[Huawei-GigabitEthernet0/0/4]port default vlan 20
[Huawei-GigabitEthernet0/0/4]q
[Huawei]interface vlanif 20
[Huawei-Vlanif20]ip add 192.168.20.1 24
vlan18 19步骤同上,此实验要设置四个vlan,三个地址池,每个地址池名字都不同,配置好后三台pc可连通
以上是关于DHCP及相关企业拓扑的主要内容,如果未能解决你的问题,请参考以下文章