一.分配相同网络的ip地址
实验目的:通过wang1对pc机和wang2分配不同网段的ip地址!
配置wang1为DHCP服务器
[H3C]sys wang1
[wang1]dhcp enable //开启DHCP服务功能
DHCP is enabled successfully!
[wang1]dhcp server ip-pool ? //创建地址池,最多能创建35个地址池!
STRING<1-35> Pool name
[wang1]dhcp server ip-pool wnt //创建地址池
[wang1-dhcp-pool-wnt]network 192.168.1.1
INTEGER<1-30> Subnet mask length
mask Specify a subnet mask
<cr>
[wang1-dhcp-pool-wnt]network 192.168.1.0 24 //分配的ip地址网络
[wang1-dhcp-pool-wnt]gateway-list 192.168.1.254 //网关
[wang1-dhcp-pool-wnt]dns-list 202.102.152.3 //DNS服务器
[wang1-dhcp-pool-wnt]expired ? //租约时间
day Expired days ----------------------》设置租约时间
unlimited Unlimited lease--------------------->设置租约时间为永久
[wang1-dhcp-pool-wnt]expired unlimited
[wang1-dhcp-pool-wnt]q
配置保留地址的地址池
[H3C]dhcp server ip-pool wntbao //创建保留ip地址池[高1]
[H3C-dhcp-pool-wntbao]static-bind mac-address 20CF-3000-476A
[H3C-dhcp-pool-wntbao]static-bind ip-address 192.168.1.177
[wang1]dhcp server forbidden-ip 192.168.1.254 //配置排除的地址池
[wang1]dhcp server forbidden-ip 192.168.1.1 192.168.1.5 //排除一段地址
配置2网段分配的ip地址!
[wang1]dhcp server ip-pool 2
[wang1-dhcp-pool-2]network 192.168.2.0 24
[wang1-dhcp-pool-2]gateway-list 192.168.2.254
[wang1-dhcp-pool-2]dns-list 202.102.128.68
[wang1-dhcp-pool-2]expired day 30 hour 10 minute 10
[wang1-dhcp-pool-2]q
[wang1]dhcp server forbidden-ip 192.168.2.254
[wang1]dhcp server forbidden-ip 192.168.2.1 192.168.2.1
[wang1]display dhcp server forbidden-ip //查看排除的地址范围
IP Range from 192.168.1.1 to 192.168.1.5
IP Range from 192.168.1.254 to 192.168.1.254
IP Range from 192.168.2.1 to 192.168.2.1
IP Range from 192.168.2.254 to 192.168.2.254
设置ip地址---实现地址分配
[wang1]int e0/1
[wang1-Ethernet0/1]ip add 192.168.2.254 24
[wang1]int e0/0
[wang1-Ethernet0/0]ip add 192.168.1.254 24
Pc机尝试获取ip地址
[wang1]display dhcp server ip-in-use all //查看已经获取的ip地址
Global pool:
IP address Client-identifier/ Lease expiration Type
Hardware address
192.168.1.177 20cf-3000-476a Unlimited Auto:COMMITTED
--- total 1 entry ---
Wang2尝试获取ip地址
[wang2]int e0/1
[wang2-Ethernet0/1]ip ad
[wang2-Ethernet0/1]ip address ?
X.X.X.X IP address
bootp-alloc IP address negotiated with BOOTP
dhcp-alloc IP address negotiated with DHCP
[wang2-Ethernet0/1]ip address dh
[wang2-Ethernet0/1]ip address dhcp-alloc ?
client-identifier Fill client-identifier of DHCP client with hardware
address
<cr>
[wang2-Ethernet0/1]ip address dhcp-alloc
二.分配不同网段的ip地址
使能DHCP
[Router] dhcp enable
配置DHCP服务器组中DHCP服务器的IP地址
[Router] dhcp relay server-group group-id ip ip-address
配置接口工作在DHCP中继模式
[Router-Ethernet1/1] dhcp select relay
配置接口与DHCP组关联
[Router-Ethernet1/1] dhcp relay server-select group-id
此处与win2003和Cisco不同。要想保留ip地址必须创建一个地址池。
并且一个地址池只能保留一个!