一.實驗拓撲:
二.實驗需求:
1.內網Ip地址使用172.16.0.0/分配 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
2.sw1和SW2之間互為備份 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
3.VRRP/STP/VLAN/Eth-trunk均使用
4.所有Pc均通過DHCP獲取IP地址
5.ISP只能配置IP地址
6.所有電腦可以正常訪問IsP路由器環回
三.實驗步驟---思路
1.首先,IP 地址規劃要確保使用 172.16.0.0/12,需要合理分配子網。例如,VLAN2 和 VLAN3 可以使用 172.16.2.0/24 和 172.16.3.0/24。AR1 與 SW1、SW2 的連接可能需要單獨的子網,比如 172.16.0.0/30 和 172.16.0.4/30。
2.然后,VLAN 劃分方面,SW3 和 SW4 的 PC 接口需要分別加入 VLAN2 和 VLAN3。交換機間的連接使用 Trunk,并配置 Eth-trunk 聚合鏈路,提高帶寬和冗余。
3.VRRP 配置在 SW1 和 SW2 的 VLAN 接口上,設置虛擬 IP 作為默認網關,優先級不同以實現主備切換。STP 啟用 MSTP,防止環路,同時配置區域和實例。
4.DHCP 服務在 SW1 上配置,為 VLAN2 和 VLAN3 提供地址池。AR1 配置接口 IP 和環回地址,設置靜態路由指向內網。SW1 和 SW2 配置默認路由指向 AR1。
5.測試部分需要驗證 IP 獲取、連通性、冗余切換和 STP 功能。需要確保所有步驟的代碼正確,設備名稱和接口名稱準確,特別是 SW3 和 SW4 的連接。
6.最后,檢查所有配置是否每一個條件,確保沒有遺漏。例如,ISp?只能配置 IP 地址,所以不需要其他復雜配置。冗余鏈路和 Eth-trunk 的配置要正確,避免環路。
三.實驗步驟---配置
1.創建VLAN
- 在 SW1、SW2、SW3、SW4 上創建 VLAN2 和 VLAN3。
[SW1]vlan batch 2 3 // 在 SW1 上批量創建 VLAN2 和 VLAN3
[SW2]vlan batch 2 3
[SW3]vlan batch 2 3
[SW4]vlan batch 2 3
2.Eth - trunk 配置
- 在 SW1 和 SW2 上創建 Eth - trunk 接口,并將它們之間互聯的物理接口加入其中,實現鏈路聚合。
[SW1]interface Eth-Trunk 1
[SW1-Eth-Trunk1]mode lacp-static
[SW1-Eth-Trunk1]trunkport GigabitEthernet0/0/1 to GigabitEthernet0/0/2
[SW1-Eth-Trunk1]port link-type trunk
[SW1-Eth-Trunk1]port trunk allow-pass vlan 2 3[SW2]interface Eth-Trunk 1
[SW2-Eth-Trunk1]mode lacp-static
[SW2-Eth-Trunk1]trunkport GigabitEthernet0/0/1 to GigabitEthernet0/0/2
[SW2-Eth-Trunk1]port link-type trunk
[SW2-Eth-Trunk1]port trunk allow-pass vlan 2 3
3. VLAN 配置
- 將連接 PC1 和 PC3 的接口設置為 access 模式并加入 VLAN2;將連接 PC2 和 PC4 的接口設置為 access 模式并加入 VLAN3。
SW3:
interface GigabitEthernet0/0/1 // PC1接口
port link-type access
port default vlan 2
interface GigabitEthernet0/0/2 // PC2接口
port link-type access
port default vlan 3SW4:
interface GigabitEthernet0/0/1 // PC3接口
port link-type access
port default vlan 2
interface GigabitEthernet0/0/2 // PC4接口
port link-type access
port default vlan 3
- 把交換機之間互聯的接口設置為 trunk 模式,允許 VLAN2 和 VLAN3 的數據通過。
SW1:
interface GigabitEthernet0/0/3 // 連接SW3
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/4 // 連接SW4
port link-type trunk
port trunk allow-pass vlan 2 3SW2:
interface GigabitEthernet0/0/4 // 連接SW3
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/3 // 連接SW4
port link-type trunk
port trunk allow-pass vlan 2 3SW3:
interface GigabitEthernet0/0/3 // 連接SW1
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/4 // 連接SW2
port link-type trunk
port trunk allow-pass vlan 2 3SW4:
interface GigabitEthernet0/0/4 // 連接SW1
port link-type trunk
port trunk allow-pass vlan 2 3
interface GigabitEthernet0/0/3 // 連接SW2
port link-type trunk
port trunk allow-pass vlan 2 3
4. STP 配置
- 在 SW1、SW2、SW3、SW4 上啟用 STP 協議,選擇合適的生成樹模式(?MSTP),防止網絡中出現環路。
[SW1]stp mode mstp
[SW1]stp region-configuration
[SW1-mst-region]region-name STP-REGION
[SW1-mst-region]revision-level 1
[SW1-mst-region]instance 1 vlan 2
[SW1-mst-region]instance 2 vlan 3
[SW1-mst-region]active region-configuration[SW2]stp mode mstp
[SW2]stp region-configuration
[SW2-mst-region]region-name STP-REGION
[SW2-mst-region]revision-level 1
[SW2-mst-region]instance 1 vlan 2
[SW2-mst-region]instance 2 vlan 3
[SW2-mst-region]active region-configuration[SW3]stp mode mstp
[SW3]stp region-configuration
[SW3-mst-region]region-name STP-REGION
[SW3-mst-region]revision-level 1
[SW3-mst-region]instance 1 vlan 2
[SW3-mst-region]instance 2 vlan 3
[SW3-mst-region]active region-configuration[SW4]stp mode mstp
[SW4]stp region-configuration
[SW4-mst-region]region-name STP-REGION
[SW4-mst-region]revision-level 1
[SW4-mst-region]instance 1 vlan 2
[SW4-mst-region]instance 2 vlan 3
[SW4-mst-region]active region-configuration
-
交換機1做組1的主根,做組2的備份根。交換機2做組2的主根,做組1的備份根
[sw1]stp instance 1 root primary
[sw1]stp instance 2 root secondary [sw2]stp instance 1 root secondary
[sw2]stp instance 2 root primary
5.SVI配置
- ?SW1 和 SW2 上為 VLAN 2 和 VLAN 3 創建 SVI 接口,并配置 IP 地址
[SW1]interface Vlanif 2
[SW1-Vlanif2]ip address 172.16.2.1 255.255.255.0[SW1]interface Vlanif 3
[SW1-Vlanif3]ip address 172.16.3.1 255.255.255.0[SW2]interface Vlanif 2
[SW2-Vlanif2]ip address 172.16.2.2 255.255.255.0[SW2]interface Vlanif 3
[SW2-Vlanif3]ip address 172.16.3.2 255.255.255.0
6.VRRP 配置
- 分別為 Vlanif2 和 Vlanif3 配置 VRRP,設置虛擬 IP 地址,同時為 SW1 和 SW2 分配不同優先級,實現主備冗余。
[SW1]interface Vlanif 2
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.2.254
[SW1-Vlanif2]vrrp vrid 1 priority 110
[SW1-Vlanif2]vrrp vrid 1 track int g0/0/1 reduced 11
[SW1-Vlanif2]dhcp select relay
[SW1-Vlanif2]dhcp relay server-ip 172.16.0.1[SW1]interface Vlanif 3
[SW1-Vlanif3]vrrp vrid 2 virtual-ip 172.16.3.254
[SW1-Vlanif3]dhcp select relay
[SW1-Vlanif3]dhcp relay server-ip 172.16.0.1[SW2]interface Vlanif 2
[SW2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.2.254
[SW2-Vlanif2]dhcp select relay
[SW2-Vlanif2]dhcp relay server-ip 172.16.0.1[SW2]interface Vlanif 3
[SW2-Vlanif3]vrrp vrid 2 virtual-ip 172.16.3.254
[SW2-Vlanif3]vrrp vrid 2 priority 110
[SW2-Vlanif3]vrrp vrid 2 track int g0/0/1 reduced 11
[SW2-Vlanif3]dhcp select relay
[SW2-Vlanif3]dhcp relay server-ip 172.16.0.1
7. DHCP 配置
- 為 VLAN2 和 VLAN3 分別創建 DHCP 地址池,指定網段、網關和 DNS 服務器地址,使 PC 能自動獲取 IP 地址。
# 開啟 DHCP 服務
[SW1] dhcp enable
# 創建 VLAN 2 的 DHCP 地址池
[SW1] ip pool vlan2_pool
# 配置可分配的 IP 地址范圍
[SW1-ip-pool-vlan2_pool] network 172.16.2.0 mask 255.255.255.0
# 配置網關地址
[SW1-ip-pool-vlan2_pool] gateway-list 172.16.2.254
# 配置 DNS 服務器地址
[SW1-ip-pool-vlan2_pool] dns-list 8.8.8.8
# 創建 VLAN 3 的 DHCP 地址池
[SW1] ip pool vlan3_pool
# 配置可分配的 IP 地址范圍
[SW1-ip-pool-vlan3_pool] network 172.16.3.0 mask 255.255.255.0
# 配置網關地址
[SW1-ip-pool-vlan3_pool] gateway-list 172.16.3.254
# 配置 DNS 服務器地址
[SW1-ip-pool-vlan3_pool] dns-list 8.8.8.8
# 進入 VLAN 2 的接口視圖
[SW1] interface Vlanif 2
# 開啟 DHCP 功能并選擇全局地址池分配方式
[SW1-Vlanif2] dhcp select global
# 進入 VLAN 3 的接口視圖
[SW1] interface Vlanif 3
# 開啟 DHCP 功能并選擇全局地址池分配方式
[SW1-Vlanif3] dhcp select global# 開啟 DHCP 服務
[SW2] dhcp enable
# 創建 VLAN 2 的 DHCP 地址池
[SW2] ip pool vlan2_pool
# 配置可分配的 IP 地址范圍
[SW2-ip-pool-vlan2_pool] network 172.16.2.0 mask 255.255.255.0
# 配置網關地址
[SW2-ip-pool-vlan2_pool] gateway-list 172.16.2.254
# 配置 DNS 服務器地址
[SW2-ip-pool-vlan2_pool] dns-list 8.8.8.8
# 創建 VLAN 3 的 DHCP 地址池
[SW2] ip pool vlan3_pool
# 配置可分配的 IP 地址范圍
[SW2-ip-pool-vlan3_pool] network 172.16.3.0 mask 255.255.255.0
# 配置網關地址
[SW2-ip-pool-vlan3_pool] gateway-list 172.16.3.254
# 配置 DNS 服務器地址
[SW2-ip-pool-vlan3_pool] dns-list 8.8.8.8
# 進入 VLAN 2 的接口視圖
[SW2] interface Vlanif 2
# 開啟 DHCP 功能并選擇全局地址池分配方式
[SW2-Vlanif2] dhcp select global
# 進入 VLAN 3 的接口視圖
[SW2] interface Vlanif 3
# 開啟 DHCP 功能并選擇全局地址池分配方式
[SW2-Vlanif3] dhcp select global
8. AR1 路由器配置
- 為 AR1 與 SW1、SW2 連接的接口以及環回接口配置 IP 地址。
# 進入 GigabitEthernet0/0/0 接口配置模式,連接 ISP
[R1] interface GigabitEthernet0/0/0
# 配置 IP 地址 12.1.1.1,子網掩碼 255.255.255.0
[R1-GigabitEthernet0/0/0] ip address 12.1.1.1 24
# 進入 GigabitEthernet0/0/1 接口配置模式,連接 SW1
[R1] interface GigabitEthernet0/0/1
# 配置 IP 地址 172.16.0.1,子網掩碼 255.255.255.0
[R1-GigabitEthernet0/0/1] ip address 172.16.0.1 24
# 進入 GigabitEthernet2/0/0 接口配置模式,連接 SW2
[R1] interface GigabitEthernet2/0/0
# 配置 IP 地址 172.16.1.1,子網掩碼 255.255.255.0
[R1-GigabitEthernet2/0/0] ip address 172.16.1.1 24# 進入 GigabitEthernet0/0/0 接口配置模式,連接 R1
[ISP] interface GigabitEthernet0/0/0
# 配置 IP 地址 12.1.1.2,子網掩碼 255.255.255.0
[ISP-GigabitEthernet0/0/0] ip address 12.1.1.2 24
# 進入 LoopBack0 接口配置模式
[ISP] interface LoopBack0
# 配置 IP 地址 6.6.6.6,子網掩碼 255.255.255.0
[ISP-LoopBack0] ip address 6.6.6.6 24# 創建 VLAN 4
[SW1] vlan 4
# 進入 VLAN 4 的 SVI 接口配置模式
[SW1] interface Vlanif 4
# 配置 IP 地址 172.16.0.2,子網掩碼 255.255.255.0
[SW1-Vlanif1] ip address 172.16.0.2 24
# 進入 GigabitEthernet0/0/5 接口配置模式,連接 R1
[SW1] interface GigabitEthernet0/0/5
# 設置接口類型為 access 模式
[SW1-GigabitEthernet0/0/5] port link-type access
# 將接口加入 VLAN 4
[SW1-GigabitEthernet0/0/5] port default vlan 4# 創建 VLAN 4
[SW2] vlan 4
# 進入 VLAN 4 的 SVI 接口配置模式
[SW2] interface Vlanif 4
# 配置 IP 地址 172.16.1.2,子網掩碼 255.255.255.0
[SW2-Vlanif1] ip address 172.16.1.2 24
# 進入 GigabitEthernet0/0/5 接口配置模式,連接 R1
[SW2] interface GigabitEthernet0/0/5
# 設置接口類型為 access 模式
[SW2-GigabitEthernet0/0/5] port link-type access
# 將接口加入 VLAN 4
[SW2-GigabitEthernet0/0/5] port default vlan 4