一、實驗目的:掌握DHCP服務基本配置及DHCP中繼服務配置,實現全網互通
二、拓撲圖:
三、具體步驟配置:
(1)R1路由器配置:
Router>enable --進入特權模式
Router#configure terminal --進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1 --修改路由器名為R1
R1(config)#interface f0/0 --進入端口
R1(config-if)#ip address 192.168.11.1 255.255.255.0 --為端口配置ip地址
R1(config-if)#no shutdown --激活端口
R1(config-if)#interface s0/0/0 --進入端口
R1(config-if)#ip address 192.168.12.1 255.255.255.0 --為端口配置ip地址
R1(config-if)#clock rate 64000 --設置時鍾同步速率
R1(config-if)#no shutdown --激活端口
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to down
R1(config-if)#exit --返回上一級
R1(config)#service dhcp --開啟dhcp服務
R1(config)#ip dhcp pool 1 --定義地址池
R1(dhcp-config)#network 192.168.11.0 255.255.255.0 --DHCP服務器要分配的網絡和掩碼
R1(dhcp-config)#default-router 192.168.11.1 --默認網關,這個地址要和相應網絡所連接的路由器的以太口地址相同
R1(dhcp-config)#exit --返回上一級
R1(config)#ip dhcp pool 2 --定義地址池
R1(dhcp-config)#network 192.168.22.0 255.255.255.0 --DHCP服務器要分配的網絡和掩碼
R1(dhcp-config)#default-router 192.168.22.1 --默認網關
R1(dhcp-config)#exit --返回上一級
R1(config)#ip dhcp pool 3 --定義地址池
R1(dhcp-config)#network 192.168.33.0 255.255.255.0 --DHCP服務器要分配的網絡和掩碼
R1(dhcp-config)#default-router 192.168.33.1 --默認網關
R1(dhcp-config)#exit --返回上一級
R1(config)#ip dhcp excluded-address 192.168.11.1 --排除的地址段
R1(config)#ip dhcp excluded-address 192.168.22.1 --排除的地址段
R1(config)#ip dhcp excluded-address 192.168.33.1 --排除的地址段
R1(config)#route rip --開啟rip協議
R1(config-router)#version 2 --版本2
R1(config-router)#no auto-summary --關閉路由自動匯總
R1(config-router)#network 192.168.12.0 --添加直連網段到rip
R1(config-router)#network 192.168.11.0
R1(config-router)#network 192.168.22.0
R1(config-router)#network 192.168.33.0
R1(config-router)#end --返回特權模式
R1#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
%SYS-5-CONFIG_I: Configured from console by console
R1#
R1#
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up
(2)R2路由器配置:
Router>enable --進入特權模式
Router#configure terminal --進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2 --修改路由器名為R2
R2(config)#interface f0/0 --進入端口
R2(config-if)#ip address 192.168.22.1 255.255.255.0 --為端口配置ip地址
R2(config-if)#ip helper-address 192.168.12.1 --配置幫助地址
R2(config-if)#no shutdown --激活端口
R2(config-if)#interface s0/0/0 --進入端口
R2(config-if)#ip address 192.168.12.2 255.255.255.0 --為端口配置ip地址
R2(config-if)#no shutdown --激活端口
R2(config-if)#interface s0/0/1 --進入端口
R2(config-if)#ip address 192.168.24.2 255.255.255.0 --為端口配置ip地址
R2(config-if)#clock rate 64000 --設置時鍾同步速率
R2(config-if)#no shutdown --激活端口
%LINK-5-CHANGED: Interface Serial0/0/1, changed state to down
R2(config-if)#exit --返回上一級
R2(config)#route rip --開啟rip協議
R2(config-router)#version 2 --版本2
R2(config-router)#no auto-summary --關閉路由自動匯總
R2(config-router)#network 192.168.12.0 --添加直連網段到rip
R2(config-router)#network 192.168.24.0
R2(config-router)#network 192.168.22.0
R2(config-router)#network
% Incomplete command.
R2(config-router)#end --返回特權模式
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up
%LINK-5-CHANGED: Interface Serial0/0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/1, changed state to up
(3)R3路由器配置:
Router>enable --進入特權模式
Router#configure terminal --進入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R3 --修改路由器名為R3
R3(config)#interface f0/0 --進入端口
R3(config-if)#ip address 192.168.33.1 255.255.255.0 --為端口配置ip地址
R3(config-if)#ip helper-address 192.168.12.1 --配置幫助地址
R3(config-if)#no shutdown --激活端口
R3(config-if)#interface S0/0/0 --進入端口
R3(config-if)#ip address 192.168.24.1 255.255.255.0 --為端口配置ip地址
R3(config-if)#no shutdown --激活端口
R3(config-if)#exit --返回上一級
R3(config)#route rip --開啟rip協議
R3(config-router)#version 2 --版本2
R3(config-router)#no auto-summary --關閉自動路由匯總
R3(config-router)#network 192.168.24.0 --添加直連網段到rip
R3(config-router)#network 192.168.33.0
R3(config-router)#network 192.168.12.0
R3(config-router)#end
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
%LINK-5-CHANGED: Interface Serial0/0/0, changed state to up
R3#
%SYS-5-CONFIG_I: Configured from console by console
R3#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up
四、驗證測試:
1、打開各台虛擬機的DHCP功能查看是否接收到DHCP服務所分配的地址:
(1)PC1
(2)PC2
(3)PC3
分配地址成功
2、測試各台主機之間是否互通
(1)PC1與PC2
(2)PC2與PC3
(3)PC3與PC1
結果:全網互通成功