快捷搜索:

Linux下利用VRRP功能实现路由器备份

无意偶尔候为了包管我们收集的稳定性和靠得住性,可能会申请两条出口链路,应用两个路由器。在此中的一个路由器无法正常事情时,由别的一个路由器来接收响应的事情。实现的道理是使用RFC2338中描述的VRRP(Virtual Router Redundancy Protocol)协议。实现的对象是keepalived。

实验名称:使用VRRP功能实现简单的路由器备份

操作系统:RedHat 7.3

所应用的内核:linux-2.4.24

实验用到的模块: keepalived-1.16.tar.gz

收集布局如下图所示:图中的V-Gate便是VRRP中的VIP。

收集中有两个Linux Router:

(1), Master(eth0:192.168.1.10/24接外网; eth1:192.168.3.1/24接内网)

(2), Backup(eth0:192.168.2.10/24接外网; eth1:192.168.3.2/24接内网)

内网的IP地址段为192.168.3.0/24,网关(V-Gate)为192.168.3.3/24,记着192.168.3.3/24这个地址是在Keepalived启动时生效的。

首先我们在Linux Router Master上安装keepalived-1.1.6.tar.gz

(1)、下载keepalived-1.1.6.tar.gz (http://www.keepalived.org)

(2)、解压缩:

#tar zxvf keepalived-1.1.6.tar.gz

(3)编译keepalived

#cd keepalived-1.1.6

#./configure –prefix=/usr/local/keepalived

#make

(4)安装keepalived

#make install

(5)设置设置设备摆设摆设Linux Router Master的VRRP

#vi /usr/local/keepalived/etc/keepalived/keepalived.conf

内容如下:  vrrp_instance VI_1 {

state MASTER

interface eth1

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.3.3

}

}

在Linux Router Backup上安装keepalived的措施是相同的,不合的是设置设置设备摆设摆设文件/usr/local/keepalived/etc/keepalived/keepalived.conf,如下:  vrrp_instance VI_1 {

state BACKUP

interface eth1

virtual_router_id 51

priority 100

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.3.3

}

}

在启动Master上的keepalived之前,我们先看一下Master上eth1的环境:  # ip add show eth1

8: eth1:

mtu 1500 qdisc pfifo_fast qlen 1000

link/ether 00:e0:4c:3a:d7:25 brd ff:ff:ff:ff:ff:ff

inet 192.168.3.1/24 brd 192.168.3.255 scope global eth1

inet6 fe80::2e0:4cff:fe3a:d725/64 scope link

我们看到只有一个IP地址:192.168.3.1/24,现在我们启动Master上的keepalived:

#/usr/local/keepalived/sbin/keepalived –D –

f /usr/local/keepalived/etc/keepalived/keepalived.conf

现在我们再看一下Master上eth1的环境:  # ip add show eth1

8: eth1:

mtu 1500 qdisc pfifo_fast qlen 1000

link/ether 00:e0:4c:3a:d7:25 brd ff:ff:ff:ff:ff:ff

inet 192.168.3.1/24 brd 192.168.3.255 scope global eth1

inet 192.168.3.3/32 scope global eth1

inet6 fe80::2e0:4cff:fe3a:d725/64 scope link

我们看到有两个IP地址,此中一个便是V-Gate:192.168.3.3/32

用同样的措施启动Backup上的keepalived:

#/usr/local/keepalived/sbin/keepalived –D –

f /usr/local/keepalived/etc/keepalived/keepalived.conf

这样,当Master掉效时,Backup就会经由过程MultiCast地址:224.0.0.18这个组播地址,得到这个消息,并将192.168.3.3这个地址接收过来。

总结,请你留意一下我们这个实验的题目“使用Keepalived的VRRP功能实现简单的路由器备份”,而不是路由备份。我们这个实验的目的,是让大年夜家认识VRRP协讲和若何使用Keepalived实现VRRP协议。

您可能还会对下面的文章感兴趣: