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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/35208.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

golang学习笔记——接口经典面试题 value receivers与pointer receiver

下面的代码是一个比较好的面试题 请问下面的代码是否能通过编译? package mainimport "fmt"type People interface {Speak(string) string }type Student struct{}func (stu *Student) Speak(think string) (talk string) {if think "sb" {t…

如何删除掉MySQL的多余的实例

删除 MySQL 的多余实例通常意味着我们希望卸载或停止某个 MySQL 服务器实例,并从系统中完全移除它。这通常涉及到几个步骤,包括但不限于停止服务、删除数据目录、卸载软件(如果适用)等。 1.基于 Linux 的系统上删除 MySQL 的多余实例 以下是一个详细的步…

运算符重载详解(完全版)

1.运算符重载 C为了增强代码的可读性引入了运算符重载,运算符重载是具有特殊函数名的函数,也具有其返回值类型,函数名字和参数列表,其返回值类型与参数列表都与普通的函数类似 函数名:关键字operator后面接需要重载的…

Interview preparation--Elasticsearch写入原理与调优

ES的写入过程 ES支持的写操作 create: create操作不同于put操作,put操作的时候如果当前put的数据存在则会被覆盖,如果put操作的时候加上操作类型create,如果数据存在则会返回失败,比如:PUT /pruduct/_cre…

【C/C++】告警及报错问题收集

告警及报错问题收集 1 warning 1.1 backslash and newline separated by space 原因:宏定义分行时,后不要有空格 2 error

Ubuntu20.04安装python2和python3及版本配置

Ubuntu20.04安装python2和python3及版本配置_ubuntu 20.04 python3-CSDN博客https://blog.csdn.net/pangc2014/article/details/117407413 >>>ubuntu 安装源码python2_mob649e8161c39d的技术博客_51CTO博客https://blog.51cto.com/u_16175489/7327966

大厂薪资福利篇第四弹:字节跳动

欢迎来到绝命Coding! 今天继续更新大家最关心的 大厂薪资福利系列! 往期分享: 福利开水喝不完?大厂薪资福利篇!美团 职场文化发源地?大厂薪资福利篇!阿里巴巴 给这么多!还能带宠物上…

MFC案例:自制工具条(Toolbar)按钮的小程序

程序目标:在基于对话框的MFC项目中,自制三个 Toolbar 按钮(用颜色区分,分别为红、绿、蓝);程序运行时,单击红色按钮显示一个红色的填充椭圆;再单击绿色按钮则进行清屏;最…

[hive] posexplode生成从去年一月一号,到本月的月时间表

生成从去年一月一号,到本月的月时间表 posexplode用法: lateral view 表别名 as 序号列名,数组中的元素的名 1、生成序列 SELECT time_stamp_fist_day_of_last_year,--去年第一天的时间戳numfrom(SELECTsplit(repeat_o,,) o_array,time_stamp_fist_da…

计组--指令系统--复习专用

文章目录 前言一、指令系统概述二、指令结构三、操作数类型四、指令操作码and扩展技术五、寻址方式1.指令寻址2.数据寻址 总结 前言 学无止境,笔勤不辍。今天,笔者分享关于计组中指令系统的复习知识点… 一、指令系统概述 有关机器指令的介绍&#xff…

用英文介绍纽约:NEW YORK, USA‘s MEGACITY

NEW YORK, USA’s MEGACITY | America’s Largest City Link: https://www.youtube.com/watch?vdzjQ-akB3BI&listPLmSQiOQJmbZ7TU39cyx7gizM9i8nOuZXy&index24 The story of New York City, America’s megalopolis. Summary Paragraph 1: The Historical Developm…

PostgreSQL 高级功能与扩展(九)

1. JSONB 数据类型与操作 1.1 JSONB 简介 JSONB 是 PostgreSQL 中的一种数据类型,用于存储 JSON 格式的数据,并提供高效的查询和索引功能。 1.1.1 创建 JSONB 列 CREATE TABLE json_data ( id SERIAL PRIMARY KEY, data JSONB ); 1.2 JSONB 查询与索…

Chrome插件:​Vue.js Devtools 高效地开发和调试

在现代前端开发中,Vue.js因其灵活性和性能优势,受到越来越多开发者的青睐。然而,随着项目规模的扩大,调试和优化变得愈发复杂。幸运的是,Vue.js Devtools的出现,为开发者提供了一套强大的工具集&#xff0c…

vue大屏适配方案

前言 开发过大屏的铁汁们应该知道,前期最头疼的就是大屏适配,由于大屏项目需要在市面上不是很常见的显示器上进行展示,所以要根据不同的尺寸进行适配,今天我将为大家分享的我使用的大屏适配方案,话不多说,直…

mongo基础操作总结

1.新搭建的环境没有安全验证,很容易被入侵,两个基础的安全模式: 1:一个改端口号,把默认27017改了,对方不知道端口号就没法入侵 2:建安全验证用户,先关闭安全验证,插入用…

Matlab|风光及负荷多场景随机生成与缩减

目录 1 主要内容 计算模型 场景生成与聚类方法应用 2 部分程序 3 程序结果 4 下载链接 1 主要内容 该程序方法复现了《融合多场景分析的交直流混合微电网多时间尺度随机优化调度策略》3.1节基于多场景技术的随机性建模部分,该部分是随机优化调度的重要组成部分…

轻松掌握:工科生如何高效阅读国际期刊和撰写论文(下)

⭐️我叫忆_恒心,一名喜欢书写博客的研究生👨‍🎓。 如果觉得本文能帮到您,麻烦点个赞👍呗! 近期会不断在专栏里进行更新讲解博客~~~ 有什么问题的小伙伴 欢迎留言提问欧,喜欢的小伙伴给个三连支…

每日新闻掌握【2024年6月24日 星期一】

2024年6月24日 星期一 农历五月十九 大公司/大事件 阿里巴巴全球数学竞赛决赛试题公布,获奖选手名单将于8月公布 据阿里达摩院官微消息,北京时间6月22日24时,2024阿里巴巴全球数学竞赛决赛正式结束。本届决赛共有来自全球17个国家和地区的8…

源码解读:InternVL 1.5

源码地址:https://github.com/OpenGVLab/InternVL/tree/main/internvl_chat/internvl/model/internvl_chat 配置 在internvl_chat/internvl/model/internvl_chat/configuration_intern_vit.py 用InternVisionConfig类来设置类,用于初始化模型 num_channels=3,patch_size=1…

使用Spring Boot框架来生成HTML页面并返回给客户端

文章目录 1. 创建Spring Boot项目1.1 项目结构 2. 配置 pom.xml3. 编写代码3.1 创建主应用程序类3.2 创建数据模型3.3 创建数据仓库3.4 创建控制器3.5 创建HTML模板 4. 运行应用程序总结 下面是一个简单的Java实现,使用Spring Boot框架来生成HTML页面并返回给客户端…