systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vim /etc/keepalived/keepalived.conf
# vrrp_strict # 必须注释!
vrrp_instance VI_1 {
state MASTER
interface eth0 # 你的网卡
virtual_router_id 51
priority 100
advert_int 1
unicast_src_ip 10.0.0.10 # A 真实IP
unicast_peer {
10.0.0.11 # B 真实IP
}
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.99/24 # VIP
}
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 90
advert_int 1
unicast_src_ip 10.0.0.11 # B 真实IP
unicast_peer {
10.0.0.10 # A 真实IP
}
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
10.0.0.99/24
}
}
systemctl restart keepalived
ip addr
10.0.0.99 在 eth0 上,正常。ping 10.0.0.99 # 本机能通,说明绑定没问题
ping 10.0.0.99
# 在 Master 抓 VRRP
tcpdump -i eth0 host 224.0.0.18 -nn
# 抓 VIP 的 ARP
tcpdump -i eth0 arp | grep 10.0.0.99
ip addr 看 VIP,跨机 ping。
暂无评论
/etc/sysctl.conf 文件,添加以下参数以优化 ARP 行为,确保 VIP 切换后网络层可达:net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.default.arp_ignore = 1
net.ipv4.conf.default.arp_announce = 2
# 将 eth0 替换为您实际的网卡名称
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.eth0.arp_announce = 2sysctl -p 使配置生效。keepalived.conf 的 vrrp_instance 块中增加以下参数:garp_master_refresh 5 # 接管 VIP 后,每隔 5 秒发送一次免费 ARP
garp_master_repeat 2 # 每次连续发送 2 个免费 ARP 包暂无评论
亲~登录后才可以操作哦!
确定你的邮箱还未认证,请认证邮箱或绑定手机后进行当前操作
举报
×
侵犯我的权益
×
侵犯了我企业的权益
×
抄袭了我的内容
×
原文链接或出处
诽谤我
×
对根叔社区有害的内容
×
不规范转载
×
举报说明
暂无评论