HSRP热备份路由协议(VRRP虚拟路由冗余协议)配置以及实现负载均衡
1、相关原理
在网络中,如果一台作为默认网关的三层交换机或者路由器损坏,所有使用该网关为下一跳的主机通信必然中断,即使配置多个默认网关,在不重启终端的情况下,也不能彻底换到新网关。Cisco提出了HSRP热备份路由协议,VRRP虚拟路由冗余协议一样,他们采用主备模式,将一个协议组内的多个路由设备映射为一个虚拟路由设备,当其中任意一个发生故障时,组内其它设备顶替损坏设备担任主路由设备。(本文采用的是HSRP协议配置方式,VRRP相关配置命令一致)
一个HSRP组中只有一台主控设备,可以有一台或者多台处于备份角色的设备,HSRP使用选择策略从该组中选择一个作为主控,负责ARP响应和IP数据包转发,备份设备处于待命状态。
比如说路由器,我们只需要在一个路由器上配置虚拟路由号和虚拟IP地址,同时会产生一个虚拟MAC地址,这样,就在网络中添加了一个虚拟路由器。
2、搭建网络

3、配置主机和服务器
规划主机IP地址
单击PC主机,选择桌面,单击IP配置,输入规划好的主机IP和默认网关,子网掩码会自动生成

对PC2-PC4做相同配置



服务器IP地址进行一样的操作

4、配置交换机
配置交换机1,创建vlan10、20、30、40,vlan10和vlan20用于接入主机,交换方式设置为access
vlan30和vlan40用于连接路由器,交换方式设置为trunk
vlan相关配置完成后,接下来配置OSPF动态路由协议,将路由器划分到OSPF area 123
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10
Switch(config-vlan)#name vlan10
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#name vlan20
Switch(config-vlan)#exit
Switch(config)#vlan 30
Switch(config-vlan)#name vlan30
Switch(config-vlan)#exit
Switch(config)#vlan 40
Switch(config-vlan)#name vlan40
Switch(config-vlan)#exitSwitch(config)#int f0/1
Switch(config-if)#switchport access vlan 10
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#int f0/2
Switch(config-if)#switchport access vlan 20
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#int f0/3
Switch(config-if)#switchport access vlan 10
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#int f0/4
Switch(config-if)#switchport access vlan 20
Switch(config-if)#no shutdown
Switch(config-if)#exitSwitch(config)#int f0/5
Switch(config-if)#switchport trunk all vlan 30
Switch(config-if)#switchport trunk all vlan add 10
Switch(config-if)#switchport trunk all vlan add 20
Switch(config-if)#no shutdown
Switch(config-if)#exitSwitch(config)#int f0/6
Switch(config-if)#switchport trunk all vlan 40
Switch(config-if)#switchport trunk all vlan add 10
Switch(config-if)#switchport trunk all vlan add 20
Switch(config-if)#no shutdown
Switch(config-if)#exitSwitch(config)#int vlan10
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#exitSwitch(config)#int vlan 20
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#exitSwitch(config)#int vlan 30
Switch(config-if)#ip address 192.168.3.1 255.255.255.0
Switch(config-if)#exitSwitch(config)#int vlan 40
Switch(config-if)#ip address 192.168.4.1 255.255.255.0
Switch(config-if)#exitSwitch(config)#ip routing
Switch(config)#router ospf 1
Switch(config-router)#network 192.168.1.0 0.0.0.255 area 123
Switch(config-router)#network 192.168.2.0 0.0.0.255 area 123
Switch(config-router)#network 192.168.3.0 0.0.0.255 area 123
Switch(config-router)#network 192.168.4.0 0.0.0.255 area 123
Switch(config-router)#end
配置交换机2,创建vlan50、60、70,vlan 50用于连接服务器和交换机,交换方式也是access,vlan 60和vlan 70用于连接路由器和交换机,交换方式trunk,此处创建vlan以及vlan接入方式同上文。
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname Switch2Switch2(config)#vlan 50
Switch2(config-vlan)#name vlan50
Switch2(config-vlan)#exitSwitch2(config)#vlan 60
Switch2(config-vlan)#name vlan60
Switch2(config-vlan)#exitSwitch2(config)#vlan 70
Switch2(config-vlan)#name vlan70
Switch2(config-vlan)#exitSwitch2(config)#int f0/1
Switch2(config-if)#switchport access vlan 50
Switch2(config-if)#no shutdown
Switch2(config-if)#exitSwitch2(config)#int f0/2
Switch2(config-if)#no shutdown
Switch2(config-if)#switchport trunk all vlan 60
Switch2(config-if)#switchport trunk all vlan add 50
Switch2(config-if)#switchport trunk all vlan add 70
Switch2(config-if)#exitSwitch2(config)#int f0/3
Switch2(config-if)#no shutdown
Switch2(config-if)#switchport trunk all vlan 70
Switch2(config-if)#switchport trunk all vlan add 50
Switch2(config-if)#switchport trunk all vlan add 60
Switch2(config-if)#exitSwitch2(config)#int vlan 50
Switch2(config-if)#ip address 8.8.8.254 255.0.0.0
Switch2(config-if)#exitSwitch2(config)#int vlan 60
Switch2(config-if)#ip address 192.168.6.1 255.255.255.0
Switch2(config-if)#exitSwitch2(config)#int vlan 70
Switch2(config-if)#ip address 192.168.7.1 255.255.255.0
Switch2(config-if)#exitSwitch2(config)#ip routing
Switch2(config)#router ospf 1
Switch2(config-router)#network 8.0.0.0 255.255.255.0 area 123
Switch2(config-router)#network 192.168.6.0 0.0.0.255 area 123
Switch2(config-router)#network 192.168.7.0 0.0.0.255 area 123
Switch2(config-router)#exit

5、配置路由器
配置端口g0/0/0,设置该端口的IP地址,设置两个子接口192.168.1.10和192.168.2.10,每个子接口划分成组,配置虚拟网关,是否抢占,优先级
//进入全局配置模式,并修改路由器名称R1
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1//配置子接口1,IP以及虚拟ip网关
R1(config)#int g0/0/0.1
R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip address 192.168.1.1 255.255.255.0 //子接口IP地址
R1(config-subif)#standby 1 ip 192.168.1.10 //vlan10的虚拟网关
R1(config-subif)#standby 1 preempt //设置为抢占模式
R1(config-subif)#standby 1 priority 200 //设置优先级为200
R1(config-subif)#exit//配置子接口2,IP以及虚拟ip网关
R1(config)#int g0/0/0.2
R1(config-subif)#encapsulation dot1q 20
R1(config-subif)#ip address 192.168.2.1 255.255.255.0
R1(config-subif)#standby 2 ip 192.168.2.10
R1(config-subif)#standby 2 preempt
R1(config-subif)#standby 2 priority 150
R1(config-subif)#exit//配置接口
R1(config)#int gigabitEthernet 0/0/1
R1(config-if)#ip address 192.168.6.2 255.255.255.0//ospf视图下发布直连路由
R1(config)#router ospf 1
R1(config-router)#network 192.168.3.0 0.0.0.255 area 123
R1(config-router)#network 192.168.6.0 0.0.0.255 area 123
R1(config-router)#exit
配置后查看路由表

(另一台路由器做相同配置,注意划分网段和IP)
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2R2(config)#int g0/0/0.1
R2(config-subif)#encapsulation dot1q 10
R2(config-subif)#ip address 192.168.1.1 255.255.255.0
R2(config-subif)#standby 1 ip 192.168.1.10
R2(config-subif)#standby 1 preempt
R2(config-subif)#standby 1 priority 150
R2(config-subif)#exitR2(config)#int g0/0/0.2R2(config-subif)#encapsulation dot1q 20
R2(config-subif)#ip address 192.168.2.1 255.255.255.0
R2(config-subif)#standby 2 ip 192.168.2.10
R2(config-subif)#standby 2 preempt
R2(config-subif)#standby 2 priority 200
R2(config-subif)#exitR2(config)#int g0/0/0
R2(config-if)#no shutdown
R2(config-if)#ip address 192.168.4.2 255.255.255.0
R2(config-if)#exitR2(config)#int g0/0/1
R2(config-if)#no shutdown
R2(config-if)#ip address 192.168.7.1 255.255.255.0
R2(config-if)#exitR2(config)#router ospf 1
R2(config-router)#network 192.168.7.0 0.0.0.255 area 123
R2(config-router)#network 192.168.4.0 0.0.0.255 area 123
R2(config-router)#exit
相关文章:
HSRP热备份路由协议(VRRP虚拟路由冗余协议)配置以及实现负载均衡
1、相关原理 在网络中,如果一台作为默认网关的三层交换机或者路由器损坏,所有使用该网关为下一跳的主机通信必然中断,即使配置多个默认网关,在不重启终端的情况下,也不能彻底换到新网关。Cisco提出了HSRP热备份路由协…...
不同集成学习算法的比较:随机森林、AdaBoost、XGBoost、LightGBM
好的,我来为您比较一些常见的集成学习算法,并生成表格形式以便于对比: 算法主要思想和特点应用场景并行处理支持稳定性和鲁棒性主要优化策略和技术AdaBoost使用加权投票组合多个弱分类器,逐步提升分类器性能二分类和多分类问题&a…...
【聊聊原子性,中断,以及nodejs中的具体示例】
什么是原子性 从一个例子说起, x ,读和写 , 如图假设多线程,线程1和线程2同时操作变量x,进行x的操作,那么由于写的过程中,都会先读一份x数据到cpu的寄存器中,所以这个时候cpu1 和 c…...
常见网络端口号
在网络工程领域,了解和掌握默认端口号是至关重要的。端口号是计算机网络中最基本的概念之 一,用于标识特定的网络服务或应用程序。 1、什么是端口号? 端口号是计算机网络中的一种标识,用于区分不同的网络服务和应用程序。每个端…...
【数值计算库-超长笔记】Python-Mpmath库:高精度数值计算
原文链接:https://www.cnblogs.com/aksoam/p/18279394 更多精彩,关注博客园主页,不断学习!不断进步! 我的主页 csdn很少看私信,有事请b站私信 博客园主页-发文字笔记-常用 有限元鹰的主页 内容…...
昇思25天学习打卡营第6天|函数式自动微分
函数式自动微分 相关前置知识复习 深度学习的重点之一是神经网络。而神经网络很重要的一环是反向传播算法,这个算法用于调整神经网络的权重。 反向传播算法 这里举例说明反向传播在做什么。 假设你是一个学生,一次考试过后,你收到了一份老…...
作业7.2
用结构体数组以及函数完成: 录入你要增加的几个学生,之后输出所有的学生信息 删除你要删除的第几个学生,并打印所有的学生信息 修改你要修改的第几个学生,并打印所有的学生信息 查找你要查找的第几个学生,并打印该的学生信息 1 /*…...
PCL 点云聚类(基于体素连通性)
文章目录 一、简介二、实现代码三、实现效果参考资料一、简介 这里的思路很简单,我们通过将点云转换为体素,基于体素的连通性实现对点云的聚类(有点类似于欧式聚类),不过这种方式进行的聚类有些粗糙,但聚类速度相对会快很多,具体的实现效果可以详细阅读代码。 二、实现代…...
python自动化运维--DNS处理模块dnspython
1.dnspython介绍 dnspython是Pyhton实现的一个DNS工具包,他几乎支持所有的记录类型,可以用于查询、传输并动态更新ZONE信息,同事支持TSIG(事物签名)验证消息和EDNS0(扩展DNS)。在系统管理方面&a…...
成人职场商务英语学习柯桥外语学校|邮件中的“备注”用英语怎么说?
在英语中,"备注"通常可以翻译为"Notes" 或 "Remarks"。 这两个词在邮件中都很常用。例如: 1. Notes Notes: 是最通用和最常见的表达,可以用在各种情况下,例如: 提供有关电子邮件内容的附加信息 列…...
AndroidStudio报错macMissing essential plugin
电脑重启后打开studio: Missing essential plugin: org.jetbrains.android Please reinstall Android Studio from scratch. 无法使用 对应Mac下disabled_plugins.txt位于如下目录: /Users/ACB/Library/Application Support/Google/AndroidStudio4.2 …...
doris集群物理部署保姆级教程
doris物理安装 1、安装要求 Linux 操作系统版本需求 查看CentOs版本(>7.1) cat /etc/redhat-release 1)设置系统最大打开文件句柄数 vi /etc/security/limits.conf soft nofile 65536hard nofile 65536 echo ‘’’ soft nofile 655360hard nofile 655…...
探囊取物之多形式登录页面(基于BootStrap4)
基于BootStrap4的登录页面,支持手机验证码登录、账号密码登录、二维码登录、其它统一登录 低配置云服务器,首次加载速度较慢,请耐心等候;演练页面可点击查看源码 预览页面:http://www.daelui.com/#/tigerlair/saas/pr…...
【ONLYOFFICE】| 桌面编辑器从0-1使用初体验
目录 一. 🦁 写在前面二. 🦁 在线使用感受2.1 创建 ONLYOFFICE 账号2.2 编辑pdf文档2.3 pdf直接创建表格 三. 🦁 写在最后 一. 🦁 写在前面 所谓桌面编辑器就是一种用于编辑文本、图像、视频等多种自媒体的软件工具,具…...
20、PHP字符串的排列(含源码)
题目: PHP字符串的排列? 描述: 输入一个字符串,按字典序打印出该字符串中字符的所有排列。 例如输入字符串abc,则打印出由字符a,b,c所能排列出来的所有字符串abc,acb,bac,bca,cab和cba。 输入描述: 输入一个字符串,长度不超过9(可…...
Linux 标准IO的fopen和fclose
getchar(),putchar() ‐‐‐‐ 一个字符 gets(buf),puts(buf) ‐‐‐‐ 一串字符 scanf(),printf() ‐‐‐‐ 一个字符,一串字符都可以 fopen函数的形式 FILE * fopen(constchar *path , cost char *mode) /* * description : 打开一个文件 * param ‐ path…...
一个计算密集小程序在不同CPU下的表现
本文比较了几款CPU对同一测试程序的比较结果,用的是Oracle公有云OCI上的计算实例,均分配的1 OCPU,内存用的默认值,不过内存对此测试程序运行结果不重要。 本文只列结果,不做任何评价。下表中,最后一列为测…...
圈子系统搭建教程,以及圈子系统的功能特点,圈子系统,允许二开,免费源码,APP小程序H5
圈子是一款社区与群组的交友工具。你可以在软件内创造一个兴趣的群组从而达到按圈子来交友的效果用户可以根据自己的兴趣爱好。 1. 创建圈子 轻松创建专属圈子,支持付费型社群。 2. 加入圈子 加入不同圈子,设置不同名片,保护隐私。 3. 定…...
递归算法练习
112. 路径总和 package Tree;import java.util.HashMap; import java.util.Map;class TreeNode {int val;TreeNode left;TreeNode right;public TreeNode(int val) {this.val val;} }/*** 求 树的路径和* <p>* 递归 递减* <p>* 询问是否存在从*当前节点 root 到叶…...
WebDriver 类的常用属性和方法
目录 🎍简介 🎊WebDriver 核心概念 🎉WebDriver 常用属性 🎁WebDriver 常用方法 🐷示例代码 🎪注意事项 🎐结语 🧣参考资料 🎍简介 Selenium WebDriver 是一个用…...
通过Wrangler CLI在worker中创建数据库和表
官方使用文档:Getting started Cloudflare D1 docs 创建数据库 在命令行中执行完成之后,会在本地和远程创建数据库: npx wranglerlatest d1 create prod-d1-tutorial 在cf中就可以看到数据库: 现在,您的Cloudfla…...
ssc377d修改flash分区大小
1、flash的分区默认分配16M、 / # df -h Filesystem Size Used Available Use% Mounted on /dev/root 1.9M 1.9M 0 100% / /dev/mtdblock4 3.0M...
uni-app学习笔记二十二---使用vite.config.js全局导入常用依赖
在前面的练习中,每个页面需要使用ref,onShow等生命周期钩子函数时都需要像下面这样导入 import {onMounted, ref} from "vue" 如果不想每个页面都导入,需要使用node.js命令npm安装unplugin-auto-import npm install unplugin-au…...
质量体系的重要
质量体系是为确保产品、服务或过程质量满足规定要求,由相互关联的要素构成的有机整体。其核心内容可归纳为以下五个方面: 🏛️ 一、组织架构与职责 质量体系明确组织内各部门、岗位的职责与权限,形成层级清晰的管理网络…...
【决胜公务员考试】求职OMG——见面课测验1
2025最新版!!!6.8截至答题,大家注意呀! 博主码字不易点个关注吧,祝期末顺利~~ 1.单选题(2分) 下列说法错误的是:( B ) A.选调生属于公务员系统 B.公务员属于事业编 C.选调生有基层锻炼的要求 D…...
Spring Boot+Neo4j知识图谱实战:3步搭建智能关系网络!
一、引言 在数据驱动的背景下,知识图谱凭借其高效的信息组织能力,正逐步成为各行业应用的关键技术。本文聚焦 Spring Boot与Neo4j图数据库的技术结合,探讨知识图谱开发的实现细节,帮助读者掌握该技术栈在实际项目中的落地方法。 …...
leetcodeSQL解题:3564. 季节性销售分析
leetcodeSQL解题:3564. 季节性销售分析 题目: 表:sales ---------------------- | Column Name | Type | ---------------------- | sale_id | int | | product_id | int | | sale_date | date | | quantity | int | | price | decimal | -…...
Unit 1 深度强化学习简介
Deep RL Course ——Unit 1 Introduction 从理论和实践层面深入学习深度强化学习。学会使用知名的深度强化学习库,例如 Stable Baselines3、RL Baselines3 Zoo、Sample Factory 和 CleanRL。在独特的环境中训练智能体,比如 SnowballFight、Huggy the Do…...
push [特殊字符] present
push 🆚 present 前言present和dismiss特点代码演示 push和pop特点代码演示 前言 在 iOS 开发中,push 和 present 是两种不同的视图控制器切换方式,它们有着显著的区别。 present和dismiss 特点 在当前控制器上方新建视图层级需要手动调用…...
淘宝扭蛋机小程序系统开发:打造互动性强的购物平台
淘宝扭蛋机小程序系统的开发,旨在打造一个互动性强的购物平台,让用户在购物的同时,能够享受到更多的乐趣和惊喜。 淘宝扭蛋机小程序系统拥有丰富的互动功能。用户可以通过虚拟摇杆操作扭蛋机,实现旋转、抽拉等动作,增…...
