**
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通:
可以通,實驗結束。