一.分配相同網絡的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地址必須創建一個地址池。
並且一個地址池只能保留一個!