1. 程式人生 > >DHCP及相關企業拓撲

DHCP及相關企業拓撲

dhcp 及實驗

DHCP

Dynamic host configuration protocol 動態主機配置協議

一、為什麽會有dhcp

在現在的企業網絡中,有大量的主機或設備需要獲取ip地址,如果使用手工配置,工作量大、容易出錯且不好管理;如果采用用戶擅自更改,還有可能會造成ip地址沖突等問題。
因此,使用DHCP來分配ip地址等網絡參數,可以減少管理員的工作量,避免出錯

二、作用:

用於實現企業用戶ip地址的動態分配和集中管理,避免繁瑣的手工配置,快速適應網絡的變化

三、角色:

DHCP客戶端:通過dhcp協議請求獲取ip地址的設備,例如pc,手機,ip電話
DHCP服務器:負責為DHCP客戶端分配網絡參數的設備

DHCP中繼:負責轉發DHCP服務器和DHCP客戶端之間的DHCP報文,協助DHCP服務器向DHCP客戶端動態分配網絡參數的設備

四、工作過程:

(1)首次接入
技術分享圖片
(2)地址重用
技術分享圖片
(3)更新租期
技術分享圖片
前提:
PC機開啟DHCP
技術分享圖片

方法一:
基於全局的dhcp(路由器):
1.開啟dhcp
[Huawei]dhcp enable
2.建立地址池abc
[Huawei]ip pool abc
3.設置網段,網關,dns地址
[Huawei-ip-pool-abc]network 192.168.2.0 mask 255.255.255.0
[Huawei-ip-pool-abc]gateway-list 192.168.2.254
[Huawei-ip-pool-abc]dns-list 1.1.1.1

[Huawei-ip-pool-abc]q
4.進入接口配置ip
[Huawei]interface gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.2.254 24
5.dhcp選擇全局模式
[Huawei-GigabitEthernet0/0/0]dhcp select global
方法二:基於接口的dhcp:
PC機開啟DHCP
路由器:
1.開啟dhcp [Huawei]dhcp enable
2.進入接口配置ip
[Huawei]interface gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.254 24
3.讓dhcp選擇接口模式
[Huawei-GigabitEthernet0/0/0]dhcp select interface
4.設置dns地址
[Huawei-GigabitEthernet0/0/0]dhcp server dns-list 1.2.3.0

五:實驗

實驗1:交換機充當server服務器
技術分享圖片
PC5:VLAN10
PC6:VLAN 20
[Huawei]dhcp enable
[Huawei]vlan batch 10 20
[Huawei]interface gi0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]q
[Huawei]ip pool abc
[Huawei-ip-pool-abc]network 192.168.1.0 mask 255.255.255.0
[Huawei-ip-pool-abc]gateway-list 192.168.1.254
[Huawei-ip-pool-abc]dns-list 1.1.1.1
[Huawei-ip-pool-abc]q
[Huawei]interface vlanif 10
[Huawei-Vlanif10]ip add 192.168.1.254 24
[Huawei-Vlanif10]dhcp select global

PC6再設一個地址池
[Huawei]ip pool bcd
[Huawei-ip-pool-bcd]network 192.168.2.0 mask 255.255.255.0
[Huawei-ip-pool-bcd]gateway-list 192.168.2.254
[Huawei-ip-pool-bcd]dns-list 1.1.1.1
[Huawei-ip-pool-bcd]q
[Huawei]interface gi0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 20
[Huawei-GigabitEthernet0/0/2]q
[Huawei]interface vlanif 20
[Huawei-Vlanif20]ip add 192.168.2.254 24
[Huawei-Vlanif20]dhcp select global
將PC5 PC6設置好自動獲取dhcp
驗證:技術分享圖片

實驗二:路由充當server服務器,通過一個路由器來配置ip
技術分享圖片
[AR14]interface gi0/0/0
[AR14-GigabitEthernet0/0/0]ip add 192.168.2.2 24
[AR14-GigabitEthernet0/0/0]q
[AR14]dhcp enable
[AR14]ip pool abc
[AR14-ip-pool-abc]network 192.168.1.0 mask 255.255.255.0
[AR14-ip-pool-abc]gateway-list 192.168.1.254
[AR14-ip-pool-abc]dns-list 1.1.1.1
[AR14-ip-pool-abc]q
[AR14]interface gi0/0/0
[AR14-GigabitEthernet0/0/0]dhcp select global
[AR14-GigabitEthernet0/0/0]q
[AR14]ip route-static 192.168.1.0 24 192.168.2.1

[AR15]interface gi0/0/1
[AR15-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[AR15-GigabitEthernet0/0/1]q
[AR15]interface gi 0/0/0
[AR15-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[AR15-GigabitEthernet0/0/0]q
[AR15]dhcp enable
[AR15]inter gi0/0/0
[AR15-GigabitEthernet0/0/0]dhcp select relay
[AR15-GigabitEthernet0/0/0]dhcp relay server-ip 192.168.2.2
驗證:技術分享圖片

實驗三:路由器充當server服務器,中間通過交換機分配
技術分享圖片
AR17:
[Huawei]dhcp enable
[Huawei]interface gi0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.20.2 24
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ip pool v17
Info: It‘s successful to create an IP address pool.
[Huawei-ip-pool-v17]network 192.168.17.0 mask 255.255.255.0
[Huawei-ip-pool-v17]gateway-list 192.168.17.254
[Huawei-ip-pool-v17]dns-list 1.1.1.1
[Huawei-ip-pool-v17]q
[Huawei]interface gi 0/0/0
[Huawei-GigabitEthernet0/0/0]dhcp select global
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ip route-static 0.0.0.0 0.0.0.0 192.168.20.1

LW4:
[Huawei]dhcp enable
[Huawei]vlan batch 17 to 20
[Huawei]interface gi0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 17
[Huawei-GigabitEthernet0/0/1]q
[Huawei]interface vlanif 17
[Huawei-Vlanif17]ip add 192.168.17.254 24
[Huawei-Vlanif17]dhcp select relay
[Huawei-Vlanif17]dhcp relay server-ip 192.168.20.2
[Huawei-Vlanif17]q
[Huawei]interface gi 0/0/4
[Huawei-GigabitEthernet0/0/4]port link-type access
[Huawei-GigabitEthernet0/0/4]port default vlan 20
[Huawei-GigabitEthernet0/0/4]q
[Huawei]interface vlanif 20
[Huawei-Vlanif20]ip add 192.168.20.1 24

vlan18 19步驟同上,此實驗要設置四個vlan,三個地址池,每個地址池名字都不同,配置好後三臺pc可連通

DHCP及相關企業拓撲