交換機基于全局地址池作為DHCP服務器
組網圖形

DHCP服務器簡介
- 通常用戶希望網絡中的每臺終端能夠動態獲取IP地址、DNS服務器的IP地址、路由信息、網關信息等網絡參數,不需要手動配置終端的IP地址等網絡參數;另外,針對一些移動終端(手機、ipad、辦公筆記本等)希望能夠即插即用,不需要每次修改終端的IP等網絡參數。如果用戶網絡中有這些需求,就可以在匯聚層的用戶網關設備或核心層設備上配置DHCP服務器功能,來給終端分配IP地址等網絡參數。
- 動態主機配置協議DHCP(Dynamic Host Configuration Protocol)采用客戶端/服務器模式對用戶的網絡參數進行動態配置和集中管理。其中,DHCP服務器通過地址池為用戶分配IP地址等網絡參數。地址池分為接口地址池和全局地址池兩種。
- 接口地址池(詳情見)配置方式簡單,只能用于用戶與DHCP服務器在同一個網段的場景,并且只能給對應接口下的用戶分配IP地址等網絡參數;適用于設備數量有限、配置以及維護量可控的小型網絡。在用戶網關設備上配置基于接口地址池的DHCP服務器功能之后,對應接口下的固定主機、移動終端等都可以自動獲取IP地址等網絡參數,不需要用戶手動配置修改。
- 與接口地址池相比,全局地址池可應用于大型網絡,推薦在核心層設備上配置基于全局地址池的DHCP服務器功能或在服務器區域搭建一臺專門的DHCP服務器統一分配IP地址等網絡參數,而用戶網關設備上只需要啟用簡單的DHCP中繼功能(詳情見)即可。
組網需求
- 如圖1所示,某企業有兩個辦公室,為了節省資源,兩個辦公室內的主機由Switch作為DHCP服務器統一分配IP地址。辦公室1所屬的網段為10.1.1.0/25,主機都加入VLAN10,地址租期為10天;辦公室2所屬的網段為10.1.1.128/25,主機都加入VLAN11,地址租期為2天。
配置思路
- 通過在Switch上配置DHCP服務器,實現為企業的兩個辦公室內終端動態分配IP地址和DNS服務器地址。其中,網段10.1.1.0/25內PC為辦公室1員工辦公終端,IP地址租期配置為10天;網段10.1.1.128/25內PC為辦公室2員工辦公終端,IP地址租期配置為2天。
操作步驟
- 1.使能DHCP服務
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] dhcp enable
- 2.配置接口加入VLAN
# 配置GE0/0/1接口加入VLAN10。
[Switch] vlan batch 10 to 11 [Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] port link-type hybrid [Switch-GigabitEthernet0/0/1] port hybrid pvid vlan 10 [Switch-GigabitEthernet0/0/1] port hybrid untagged vlan 10 [Switch-GigabitEthernet0/0/1] quit
# 配置GE0/0/2加接口入VLAN11。
[Switch] interface gigabitethernet 0/0/2 [Switch-GigabitEthernet0/0/2] port link-type hybrid [Switch-GigabitEthernet0/0/2] port hybrid pvid vlan 11 [Switch-GigabitEthernet0/0/2] port hybrid untagged vlan 11 [Switch-GigabitEthernet0/0/2] quit
- 3.配置VLANIF接口IP地址
# 配置VLANIF10接口地址。
[Switch] interface vlanif 10 [Switch-Vlanif10] ip address 10.1.1.1 25 [Switch-Vlanif10] quit
# 配置VLANIF11接口地址。
[Switch] interface vlanif 11 [Switch-Vlanif11] ip address 10.1.1.129 25 [Switch-Vlanif11] quit
- 4.配置全局地址池
# 配置全局地址池pool1中的IP地址池和相關網絡參數。
[Switch] ip pool pool1 [Switch-ip-pool-pool1] network 10.1.1.0 mask 255.255.255.128 [Switch-ip-pool-pool1] dns-list 10.1.2.3 [Switch-ip-pool-pool1] gateway-list 10.1.1.1 [Switch-ip-pool-pool1] lease day 10 [Switch-ip-pool-pool1] quit
# 配置全局地址池pool2中的IP地址池和相關網絡參數。
[Switch] ip pool pool2 [Switch-ip-pool-pool1] network 10.1.1.128 mask 255.255.255.128 [Switch-ip-pool-pool1] dns-list 10.1.2.3 [Switch-ip-pool-pool1] gateway-list 10.1.1.129 [Switch-ip-pool-pool1] lease day 2 [Switch-ip-pool-pool1] quit
- 5.使能DHCP服務器。
# 在Vlanif10接口下使能DHCP服務器。
[Switch] interface vlanif 10 [Switch-Vlanif10] dhcp select global [Switch-Vlanif10] quit
# 在Vlanif11接口下使能DHCP服務器。
[Switch] interface vlanif 11 [Switch-Vlanif11] dhcp select global [Switch-Vlanif11] quit
- 6.驗證配置結果
# 在Switch上執行命令display ip pool name pool1來查看全局地址池pool1的分配情況,“Used”字段顯示已經分配出去的IP地址數量。
[Switch] display ip pool name pool1
Pool-name : pool1
Pool-No : 0
Lease : 10 Days 0 Hours 0 Minutes
Domain-name : -
DNS-server0 : 10.1.2.3
NBNS-server0 : -
Netbios-type : -
Position : Local
Status : Unlocked
Gateway-0 : 10.1.1.1
Network : 10.1.1.0
Mask : 255.255.255.128
VPN instance : --
Logging : Disable
Conflicted address recycle interval: -
Address Statistic: Total :125 Used :2
Idle :123 Expired :0
Conflict :0 Disabled :0
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
10.1.1.1 10.1.1.126 125 2 123(0) 0 0
-------------------------------------------------------------------------------
# 在Switch上執行命令display ip pool name pool2來查看全局地址池pool2的分配情況,“Used”字段顯示已經分配出去的IP地址數量。
[Switch] display ip pool name pool2
Pool-name : pool2
Pool-No : 1
Lease : 2 Days 0 Hours 0 Minutes
Domain-name : -
DNS-server0 : 10.1.2.3
NBNS-server0 : -
Netbios-type : -
Position : Local
Status : Unlocked
Gateway-0 : 10.1.1.129
Network : 10.1.1.128
Mask : 255.255.255.128
VPN instance : --
Logging : Disable
Conflicted address recycle interval: -
Address Statistic: Total :125 Used :2
Idle :123 Expired :0
Conflict :0 Disabled :0
-------------------------------------------------------------------------------
Network section
Start End Total Used Idle(Expired) Conflict Disabled
-------------------------------------------------------------------------------
10.1.1.129 10.1.1.254 125 2 123(0) 0 0
-------------------------------------------------------------------------------
********** 如果您認為這篇文章還不錯或者有所收獲,請點擊右下角的【推薦】/【贊助】按鈕,因為您的支持是我繼續創作分享的最大動力! **********
作者:講文張字
出處:http://www.rzrgm.cn/zhangwencheng
版權:本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出 原文鏈接
出處:http://www.rzrgm.cn/zhangwencheng
版權:本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出 原文鏈接
浙公網安備 33010602011771號