核心代码:
需要对所有虚拟路由器设置(要进入到对应的端口)
cpp
vrrp vrid 38 virtual-ip 192.168.10.254
vrrp vrid 38 priority 120
vrrp vrid 38 track int g0/0/1 reduced 30
①mac由vrid生成
②指定虚拟ip
③虚拟ip作为内部主机的网关,对外表现为不同路由器,具有不同的真实ip
cpp
//AR1:
//配置真实ip
sys
int g0/0/0
ip add 192.168.10.253 24
int g0/0/1
ip add 172.16.1.2 24
q
//配置虚拟ip和mac
int g0/0/0
vrrp vrid 38 virtual-ip 192.168.10.254
//设置为master
vrrp vrid 38 priority 120
//如果g0/0/0关闭了则无法通信又不能检测到,需要跟踪接口,发生时g0优先
//级减30
vrrp vrid 38 track int g0/0/1 reduced 30
//添加静态路由
ip route-static 172.16.20.0 24 172.16.1.1
cpp
AR2:
//配置真实ip
sys
int g0/0/0
ip add 192.168.10.252 24
int g0/0/1
ip add 172.16.2.2 24
q
//配置虚拟ip和mac
int g0/0/0
vrrp vrid 38 virtual-ip 192.168.10.254
//添加静态路由
ip route-static 172.16.20.0 24 172.16.2.1
cpp
AR3:
sys
int g0/0/0
ip add 172.16.1.1 24
int g0/0/1
ip add 172.16.20.254 24
int g0/0/2
ip add 172.16.2.1 24
q
//添加静态路由,对外表现为不同路由器
ip route-static 192.168.10.0 24 172.16.1.2
ip route-static 192.168.10.0 24 172.16.2.2