本帖最后由 straw 于 2019-7-1 12:01 编辑
说习惯了,virtual ip,也就是第2个ip
通过ip addr 看出来是这样的
5: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 8c:21:0a:d9:e5:11 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.204/24 brd 192.168.1.255 scope global br-lan
valid_lft forever preferred_lft forever
inet 192.168.1.205/24 scope global secondary br-lan
valid_lft forever preferred_lft forever
这是keepalived的简单配置(在linux服务器上)
在第一台openwrt上是这样的:
config global_defs
config ipaddress
option name "ipaddress2"
option address "192.168.1.205/24"
option device "br-lan"
config vrrp_instance
option name "VI_1"
option state "MASTER"
option interface "br-lan"
option auth_type "PASS"
option auth_pass "passwordxxx"
list virtual_ipaddress "ipaddress2"
option virtual_router_id "128"
option priority "128"
option advert_int "5"
在第2台openwrt上是这样配置的:/etc/config/keepalived
config global_defs
config ipaddress
option name "ipaddress2"
option address "192.168.1.205/24"
option device "br-lan"
config vrrp_instance
option name "VI_1"
option state "BACKUP"
option interface "br-lan"
option auth_type "PASS"
option auth_pass "passwordxxxx"
list virtual_ipaddress "ipaddress2"
option virtual_router_id "128"
option priority "128"
option advert_int "5"
然后再enable keepalived为开机程序
/etc/init.d/keepalived enable
/etc/init.d/mosquitto enable |