進階!中型網絡架構DHCP詳解、實驗步驟
DHCP :
dynamic host configuration protocol
動態 主機 配置 協議 服務器
-動態的爲主機配置IP地址等相關信息;
DHCP 定義:動態主機配置協議;網絡
DHCP 做用:
對大量的終端主機,實現IP地址自動配置以及集中管理;
節省了工做量,下降了人爲配置錯誤;架構
DHCP工做過程:
-設備角色ide
- DHCP服務器
-
DHCP客戶端code
-工做原理:
1.DHCP客戶端發送 discover 報文;廣播方式;
2.DHCP服務器接收之後,返回一個 offer 報文;廣播方式;
3.DHCP客戶端發送 request 報文;廣播方式;
4.DHCP服務器接收之後,返回一個 ack 報文;廣播方式;server
DHCP的配置思路:
1.配置 DHCP 客戶端
2.配置 DHCP 服務器
#開啓 DHCP 功能blog
[R2] dhcp enable
#建立 DHCP 地址池
*全局的地址池
[R2] ip pool ABC
[R2-ip-pool-ABC] network 192.168.1.0 mask 255.255.255.0
[R2-ip-pool-ABC] gateway-list 192.168.1.254
[R2-ip-pool-ABC] dns-list 8.8.8.8
#肯定 DHCP 選擇模式
-須要在接收 DHCP 客戶端發送來的報文的端口上配置;
-命令:
[R2]interface gi0/0/0
[R2-gi0/0/0] dhcp select global ->從這個接口上
收到的 DHCP 請求,都直接在本地設備的
地址池( ip pool ) 中拿地址用;dns
DHCP服務器配置:接口地址池
#開啓 DHCP 功能
[R2] dhcp enable
#建立 DHCP 地址池 :
接口的地址池
-使用接收 DHCP 報文的那個端口的IP地址
所在的網段,當作 DHCP 客戶端所要的IP
地址空間;
-配置命令:
interface gi0/0/0
dhcp server dns-list 8.8.8.8
#肯定 DHCP 選擇模式
當咱們在 DHCP 服務器上配置的地址池是
屬於「接口類型」的時候,咱們在「接收DHCP
報文」的端口上的 DHCP 選擇模式,應該按
照以下命令配置:
interface gi0/0/0
dhcp select interface 接口
========================================================ip
DHCP中繼:
當DHCP客戶端 與 DHCP 服務器不在同一個網段的時候,
咱們須要配置 DHCP 中繼;
而且通常狀況下,是在一個 VLAN 的網關接口下配置的;
配置命令:
-啓用 DHCP 功能;
dhcp enable
-配置 DHCP 中繼 (網關接口下)
interface vlanif 10
ip address 192.168.1.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.12.2
- 建立交換機VLAN,同時將端口加入到相應的VLAN中[H1]vlan batch 20 30 40 88[H1]port-group group-member Gi 0/0/1 to gi 0/0/4[H1-port-group]port link-type access[H1-GigabitEthernet0/0/1]port default vlan 88[H1-GigabitEthernet0/0/2]port default vlan 20[H1-GigabitEthernet0/0/3]port default vlan 30[H1-GigabitEthernet0/0/4]port default vlan 40Dhcp服務器開啓dhcp,建立三個 地址池[R1]dhcp enable[R1]ip pool 20[R1-ip-pool-20]network 192.168.20.0 mask 255.255.255.0[R1-ip-pool-20]gateway-list 192.168.20.254[R1-ip-pool-20]dns-list 8.8.8.8[R1]ip pool 30[R1-ip-pool-30]network 192.168.30.0 mask 255.255.255.0[R1-ip-pool-30]gateway-list 192.168.30.254[R1-ip-pool-30]dns-list 8.8.8.8[R1]ip pool 40[R1-ip-pool-40]network 19建立交換機VLAN,同時將端口加入到相應的VLAN中[H1]vlan batch 20 30 40 88[H1]port-group group-member Gi 0/0/1 to gi 0/0/4[H1-port-group]port link-type access[H1-GigabitEthernet0/0/1]port default vlan 88[H1-GigabitEthernet0/0/2]port default vlan 20[H1-GigabitEthernet0/0/3]port default vlan 30[H1-GigabitEthernet0/0/4]port default vlan 40Dhcp服務器開啓dhcp,建立三個 地址池[R1]dhcp enable[R1]ip pool 20[R1-ip-pool-20]network 192.168.20.0 mask 255.255.255.0[R1-ip-pool-20]gateway-list 192.168.20.254[R1-ip-pool-20]dns-list 8.8.8.8[R1]ip pool 30[R1-ip-pool-30]network 192.168.30.0 mask 255.255.255.0[R1-ip-pool-30]gateway-list 192.168.30.254[R1-ip-pool-30]dns-list 8.8.8.8[R1]ip pool 40[R1-ip-pool-40]network 192.168.40.0 mask 255.255.255.0[R1-ip-pool-40]gateway-list 192.168.40.254[R1-ip-pool-40]dns-list 8.8.8.8[R1-GigabitEthernet0/0/0]ip add 192.168.88.1 24[R1-GigabitEthernet0/0/0]dhcp select global把VLAN加IP,設置DHCP中繼模式[H1]int vlan 20[H1-Vlanif20]ip add 192.168.20.254 24[H1-Vlanif20]dhcp select relay[H1-Vlanif20]dhcp relay server-ip 192.168.88.1[H1-Vlanif30] ip add 192.168.30.254 24[H1-Vlanif30]dhcp select relay[H1-Vlanif30]dhcp relay server-ip 192.168.88.1[H1-Vlanif40]ip address 192.168.40.254 24[H1-Vlanif40]dhcp select relay[H1-Vlanif40]dhcp relay server-ip 192.168.88.1[H1-Vlanif88]ip add 192.168.88.254 242.168.40.0 mask 255.255.255.0[R1-ip-pool-40]gateway-list 192.168.40.254[R1-ip-pool-40]dns-list 8.8.8.8[R1-GigabitEthernet0/0/0]ip add 192.168.88.1 24[R1-GigabitEthernet0/0/0]dhcp select global把VLAN加IP,設置DHCP中繼模式[H1]int vlan 20[H1-Vlanif20]ip add 192.168.20.254 24[H1-Vlanif20]dhcp select relay[H1-Vlanif20]dhcp relay server-ip 192.168.88.1[H1-Vlanif30] ip add 192.168.30.254 24[H1-Vlanif30]dhcp select relay[H1-Vlanif30]dhcp relay server-ip 192.168.88.1[H1-Vlanif40]ip address 192.168.40.254 24[H1-Vlanif40]dhcp select relay[H1-Vlanif40]dhcp relay server-ip 192.168.88.1[H1-Vlanif88]ip add 192.168.88.254 24最後用主機分配獲取ip驗證明驗