The virtual address
The reference of the process that carries the virtual address of High availability on two VMs. That page is the procedure, in order; this one says what the process does and what each key means.
What it is
nexus-proxy --vrrp is a second process of the same nexus-proxy binary. It carries one IPv4 or
one IPv6 address between two VMs by VRRP version 3 (RFC 9568), one process per address family. It
moves the address to the other VM when the peer stops advertising, or when the local proxy’s
status listener stops answering 200.
The check counts a 200 only from a process running as the account nexus-proxy, so another
program on the same port, or the proxy run under another account, does not keep the VM eligible.
It announces the address with the VM’s own MAC, by a gratuitous ARP for IPv4 and an unsolicited
Neighbor Advertisement for IPv6, so the hypervisor needs no MAC spoofing setting.
It runs on Linux only, apart from the proxy, under its own account and with two capabilities,
CAP_NET_ADMIN and CAP_NET_RAW. The proxy keeps its one capability. Containers do not run it:
there, the address in front is the orchestrator’s.
The account and the file
As root:
useradd --system --user-group --home-dir /nonexistent --shell /usr/sbin/nologin nexus-vrrpinstall -d -o root -g nexus-vrrp -m 0750 /etc/nexus-vrrpinstall -o root -g nexus-vrrp -m 0640 /dev/null /etc/nexus-vrrp/v4.jsoninstall -o root -g nexus-vrrp -m 0640 /dev/null /etc/nexus-vrrp/v6.jsonThe account is not nexus-proxy: a compromised proxy cannot signal, trace or read the memory of
the privileged process, and cannot read its file. The last two lines create each family’s file,
empty, with its owner and mode, before its content is written; a site that serves only IPv4 leaves
out the last one.
The configuration
VM A’s values. On VM B the same file differs in priority and peer, as the procedure says.
IPv4
/etc/nexus-vrrp/v4.json:
{ "interface": "eth0", "virtual_address": "10.0.0.10", "vrid": 10, "priority": 200, "peer": "10.0.0.12", "check": { "address": "127.0.0.1:9100" }}The interface is the one ip -4 addr show lists with the VM’s own address, 10.0.0.11 on A.
IPv6
/etc/nexus-vrrp/v6.json:
{ "interface": "eth0", "virtual_address": "2001:db8::10", "vrid": 10, "priority": 200, "peer": "fe80::5054:ff:fe00:12", "check": { "address": "127.0.0.1:9100" }}peer is B’s link-local address, because IPv6 advertisements come from it; ip -6 addr show dev eth0 scope link on B prints it. The process also carries virtual_link_local, a link-local
address of the virtual router; without the key it is fe80::200:5eff:fe00:2XX, XX the VRID in
hexadecimal, fe80::200:5eff:fe00:20a here.
The unit
/etc/systemd/system/nexus-vrrp@.service:
[Unit]Description=nexus-proxy virtual address (%i)After=network-online.target nexus-proxy.serviceWants=network-online.target
[Service]User=nexus-vrrpGroup=nexus-vrrpExecStart=/usr/local/bin/nexus-proxy --vrrp /etc/nexus-vrrp/%i.jsonRestart=on-failureRestartSec=1NoNewPrivileges=yesCapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAWAmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAWUMask=0027ProtectSystem=strictProtectHome=yesPrivateTmp=yesPrivateDevices=yesProtectKernelTunables=yesProtectKernelModules=yesProtectKernelLogs=yesProtectControlGroups=yesProtectClock=yesProtectHostname=yesRestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK AF_PACKETRestrictNamespaces=yesRestrictRealtime=yesRestrictSUIDSGID=yesLockPersonality=yesMemoryDenyWriteExecute=yesSystemCallArchitectures=nativeSystemCallFilter=@system-serviceSystemCallErrorNumber=EPERM
[Install]WantedBy=multi-user.targetThe confinement is the proxy’s unit with these
differences: its own account; CAP_NET_ADMIN, to add and remove the address, and CAP_NET_RAW, to
send and receive VRRP and the announcements, in place of CAP_NET_BIND_SERVICE; AF_NETLINK and
AF_PACKET added to the address families; a restart after one second; and no TimeoutStopSec=,
because the process stops within one advertisement. It writes no file, so it has no
ReadWritePaths=.
The template has one instance per family: nexus-vrrp@v4 reads /etc/nexus-vrrp/v4.json, and
nexus-vrrp@v6 reads /etc/nexus-vrrp/v6.json.
Every key
| Key | Default | What it does |
|---|---|---|
interface |
required | The network interface that carries the address, present on the host. |
virtual_address |
required | The address carried: an IPv4 literal, or a global or unique-local IPv6 literal. Its family is the process’s. |
vrid |
required | The virtual router’s identifier, 1 to 255, the same on both VMs. Advertisements with another vrid are ignored. |
priority |
required | 1 to 254. The VM with the higher priority holds the address when both run. |
peer |
required | The other VM’s address, the only source whose advertisements are accepted: for IPv4 its address on the interface’s subnet, for IPv6 its link-local address, without a zone. |
advert_interval_ms |
1000 |
How often the holder advertises, 100 to 40950, a multiple of 10. The other VM takes the address after about three missed advertisements. |
preempt |
true |
With true, the VM with the higher priority takes the address back once it runs and passes its check. With false, the address stays where it is until its holder fails. |
virtual_link_local |
fe80::200:5eff:fe00:2XX |
IPv6 files only: the virtual router’s link-local address, carried with virtual_address. XX is the VRID in hexadecimal. |
check.address |
required | The proxy’s status_listen, a loopback address and port. |
check.interval_ms |
1000 |
How often GET /status is sent, 100 to 60000. |
check.timeout_ms |
500 |
How long one check may take, 50 or more and below check.interval_ms. |
check.fail_after |
2 |
Failed checks in a row after which the VM gives the address up and stops competing for it, 1 to 10. |
check.pass_after |
2 |
Passed checks in a row after which it competes again, 1 to 10. |
An unknown key, a value out of range, or an interface without an address on the same subnet as
virtual_address and peer stops the start with exit code 2 and one line on stderr that names the
key. A missing capability stops it the same way, the line naming CAP_NET_RAW or CAP_NET_ADMIN,
and so does a host whose /etc/passwd has no account nexus-proxy, with the line
check: account nexus-proxy not found in /etc/passwd.
Nothing is sent and no address is changed.
What it writes
One JSON line per event on stderr, which the journal collects:
event |
Level | Written when |
|---|---|---|
vrrp_started |
info |
Once, when the start passed every check, with the family, interface, addresses, vrid, priority and peer. |
vrrp_state |
warn to fault, info otherwise |
Each change between initialize, backup, master and fault, with its reason. |
check_state |
warn to failing, info to passing |
The proxy’s check crosses fail_after or pass_after. A failing reason of answered by uid <n>, not nexus-proxy names the account of another program answering on check.address; owner unknown: … means the kernel did not say which account answered. |
advert_refused |
warn |
An advertisement for this vrid is refused, with its source and reason; at once, then at most once a minute with the count. |
leftover_removed |
warn |
At start, for each address a killed process had left on the interface. |
address_failed |
error |
Adding, removing or announcing the address failed. A failed add or remove exits with code 1, and systemd restarts the process. |
journalctl -u nexus-vrrp@v4, or nexus-vrrp@v6, shows them.
The network it needs
Both VMs on one layer-2 segment. Between them, IP protocol 112 (VRRP) to 224.0.0.18 for IPv4,
and to ff02::12 for IPv6 together with ICMPv6 Neighbor Advertisements, allowed by the hosts’
firewalls and by the hypervisor’s.
If VRRP is filtered, each VM stops hearing the other and both hold the address: clients reach either
at random. The journals of both then show vrrp_state to master, and no higher priority advertisement after it.
An advertisement from any address other than peer, a third machine on the segment with the same
vrid included, is refused and does not move the address; the journal shows advert_refused with
source not peer. An attacker on the segment can still claim the address by ARP or Neighbor
Discovery spoofing, which VRRP cannot prevent: the segment’s isolation is the network’s.