Junos VRRP Configuration: VIP, Priority and Accept-Data - 夜莺博客

Junos VRRP Configuration: VIP, Priority and Accept-Data

VRRP gives a subnet a virtual default gateway that survives the failure of any single router. On Junos OS the configuration lives inside the interface address: you add a vrrp-group statement under the IPv4 address of the interface, define the group ID and virtual IP, and each router's priority decides who is master. This lab-based guide walks through basic Junos VRRP, the accept-data option, and the verification commands that show master and backup state.

Basic Junos VRRP Configuration

Two vMX routers share gateway 172.16.50.1 for the 172.16.50.0/24 segment. vMX-3 is preferred with priority 120; vMX-4 stays at the default priority 100:

lab@vMX-3> configure
[edit interfaces ge-0/0/2 unit 0 family inet]
set address 172.16.50.2/24 vrrp-group 50 virtual-address 172.16.50.1
set address 172.16.50.2/24 vrrp-group 50 priority 120
commit
lab@vMX-4> configure
[edit interfaces ge-0/0/2 unit 0 family inet]
set address 172.16.50.3/24 vrrp-group 50 virtual-address 172.16.50.1
commit

Verifying VRRP State

lab@vMX-3> show vrrp
lab@vMX-4> show vrrp
lab@vMX-4> show vrrp detail

vMX-3 reports State: master; vMX-4 reports backup and additionally lists the master address (172.16.50.2) and its priority. show vrrp detail exposes the VRRP version (2 by default), advertisement interval, preempt state, the virtual MAC (00:00:5e:00:01:32 for group 50) and whether tracking is enabled. The virtual MAC is derived from the group ID — group 50 maps to the last byte 0x32.

Accept-Data and Preempt

By default the VRRP master does not answer traffic destined to the VIP itself — hosts can ping through the gateway but not the gateway address. Turning on accept-data makes the master respond to the VIP, useful for management and monitoring:

[edit interfaces ge-0/0/2 unit 0 family inet]
set address 172.16.50.2/24 vrrp-group 50 accept-data
set address 172.16.50.2/24 vrrp-group 50 preempt
commit

preempt (on by default) lets the higher-priority router reclaim the master role when it recovers; disable it if you want the incumbent to keep the VIP after a failover.

Priority, Timers and Tracking

Priorities range 1–254; 255 is reserved for the address owner (the router whose physical interface IP equals the VIP). You can shorten failover with fast-interval and trigger failover when a tracked interface or route drops using track interface / route with a priority cost:

[edit interfaces ge-0/0/2 unit 0 family inet]
set address 172.16.50.2/24 vrrp-group 50 priority-cost 60
set address 172.16.50.2/24 vrrp-group 50 track interface ge-0/0/0
commit

On a Junos device VRRP competes with other first-hop options. Compare with the Cisco equivalent in HSRP configuration with priority, preempt and track, and see how Junos stages changes safely with commit confirmed and rollback before you touch a live gateway.

原文链接:https://www.networkcuriosity.com/junos-vrrp-example/