ensp练习:DHCP服务配置(1、接口地址池配置2、全局地址池配置)
**
ensp练习:DHCP服务配置(1、接口地址池配置2、全局地址池配置)
**
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途:
一、给内部网络或网络服务供应商自动分配IP地址。
二、给用户或者内部网络管理员作为对所有计算机作中央管理的手段。
1、接口地址池配置
接口地址池就是给端口配置IP然后这个IP作为网关使用,这个端口下面的PC都可以DHCP分配到IP地址。
实验拓扑:
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sy
[Huawei]sysname R1 #更改设备名
[R1]dhcp enable #开启DHCP服务
[R1]interface e0/0/0
[R1-Ethernet0/0/0]ip ad
[R1-Ethernet0/0/0]ip address 192.168.1.254 24 #给端口添加IP地址
[R1-Ethernet0/0/0]di th
interface Ethernet0/0/0
ip address 192.168.1.254 255.255.255.0
return
[R1-Ethernet0/0/0]undo shutdown
Info: Interface Ethernet0/0/0 is not shutdown.
[R1-Ethernet0/0/0]dhcp select interface #在端口开启DHCP服务
[R1-Ethernet0/0/0]dhcp server dns-list 192.168.1.254
[R1-Ethernet0/0/0]dhcp server excluded-ip-address 192.168.1.1 #不分配这个IP
[R1-Ethernet0/0/0]dhcp server lease day 3 #有效期三天
[R1-Ethernet0/0/0]di th
interface Ethernet0/0/0
ip address 192.168.1.254 255.255.255.0
dhcp select interface
dhcp server excluded-ip-address 192.168.1.1
dhcp server lease day 3 hour 0 minute 0
dhcp server dns-list 192.168.1.254
return
配置已经完成,下面来看一下是否成功。
二、全局地址池配置
全局地址池就是可以给任何接口地址提供DHCP服务,同时你可以创建多个全局地址池使用,其中全局地址池网段与端口IP是同一网段的对应关系,实现自动获取IP的作用。
实验拓扑:
sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sy
[Huawei]sysname R1
[R1]int e0/0/0
[R1-Ethernet0/0/0]ip ad
[R1-Ethernet0/0/0]ip address 192.168.10.254 24
[R1-Ethernet0/0/0]di th
interface Ethernet0/0/0
ip address 192.168.10.254 255.255.255.0
return
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]ip pool
[R1]ip pool LSW1
[R1-ip-pool-LSW1]network 192.168.10.0 mask 24
[R1-ip-pool-LSW1]gateway-list 192.168.10.254
[R1-ip-pool-LSW1]lease day 3
[R1-ip-pool-LSW1]di th
ip pool LSW1
gateway-list 192.168.10.254
network 192.168.10.0 mask 255.255.255.0
lease day 3 hour 0 minute 0
return
[R1-ip-pool-LSW1]q
[R1]int
[R1]interface e0/0/0
[R1-Ethernet0/0/0]dhcp select global
[R1-Ethernet0/0/0]q
完成第一个192.168.10.0网段的全局地址池配置,下面进行第二10.1.1.0网段的全局地址池配置。
[R1]int e0/0/1
[R1-Ethernet0/0/1]
[R1-Ethernet0/0/1]ip ad
[R1-Ethernet0/0/1]ip address 10.1.1.254 24
[R1-Ethernet0/0/1]q
[R1]ip pool LSW2
Info:It’s successful to create an IP address pool.
[R1-ip-pool-LSW2]network 10.1.1.0 mask 24
[R1-ip-pool-LSW2]gateway-list 10.1.1.254
[R1-ip-pool-LSW2]lease day 3
[R1-ip-pool-LSW2]di th
ip pool LSW2
gateway-list 10.1.1.254
network 10.1.1.0 mask 255.255.255.0
lease day 3 hour 0 minute 0
return
[R1-ip-pool-LSW2]q
[R1]int e0/0/1
[R1-Ethernet0/0/1]dhcp select global
[R1-Ethernet0/0/1]q
好的现在两个地址池都配置好,现在pc进行DHCP服务获取IP。
现在PC可以获取IP,而且获取的都是指定的地址池IP。
检查两个池是否能ping通:
可以通,实验结束。