一.配置ip
r1:
[r1]inter g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[r1-GigabitEthernet0/0/0]inter g0/0/1
[r1-GigabitEthernet0/0/1]ip add 13.1.1.1 24
[r1]inter l0
[r1-LoopBack0]ip add 1.1.1.1 24
r2:
[r2]inter g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]inter g0/0/1
[r2-GigabitEthernet0/0/1]ip add 192.168.1.1 24
r3:
[r3]inter g0/0/0
[r3-GigabitEthernet0/0/0]ip add 13.1.1.3 24
[r3-GigabitEthernet0/0/0]inter g0/0/1
[r3-GigabitEthernet0/0/1]ip add 192.168.1.2 24
二.配置vrrp
r2:
[r2-GigabitEthernet0/0/1]vrrp vrid 1 virtual-ip 192.168.1.254
[r2-GigabitEthernet0/0/1]vrrp vrid 1 priority 120 优先级大为主
[r2-GigabitEthernet0/0/1]vrrp vrid 1 track interface g0/0/0 reduced 30 若上行链路断开则减小优先级,备份则为主(备份设置了100)
r3:
[r3-GigabitEthernet0/0/1]vrrp vrid 1 virtual-ip 192.168.1.254
[r3-GigabitEthernet0/0/1]vrrp vrid 1 priority 100
三.配置dhcp
r2:
[r2]dhcp enable
[r2]ip pool aaa
[r2-ip-pool-aaa]network 192.168.1.0 mask 24
[r2-ip-pool-aaa]gateway-list 192.168.1.254
[r2-ip-pool-aaa]dns-list 8.8.8.8
[r2]inter g0/0/1
[r2-GigabitEthernet0/0/1]dhcp select global
四.测试
pc获取到ip
正常走主
上行链路断开走备