MAC Alias Cache
Shows what every MAC-type firewall alias really resolves to, and rebuilds them from current host discovery data on demand, instead of waiting up to twelve hours for stale addresses to age out. It can also give each MAC alias the IPv6 addresses host discovery misses.
Why this plugin
OPNsense resolves MAC-type aliases through a cache of addresses reported by its host discovery. When a device is still being seen, its entry is refreshed. When it is no longer reported at all (it left, moved to an unwatched interface, or its records expired), its last addresses stay in the cache for up to 12 hours, in its own alias and in every alias that nests it. Rules keep matching an address that may already belong to another device.
Firewall > Diagnostics > Aliases cannot fix that: its flush and delete act on the pf table only, and the next alias refresh reloads the table from the same cache.
Using it
Firewall > Diagnostics > MAC Alias Cache lists each MAC alias with its entries, the MACs that match, the addresses cached versus those host discovery reports now, and the aliases that nest it.
Flush & rebuild replaces the cache with one seeded only from current host discovery data and rebuilds every MAC alias and every alias nesting one, under core's own alias update lock. If the host list cannot be read, or is empty, it refuses and changes nothing, because core would otherwise rebuild every MAC alias as empty. It also refuses read-only users, runs one flush at a time, checks each host row's MAC and address before it reaches the cache, and refuses when the core files it relies on no longer match what it was built against (after a core update). The cache keeps core's own permissions.
Core's issue for this, opnsense/core#10114, was closed without a fix, and core 26.7.10 still keeps an address 12 hours. Should a later release carry one, the page says so: MAC aliases may then drop a vanished address on their own, and the addresses from the neighbor table (below) may no longer reach the aliases.
From a shell, as root: configctl macaliascache status and configctl macaliascache flush.
Addresses host discovery misses
Host discovery records an IPv6 address when it sees a host send a neighbor solicitation or advertisement from it. A host that answers for a privacy address from its stable address gets no row for the privacy address unless host discovery's Promiscuous mode is on: the network card then passes the duplicate address detection probe the host sends for it, and host discovery records the address from that (opnsense/hostwatch#39). With it off, a MAC alias for that host holds one address while the host opens connections from several, and a rule on the alias misses them.
Since 1.4 the page has a setting, Add addresses from the neighbor table, off by default. Tick it and press Apply. While it is on, and while host discovery is on, the plugin adds to core's cache, each minute, the IPv6 addresses the kernel's neighbor table has for a MAC of a MAC alias and host discovery does not list for that MAC. Core's own alias update then puts them in the alias and in every alias nesting it. The page lists them under their MAC.
Turned off again, the addresses leave the cache at once and the aliases at core's next update. Removing the package does the same. A flush keeps them while the setting is on, since the neighbor table is current data too.
The page warns, while the setting is on, when the update has failed for ten minutes, when a limit kept addresses out, when core no longer merges such entries, and when no update has completed for two hours. From a shell: configctl macaliascache neighbors runs one update.
Limits
- A flush cannot remove an address host discovery still reports; those age out with host discovery's own expiry (Interfaces > Hostwatch > Settings, Expire/cleanup IPv4 and Expire/cleanup IPv6).
- It does not probe hosts: host discovery records ARP and NDP only, which an active host with a fresh entry does not send.
- A flush runs only when asked, and nothing runs on install. With the neighbor-table setting off and nothing of the plugin's left in core's cache (so wherever it was never on, and from the first run after it was turned off that finds none left), the package's minute job does nothing: it reads no file of core's, runs no program and takes no lock.
For the addresses from the neighbor table:
- IPv6 only, and only while host discovery is on. With it off, core reads the neighbor table itself.
- The aliases never hold more than 32 such addresses for one MAC and 1024 in all. Over a limit, the addresses now in the neighbor table come first, and the page counts the ones left out.
- Up to about 90 seconds pass between the firewall first resolving a new address and the alias holding it: the plugin reads the neighbor table at second 30 of each minute, and core rebuilds the aliases at second 0. It takes three minutes in the rare minute core skips an alias it has just rebuilt. A connection opened earlier keeps the rule it matched.
- After the firewall restarts, core's cache and the neighbor table start empty. Each of these addresses is out of its alias until its host talks again and both runs have passed.
- An address stays up to 12 hours after it left the neighbor table, the lifetime of core's cache. A flush drops it at once.
- A MAC alias with an update frequency is rebuilt at that frequency, not each minute, so it gains and loses these addresses only then.
- A neighbor table of more than about 6,000 entries counts as unreadable: nothing is added, and the page says so once that has lasted ten minutes.
Source and install
Install it from the LegoTypes repository: see Install. Source: LegoTypes/plugins, net/mac-alias-cache.