一. vrrpd工具介绍
vrrpd是实现vrrp协议的工具,通过配置选项指定vrrp的参数,实现多台路由器实现网络备份功能。
二. vrrpd工具使用
~ # vrrpd -h
vrrpd version Advanced Vrrpd 1.15
Usage: vrrpd -i ifname -v vrid [ -M monitor ] [-s] [-a auth] [-p prio] [-z prio] [-x prio] [-nh] ipaddr
-h : display this short inlined help
-n : handle virtual mac address
-i ifname: the interface name to run on
-v vrid : the id of the virtual server [1-255]
-s : Switch the preemption mode (Enabled by default)
-a auth : auth=(none|pw/hexkey|ah/hexkey) hexkey=0x[0-9a-fA-F]+
-p prio : Set the priority of this host in the virtual server (dfl: 100)
-d delay : Set the advertisement interval (in sec) (dfl: 2)
-z prio : Set the priority after SIGTTIN (not decrement as default)
-x prio : Set the priority after SIGTTOU (not increment as default)
ipaddr/length : Should be at the end - IP address(es) of the virtual server and the length of the subnet mask -
-V : display version
---------------------------------------------------------------------------
Frederic Bourgeois web: http://numsys.eu code: https://github.com/fredbcode/Vrrpd
Based on (http://sourceforge.net/projects/vrrpd/)
Supplementary Options:
-U : (-U <file>): run <file> to become a master)
-D : (-D <file>): run <file> to become a backup)
-M : (-M x) Monitoring process and Network (Max 9)
If one vrrpd become backup (or died), all other process go to Backup state
If one network interface failed (ifconfig Down, link) all other process go to Backup state
Not supported (in part or whole) on all ethernet drivers
POWER USERS --------------------------------------------------------------
Magic packet erase arp table (for those who work without vmac - send fake packet to port 1100 -)
-I ipvip : Choose VIP source to send magic packet - Erase vip from mac table -
-O ipdst : Gateway destination
Example: vrrpd -i eth0 -v 11 10.1.1.1 -I 10.1.1.1 -O 10.1.1.254
-n :处理虚拟MAC地址
-i ifname :指定发送VRRP组播包的网络接口
-v vrid :指定虚拟路由器的ID,由《VRRP协议以及vrrpd工具的使用 - 1》可知,每一个备份组都有一个虚拟路由器,并对应一个ID号和一个虚拟IP地址。
-s :关闭抢占模式,抢占模式默认是开启的。
-a auth : 认证模式。无认证 - none,简单字符认证 - pw/0x,MD5 - ah/0x(vrrpd不支持)。对应报文 0 - 无认证,1 - 简单字符认证,2 - MD5认证。
-p prio : 设置Backup路由器在备份组路由器中的优先级。
-d delay : 发送VRRP组播报文通告的时间间隔。
-z prio : 当收到SIGTTIN信号时,设置此优先级
-x prio : 当收到SIGTTOU信号时,设置此优先级
ipaddr/len :设置虚拟路由器的IP地址以及子网掩码长度
三. 案例
在一个备份组路由器上启动一个vrrpd服务,虚拟路由器的IP地址时192.168.100.200/24,发送报文接口是br0,虚拟路由器号(备份组号)为3,优先级为120,备份组中路由器定时发送组播报文的时间间隔为5秒,无认证模式,不开启抢占模式。
命令:
vrrpd -s -i br0 -v 3 -a none -d 5 -p 120 192.168.100.200/24
tips:
在一个备份组中,只有Master路由器vrrpd程序会将虚拟路由器的IP地址配置到指定的ifname上,Backup路由器则不会。当Backup路由器被选举为Master路由器时,会配置ifname虚拟路由器IP地址,之前的Master路由器则会删除ifname的虚拟IP地址,通过ip addr show br0可以看到这个过程。