当前位置: 首页 > news >正文

生成树和VRRP实验

配置循序:eth-trunk        创建vlan,划分vlan        trunK        STP        SVI        VRRP     DHCP

1.配置eth-trunk

[SW1]interface Eth-Trunk 0
[SW1-Eth-Trunk0]trunkport g0/0/2
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW1-Eth-Trunk0]trunkport g0/0/3
Info: This operation may take a few seconds. Please wait for a moment...done.

[SW2]interface Eth-Trunk 0
[SW2-Eth-Trunk0]trunkport g0/0/2
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW2-Eth-Trunk0]trunkport g0/0/3
Info: This operation may take a few seconds. Please wait for a moment...done.

2.划分vlan

[SW1]vlan 2
[SW1-vlan2]q  
[SW1]port-group group-member GigabitEthernet 0/0/4 GigabitEthernet 0/0/5 Eth-Trunk 0
[SW1-port-group]port link-type trunk 
[SW1-port-group]port trunk allow-pass vlan 2
[SW2]vlan 2
[SW2]port-group group-member GigabitEthernet 0/0/4 GigabitEthernet 0/0/5 Eth-Trunk 0
[SW2-port-group]port link-type trunk 
[SW2-port-group]port trunk allow-pass vlan 2
[SW3]vlan 2
[SW3]int e0/0/4
[SW3-Ethernet0/0/4]port link-type access 
[SW3-Ethernet0/0/4]port default vlan 2
[SW3]port-group group-member e0/0/1 to e0/0/2
[SW3-port-group]port link-type trunk 
[SW3-port-group]port trunk allow-pass vlan 2
[SW4]vlan 2
[SW4-vlan2]q
[SW4]int e0/0/4
[SW4-Ethernet0/0/4]port link-type access 
[SW4-Ethernet0/0/4]port default vlan 2
[SW4-Ethernet0/0/4]q
[SW4]port-group group-member e0/0/1 to e0/0/2
[SW4-port-group]port link-type trunk 
[SW4-port-group]port trunk allow-pass vlan 2

3.配置生成树

[SW1]stp region-configuration  
[SW1-mst-region]region-name aa
[SW1-mst-region]instance 1 vlan 1
[SW1-mst-region]instance 2 vlan 2
[SW1-mst-region]active region-configuration

[SW2]stp region-configuration 
[SW2-mst-region]region-name aa
[SW2-mst-region]instance 1 vlan 1
[SW2-mst-region]instance 2 vlan 2 
[SW2-mst-region]active region-configuration

[SW3]stp region-configuration 
[SW3-mst-region]region-name aa
[SW3-mst-region]instance 1 vlan 1
[SW3-mst-region]instance 2 vlan 2   
[SW3-mst-region]active region-configuration 


[SW4]stp region-configuration 
[SW4-mst-region]region-name aa 
[SW4-mst-region]instance 1 vlan 1
[SW4-mst-region]instance 2 vlan 2
[SW4-mst-region]active region-configuration 

[SW1]stp instance 1 root primary 
[SW1]stp instance 2 root secondary 
[SW1]stp instance 0 root primary 
[SW2]stp instance 1 root secondary   
[SW2]stp instance 2 root primary 
[SW2]stp instance 0 root secondary

[SW3]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/22
[SW3-port-group]stp edged-port enable

[SW4]port-group group-member e0/0/1 to e0/0/22 
[SW4-port-group]stp edged-port enable 

4.配置SVI:

[SW1]int Vlanif 1
[SW1-Vlanif1]ip add 172.16.1.1 25
[SW1-Vlanif1]int vlanif 2
[SW1-Vlanif2]ip add 172.16.1.129 25

[SW2]int vlan 1
[SW2-Vlanif1]ip add 172.16.1.2 25
[SW2-Vlanif1]int vlanif 2
[SW2-Vlanif2]ip add 172.16.1.130 25

5.进行网关冗余:

[SW1]int vlanif 1 
[SW1-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[SW1-Vlanif1]vrrp vrid 1 priority 110:对sw1来说vlan1为主根
[SW1-Vlanif1]vrrp vrid 1 track interface g0/0/1 reduced 20

[SW1-Vlanif1]int vlanif 2 
[SW1-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254

[SW2-Vlanif2]int vlan 1
[SW2-Vlanif1]vrrp vrid 1 virtual-ip 172.16.1.126
[SW2-Vlanif1]int vlanif 2 
[SW2-Vlanif2]vrrp vrid 1 virtual-ip 172.16.1.254 
[SW2-Vlanif2]vrrp vrid 1 priority 110 :对sw2来说vlan2为主根
[SW2-Vlanif2]vrrp vrid 1 track int g0/0/1 reduced 20

6.配置DHCP获取IP地址:

[SW1]dhcp enable
[SW1]ip pool aa
Info:It's successful to create an IP address pool.
[SW1-ip-pool-aa]net 172.16.1.0 mask 25
[SW1-ip-pool-aa]gateway-list 172.16.1.126
[SW1-ip-pool-aa]dns-list 114.114.114.114
[SW1-ip-pool-aa]q
[SW1]ip pool bb
Info:It's successful to create an IP address pool.
[SW1-ip-pool-bb]net 172.16.1.128 mask 25
[SW1-ip-pool-bb]gateway-list 172.16.1.254
[SW1-ip-pool-bb]dns-list 114.114.114.114
[SW1-ip-pool-bb]q
[SW1]int vlanif 1 
[SW1-Vlanif1]dhcp select global 
[SW1-Vlanif1]int vlan 2   
[SW1-Vlanif2]dhcp select global 


[SW2]dhcp enable
[SW2]ip pool aa
Info:It's successful to create an IP address pool.
[SW2-ip-pool-aa]net 172.16.1.0 mask 25
[SW2-ip-pool-aa]gateway-list 172.16.1.126
[SW2-ip-pool-aa]dns-list 114.114.114.114
[SW2-ip-pool-aa]q
[SW2]ip pool bb
Info:It's successful to create an IP address pool.
[SW2-ip-pool-bb]net 172.16.1.128 mask 25
[SW2-ip-pool-bb]gateway-list 172.16.1.254
[SW2-ip-pool-bb]dns 114.114.114.114
[SW2-ip-pool-bb]q
[SW2]int vlanif 1
[SW2-Vlanif1]dhcp select global 
[SW2-Vlanif1]int vlanif 2
[SW2-Vlanif2]dhcp select global

7.配置交换机的上层接口:

[SW1]vlan 99
[SW1-vlan99]q
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type access 
[SW1-GigabitEthernet0/0/1]port default vlan 99
[SW1-GigabitEthernet0/0/1]q
[SW1]int vlanif 99
[SW1-Vlanif99]ip add 172.16.0.2 30

[SW2]vlan 99
[SW2-vlan99]q
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type access 
[SW2-GigabitEthernet0/0/1]port default vlan 99
[SW2-GigabitEthernet0/0/1]q
[SW2]int vlanif 99
[SW2-Vlanif99]ip add 172.16.0.6 30

8.配置沉默接口:避免ospf与其他虚拟配置建立邻居,造成流量浪费
[SW1]ospf 1
[SW1-ospf-1]silent-interface all
[SW1-ospf-1]undo silent-interface GigabitEthernet 0/0/1 
[SW1-ospf-1]undo silent-interface Eth-Trunk 0
[SW1-ospf-1]undo silent-interface Vlanif 1

[SW2]ospf 1
[SW2-ospf-1]undo sil       
[SW2-ospf-1]silent-interface all
[SW2-ospf-1]undo silent-interface GigabitEthernet 0/0/1  
[SW2-ospf-1]undo silent-interface Vlanif 99
[SW2-ospf-1]undo silent-interface Vlanif 1  
[SW2-ospf-1]undo silent-interface Eth-Trunk 0

9.配置ospf

[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]net 172.16.0.0 0.0.0.255

[SW1]ospf 2 router-id 3.3.3.3
[SW1-ospf-2]area 0
[SW1-ospf-2-area-0.0.0.0]net 172.16.0.2 0.0.0.0
[SW1-ospf-2-area-0.0.0.0]area 1
[SW1-ospf-2-area-0.0.0.1]net 172.16.1.0 0.0.0.255

[SW2-ospf-1]area 0
[SW2-ospf-1-area-0.0.0.0]net 172.16.0.6 0.0.0.0
[SW2-ospf-1-area-0.0.0.0]area 1
[SW2-ospf-1-area-0.0.0.1]net 172.16.1.0 0.0.0.255

[R2]ip route-static 0.0.0.0 0 12.1.1.1 
[R2-ospf-1]default-route-advertise 

10.路由汇总:

[SW1-ospf-2]area 1
[SW1-ospf-2-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0

[SW2-ospf-2]area 1 
[SW2-ospf-2-area-0.0.0.1]abr-summary 172.16.1.0 255.255.255.0

11.防环:

[SW1]ip route-static 172.16.1.0 24 NULL 0

[SW2]ip route-static 172.16.1.0 24 NULL 0

12.配置nat

[R2]acl 2000   
[R2-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R2]int g0/0/0    
[R2-GigabitEthernet0/0/0]nat outbound 2000

13.ISP配置IP地址:

测试:PC1和PC2进行上网:

相关文章:

  • 【keil】单步调试
  • python学习笔记(3)——元组
  • 【云服务器】在Linux CentOS 7上快速搭建我的世界 Minecraft Fabric 服务器搭建,Fabric 模组详细搭建教程
  • 2. client.chat.completions.create 简单使用
  • 【C++标准IO库】文件的输入输出
  • 批量合并 PDF 文档,支持合并成单个文档,也支持按文件夹合并 PDF 文档
  • 测试模版12
  • springboot453-基于协同过滤推荐算法的食品推荐系统(源码+数据库+纯前后端分离+部署讲解等)
  • GAMES101-现代计算机图形学入门(Animation/simulation)
  • 16-字符串/贪心-相同的字符串
  • docker启动nacos+redis
  • 每日算法----2716. 最小化字符串长度----2025/03/28
  • Android 系统ContentProvider流程
  • 【Hysteria】部署+测试
  • 深入了解Linux内核:task_struct结构详解
  • WinForm真入门-简介
  • react如何引用(按需加载)百度地图,并结合and组件化封装
  • 【leetcode】拆解与整合:分治并归的算法逻辑
  • ​​​​​​Spring Boot热部署插件
  • 【第33节】windows原理:初探PE文件
  • 比熬夜更伤肝的事,你可能每天都在做
  • 保利发展去年净利润约50亿元,在手现金1342亿元
  • 伊朗内政部长:港口爆炸由于“疏忽”和未遵守安全规定造成
  • 科学时代重读“老子”的意义——对谈《老子智慧八十一讲》
  • 香港警务处高级助理处长叶云龙升任警务处副处长(行动)
  • 《奇袭白虎团》原型人物之一赵顺合辞世,享年95岁