Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - RamSense

#16
Thanks for looking into this in more detail. This sounds very promising.

I had a closer look at how udp-proxy-2020 actually handles this, since it is already proven to work with Roon across routed networks and VPN connections.

As far as I can see, udp-proxy-2020 does not implement any SOOD-aware query/response proxying and does not interpret the SOOD payload. It captures the configured UDP traffic and reinjects it onto the other interfaces while preserving the original source IP and UDP source/target ports.

So I think your "naive" solution may actually be the right model for SOOD: preserve the original endpoint and let subsequent unicast communication use normal routing, rather than making Netflector part of that unicast conversation.

That also seems to fit the output-device case you mentioned. Netflector would not need to decide whether a "Q" semantically represents a discovery query from a Remote or an announcement/discovery packet from an output device. It can simply relay the SOOD packet while preserving its original source identity.

There is another detail which seems relevant to your question about unicast responses. Aaron Turner's Roon Wireshark dissector indicates that, besides the normal Roon Server discovery on UDP/9003, there is also a Roon Discovery service where replies may originate from an ephemeral UDP port and the dissector therefore uses conversation tracking. To me that is another argument in favour of preserving the original source IP and port rather than introducing SOOD-specific response translation.

One implementation detail from udp-proxy-2020 may also be worth keeping in mind. In addition to BPF capture/injection it opens a normal UDP listener on the configured port and discards anything received there. That was added because ICMP Port Unreachable responses could otherwise cause problems for Roon clients, particularly iOS clients over VPN. I don't know whether that will be relevant to Netflector on OPNsense, but it seems worth being aware of when testing a first implementation.

So I would definitely start with the simple source-IP/source-port preserving model. If you build an initial SOOD implementation that way, I would be very happy to test it with Roon Remote over WireGuard and also with the Roon server/output side.
#17
Thanks for the update. Your gateway-group finding prompted me to check my configuration as well.

I also found an old unused gateway group. It contained only `WAN_DHCP6` as Tier 2 and was not referenced by any firewall rule, so I removed the group through the GUI and applied the configuration.

However, this does not appear to be the root cause on my system.

After removing the unused gateway group, I kept my existing `radix4` workaround active and then tried to switch the IPv4 FIB algorithm live back to `radix4_lockless`:

sysctl net.route.algo.inet.algo=radix4_lockless

This failed immediately:

net.route.algo.inet.algo: radix4
sysctl: net.route.algo.inet.algo=radix4_lockless: Invalid argument

At the same time the kernel logged a new failure:

[fib_algo] inet.0 setup_fd_instance: radix4_lockless algo instance setup failed, failures=0

The active algorithm therefore remained `radix4`.

My WireGuard IPv4 route and connectivity remained correct during the test, but this was because the switch to `radix4_lockless` never succeeded:

route to: 10.10.10.2
fib: 0
interface: wg0

So in my case, removing the old unused gateway group did not make `radix4_lockless` usable again.

For now I therefore still need:

net.route.algo.inet.algo=radix4

as the workaround.

This suggests that an incomplete or stale gateway group may be a trigger in some configurations, but it does not appear to be the sole cause of the `radix4_lockless` setup/rebuild failure.

I have not rebooted after removing the group; this was a live test while keeping the persistent `radix4` tunable in place.

DEC850v2 / OPNsense 26.7.3_8 / PPPoE / WireGuard
#18
Thanks both. I completely agree about avoiding a generic "Swiss army knife" with lots of special cases. That wasn't really what I had in mind either.

My suggestion was specifically a dedicated Roon/SOOD reflector, but only if the protocol fits cleanly within Netflector's existing model of explicitly supported discovery protocols such as mDNS, SSDP and WSD.

I mentioned the source-IP and WireGuard/roadwarrior details mainly so that, if Roon support is investigated, the important part of the use case is known from the start. If implementing that would require too many Roon-specific exceptions, keeping a dedicated tool such as udp-proxy-2020 or RoonBroadcastRelay is of course perfectly reasonable.

If it does fit, I'd be happy to test a development version on OPNsense with Roon across a WireGuard roadwarrior connection.
#19
This looks like a very interesting plugin.

Would you consider adding dedicated support for Roon discovery (SOOD/RAAT discovery) as an additional reflector type?

Roon music uses UDP port 9003 and relies on both broadcast and multicast (239.255.90.90:9003) for discovery. This normally does not cross routed VLANs or Layer-3 VPNs such as WireGuard or OpenVPN.

For this reason I currently use udp-proxy-2020 directly on OPNsense. It was specifically designed to make Roon discovery work across routed networks and VPN tunnels, and in my case it allows Roon clients/endpoints connected through WireGuard to discover and communicate with the Roon server on the LAN.

One important detail is that simply forwarding UDP/9003 may not be sufficient for all Roon use cases. A remote Roon endpoint connected through a routed VPN must remain reachable on its actual VPN IP after discovery.

Projects such as RoonBroadcastRelay therefore explicitly preserve the original source IP when relaying Roon discovery traffic. This allows the Roon server to subsequently connect back to the endpoint using its real VPN address. It also supports unicast delivery towards roadwarrior VPN clients where multicast/broadcast cannot be delivered directly.

So, if Roon support were added to Netflector, an ideal implementation would probably need to cover:

* UDP 9003
* IPv4 broadcast discovery
* multicast 239.255.90.90:9003
* LAN/VLAN <-> routed Layer-3 VPN interfaces such as WireGuard/OpenVPN
* preservation of the original endpoint/source IP where required
* unicast forwarding towards VPN peers/roadwarrior clients
* preferably either configured VPN peer targets or some form of automatic client/peer learning

The reason Netflector is especially interesting for this is that it already has native OPNsense/FreeBSD integration, interface monitoring, directional reflector configuration and a GUI. If it could handle the Roon-specific discovery semantics as well, it could potentially replace the separate udp-proxy-2020 service completely.

Would a dedicated Roon/SOOD reflector like this fit within the scope of Netflector?
#20
That's a fair point.

I cannot be sure that the previous kernel was free of radix4_lockless errors, because unfortunately I did not save the dmesg output from the previous installation before replacing the SSD. The SSD had reached a very high level of wear after substantial disk writes, which I am investigating separately with Zenarmor because of the amount of write activity generated by its logging. Warning for other users here.

In fact, I think I may have seen similar fib_algo/radix messages before, while WireGuard and normal IPv4 routing were still working correctly.

So I don't want to claim that 26.7.3 necessarily introduced the radix issue, nor that this is related to an igc change.

It is quite possible that the radix4_lockless problem was already present but latent/non-impacting, and that the clean installation/config restore exposed it during a fresh FIB rebuild.

What I can reproduce reliably on the current 26.7.3_8 installation is:

- radix4_lockless repeatedly reports setup/rebuild failures
- the routing table and nexthops still appear correct
- actual IPv4 lookup to wg0 is wrong
- IPv6 is unaffected
- changing only net.route.algo.inet.algo from radix4_lockless to radix4 immediately restores both the normal IPv4 route to the WireGuard peer and full IPv4 Internet access through WireGuard

So the exact version where the radix errors first appeared is unknown. The reproducible part is the radix4_lockless failure and the radix4 workaround on the current installation.
#21
I can confirm the same radix4_lockless problem on a DEC850v2 running OPNsense 26.7.3_8.

In my case WAN itself remained available, but IPv4 routing to a WireGuard interface was broken after restoring the configuration onto a replacement SSD. The WireGuard tunnel had a healthy handshake and IPv6 through the same tunnel worked normally.

The kernel log contains repeated errors:

[fib_algo] inet.0 setup_fd_instance: radix4_lockless algo instance setup failed
[fib_algo] inet.0 (radix4_lockless#43) rebuild_fd_flm: table rebuild failed
[fib_algo] inet.0 (radix4_lockless#43) rebuild_fd: sync rebuild failed

The failure counter reached at least 42.

The interesting part is that the routing table itself looked completely correct:

route -n get 10.10.10.2
  interface: wg0

netstat -rWn4:
10.10.10.2  link#11  UHS  Nhop#16  wg0

netstat -4onW:
Nhop#16:
IFA      10.10.10.1
Gateway  wg0/resolve
Netif    wg0

Despite this, normal IPv4 traffic to 10.10.10.2 was incorrectly sent towards pppoe0.

A normal:

ping -c 1 10.10.10.2

failed, while:

ping -r -S 10.10.10.1 -c 1 10.10.10.2

worked immediately.

IPv6 to the same WireGuard peer also worked normally.

The decisive test was changing only the IPv4 FIB algorithm:

sysctl net.route.algo.inet.algo=radix4

Immediately afterwards the normal IPv4 ping worked through wg0 and full IPv4 Internet access through WireGuard was restored.

Changing nothing else was required.

Current workaround:

System > Settings > Tunables

net.route.algo.inet.algo = radix4

So this appears to be a radix4_lockless FIB rebuild/lookup failure rather than a WireGuard, NAT or firewall configuration problem.

Hardware: DEC850v2
OPNsense: 26.7.3_8
WAN: PPPoE
IPv4 default algorithm before workaround: radix4_lockless
Available algorithms: bsearch4, radix4_lockless, radix4

I have now also filed this as OPNsense src issue #323, including the full diagnostic results and the reproducible radix4_lockless → radix4 A/B test.

GitHub: https://github.com/opnsense/src/issues/323

Hopefully this helps confirm that the radix4_lockless rebuild errors can cause different IPv4 routing failures depending on the system/configuration.
#22
General Discussion / Re: Support AmneziaWG
August 28, 2026, 03:41:10 PM
Getting a 404 error on your links
#23
Hi,

I am running OPNsense:

OPNsense 26.7.2_2-amd64
FreeBSD 15.1-RELEASE-p2
OpenSSL 3.5.7

With Suricata IPS in Divert mode and Hyperscan.

There is currently an open OPNsense issue describing an intermittent deadlock during a live Suricata rule reload with SIGUSR2 in this configuration:
https://github.com/opnsense/core/issues/10416

The stock scheduled IDS rule update currently follows this path:


rule-updater.py
installRules.py
pkill -USR2 suricata

The workaround described in the issue is to update/install the rules and then perform a full Suricata restart instead of entering the problematic live-reload path.

I wanted to keep automatic rule updates, but add some safeguards around that workaround.

The wrapper below prevents concurrent runs with lockf, uses OPNsense's own rule updater and installer, backs up the active ruleset, skips an unnecessary restart when the active rules did not change, validates the new rules before restarting, performs a full restart without SIGUSR2, checks whether the Divert listeners return, and restores the previous active ruleset if validation/startup fails.

This is a temporary workaround, not an upstream fix.

1. Create the update wrapper

Create:
/usr/local/sbin/suricata-safe-update

contents:
#!/bin/sh

set -u

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
export PATH

TAG="suricata-safe-update"

UPDATER="/usr/local/opnsense/scripts/suricata/rule-updater.py"
INSTALLER="/usr/local/opnsense/scripts/suricata/installRules.py"
SURICATA="/usr/local/bin/suricata"
CONFIG="/usr/local/etc/suricata/suricata.yaml"
RC="/usr/local/etc/rc.d/suricata"

ACTIVE_DIR="/usr/local/etc/suricata/opnsense.rules"
ACTIVE_YAML="/usr/local/etc/suricata/installed_rules.yaml"

BACKUP_DIR=""

logmsg()
{
    logger -t "$TAG" "$*"
    echo "$TAG: $*"
}

active_hash()
{
    {
        if [ -d "$ACTIVE_DIR" ]; then
            find "$ACTIVE_DIR" -type f -name '*.rules' -print 2>/dev/null |
                sort |
                while IFS= read -r f; do
                    printf '%s ' "$f"
                    sha256 -q "$f"
                done
        fi

        if [ -f "$ACTIVE_YAML" ]; then
            printf '%s ' "$ACTIVE_YAML"
            sha256 -q "$ACTIVE_YAML"
        fi
    } | sha256 -q
}

divert_count()
{
    sockstat 2>/dev/null |
        awk '$2 == "suricata" && $5 == "div4" && $6 == "*:8000" { n++ }
             END { print n + 0 }'
}

restore_active()
{
    logmsg "restoring previous active ruleset"

    rm -rf "$ACTIVE_DIR"

    if [ -d "$BACKUP_DIR/opnsense.rules" ]; then
        cp -a "$BACKUP_DIR/opnsense.rules" "$ACTIVE_DIR"
    fi

    if [ -f "$BACKUP_DIR/installed_rules.yaml" ]; then
        cp -p "$BACKUP_DIR/installed_rules.yaml" "$ACTIVE_YAML"
    else
        rm -f "$ACTIVE_YAML"
    fi
}

cleanup()
{
    if [ -n "${BACKUP_DIR:-}" ] && [ -d "$BACKUP_DIR" ]; then
        rm -rf "$BACKUP_DIR"
    fi
}

trap cleanup EXIT HUP INT TERM

for f in "$UPDATER" "$INSTALLER" "$SURICATA" "$CONFIG" "$RC"; do
    if [ ! -e "$f" ]; then
        logmsg "ABORT: required file missing: $f"
        exit 10
    fi
done

if ! "$RC" status >/dev/null 2>&1; then
    logmsg "ABORT: Suricata is not running"
    exit 11
fi

OLD_DIVERT=$(divert_count)

if [ "$OLD_DIVERT" -lt 1 ]; then
    logmsg "ABORT: no active Suricata Divert listeners found"
    exit 12
fi

OLD_PID=$(cat /var/run/suricata.pid 2>/dev/null || true)
BEFORE=$(active_hash)

logmsg "starting rule update; current PID=$OLD_PID divert_listeners=$OLD_DIVERT"

"$UPDATER"
rc=$?

if [ "$rc" -ne 0 ]; then
    logmsg "FAILED: rule-updater.py rc=$rc"
    exit "$rc"
fi

BACKUP_DIR=$(mktemp -d /root/suricata-safe-update.XXXXXX)

if [ -d "$ACTIVE_DIR" ]; then
    cp -a "$ACTIVE_DIR" "$BACKUP_DIR/opnsense.rules"
fi

if [ -f "$ACTIVE_YAML" ]; then
    cp -p "$ACTIVE_YAML" "$BACKUP_DIR/installed_rules.yaml"
fi

logmsg "installing updated rules"

"$INSTALLER"
rc=$?

if [ "$rc" -ne 0 ]; then
    logmsg "FAILED: installRules.py rc=$rc"
    restore_active
    exit "$rc"
fi

AFTER=$(active_hash)

if [ "$BEFORE" = "$AFTER" ]; then
    logmsg "no active rule changes; restart skipped"
    exit 0
fi

logmsg "active rules changed; validating new ruleset"

"$SURICATA" -T --init-errors-fatal -c "$CONFIG"
rc=$?

if [ "$rc" -ne 0 ]; then
    logmsg "FAILED: Suricata validation rc=$rc; restart NOT performed"
    restore_active
    exit "$rc"
fi

logmsg "validation passed; performing full Suricata restart"

"$RC" restart
rc=$?

if [ "$rc" -ne 0 ]; then
    logmsg "FAILED: restart rc=$rc; restoring previous ruleset"
    restore_active
    "$RC" restart
    exit 30
fi

i=0
while [ "$i" -lt 36 ]; do
    sleep 5

    NEW_DIVERT=$(divert_count)

    if "$RC" status >/dev/null 2>&1 &&
       [ "$NEW_DIVERT" -eq "$OLD_DIVERT" ]; then
        NEW_PID=$(cat /var/run/suricata.pid 2>/dev/null || true)
        logmsg "SUCCESS: PID=$NEW_PID divert_listeners=$NEW_DIVERT"
        exit 0
    fi

    i=$((i + 1))
done

logmsg "FAILED: Divert listeners did not recover within 180 seconds"
logmsg "restoring previous ruleset and restarting"

restore_active
"$RC" restart
rc=$?

if [ "$rc" -ne 0 ]; then
    logmsg "CRITICAL: rollback restart failed rc=$rc"
    exit 40
fi

logmsg "ROLLBACK completed; manual verification required"
exit 41

Set ownership and permissions:
chown root:wheel /usr/local/sbin/suricata-safe-update
chmod 0700 /usr/local/sbin/suricata-safe-update

Check shell syntax:
/bin/sh -n /usr/local/sbin/suricata-safe-update
Optional check that the wrapper itself does not contain a SIGUSR2, pkill, or kill command:
grep -nEi 'USR2|pkill|kill ' /usr/local/sbin/suricata-safe-update
No output is expected.

2. Create a configd action

Create:
/usr/local/opnsense/service/conf/actions.d/actions_suricatasafe.conf

Contents:
[update]
command:/usr/bin/lockf -k -t 0 /var/run/suricata-safe-update.lock /usr/local/sbin/suricata-safe-update
parameters:
type:script
message:safely update Suricata rules with full restart when needed
description:Suricata safe rule update (full restart, no SIGUSR2)

Set permissions:
chown root:wheel /usr/local/opnsense/service/conf/actions.d/actions_suricatasafe.conf
chmod 0644 /usr/local/opnsense/service/conf/actions.d/actions_suricatasafe.conf

Reload configd:
service configd restart
Check that the action was registered:
configctl configd actions | grep -i suricatasafe
Expected:
suricatasafe update [ Suricata safe rule update (full restart, no SIGUSR2) ]

3. Test manually before changing Cron

Check the current Suricata PID:
cat /var/run/suricata.pid
Check the current Suricata sockets:
sockstat | grep '[s]uricata'
For the actual test I recommend using detached configctl:
/usr/local/sbin/configctl -d -- suricatasafe update
A synchronous call may exceed the configctl client timeout because Hyperscan validation and startup can take several minutes.

Monitor the updater and Suricata:
ps -axww -o pid,ppid,state,etime,%cpu,%mem,rss,vsz,command | grep -E 'suricata-safe-update|suricata -T|/usr/local/bin/suricata' | grep -v grep
Check the sockets:
sockstat | grep '[s]uricata'
After the update has finished, check the PID again:
cat /var/run/suricata.pid
Check whether the new engine completed startup:
/bin/sh -c 'PID=$(cat /var/run/suricata.pid); grep "suricata $PID" /var/log/suricata/suricata_*.log | grep -E "Engine started|<Error>|<Warning>" | tail -30'
A successful start should contain something similar to:
Threads created -> W: 8 FM: 1 FR: 1  Engine started.

The number of workers/listeners depends on the system configuration.

4. Replace the normal scheduled IDS update

Go to:

System → Settings → Cron

Disable the existing:
ids rule updates

I kept the original job present but disabled, rather than deleting it, so reverting is easy.

Then create a new Cron job using:
Suricata safe rule update (full restart, no SIGUSR2)
For example, daily at 02:00:


Minutes:  0
Hours:    2
Days:      *
Months:    *
Weekdays:  *

OPNsense should generate an effective cron entry similar to:
0 2 * * * /usr/local/sbin/configctl -d -- suricatasafe update
Verify the effective cron:
grep -nE 'ids update|suricatasafe update' /var/cron/tabs/nobody
The old active command:
/usr/local/sbin/configctl -d -- ids update
should be gone.

The new active command should be:
/usr/local/sbin/configctl -d -- suricatasafe update
5. Why detached configctl -d?

On my system a real rule update plus Hyperscan validation and full Suricata restart takes longer than a synchronous configctl client waits.

During testing, a synchronous invocation produced:


error in configd communication
TimeoutError: timed out

The configd action itself continued running and completed successfully.

For scheduled execution I therefore use:
/usr/local/sbin/configctl -d -- suricatasafe update
The lockf around the wrapper prevents two update jobs from running concurrently.

6. Tested result

Tested on:


OPNsense:        26.7.2_2
Suricata:        8.0.6
IPS mode:        Divert
Pattern matcher: Hyperscan

A real rule update resulted in a full Suricata restart.

During startup the new Suricata process spent roughly two minutes at high CPU while compiling/initializing the rules.

Afterwards all eight Divert listeners on my system returned:


div4 *:8000
div4 *:8000
div4 *:8000
div4 *:8000
div4 *:8000
div4 *:8000
div4 *:8000
div4 *:8000

The log then reported:
Threads created -> W: 8 FM: 1 FR: 1  Engine started.

SHA256 of the exact wrapper version I tested:


93d4235d5c79a3ce2aba22bbc80e049601ca0d5ca88a845f24afb67ed928231f

7. Important note

This is specifically a workaround for the current Divert + Hyperscan live-reload problem described in:

OPNsense core issue #10416

The automatic path deliberately avoids:
pkill -USR2 suricata
and performs a full restart when the active ruleset changes.

A full restart introduces a short inspection interruption while Suricata starts again, so anyone using this should evaluate that behavior for their own inline setup.

The wrapper above also checks OPNsense Divert listeners on:
*:8000

because that is the Divert configuration used on my system. Anyone with a substantially different setup should review the listener detection before copying it unchanged.

This is not intended to replace Suricata's normal live-reload mechanism permanently. Once the upstream Divert/Hyperscan issue is fixed and that fix is available in OPNsense, I intend to remove this workaround and return to the stock OPNsense rule-update path.

I hope this helps somebody else also.

This applies specifically to OPNsense Suricata IPS using Divert mode + Hyperscan. Do not use this workaround for normal Netmap/IDS installations unless you understand why you need it.
#24
I just made the jump with the outbound NAT to SNAT conversion using the NAT migration tool.

This is working as expected! Thanks for that. One minor human error occurred here. When I imported the CSV file, there was a validation error with one of the (non-activated) old outbound NAT rules.
I ignored this warning because it is no longer in use.

I clicked the [green checkmark] and the window with this validation error stayed open. I clicked the green checkmark two more times and then decided to click the [ x ]to close it.

I noticed that my SNAT has now been populated with three times the same rules ;-). Maybe a control function can be added to the migration tool to prevent importing the same rules repeatedly if someone accidentally clicks the green checkmark more than once?


#25
Thanks, that works.
#26
@yourfriendarmando thanks for this. I like the color's with categories. Never used that before. I can follow your guide until the [Firewall :: Rules [New] or classic, same concept] part. (I use the [New])

Can you write the firewall rules out so it is clear what belongs to what part of the firewall-rule?

And [local_link] is missing in your guide(?)


N.B> with NAT: I assumed the Destination ::
  Invert Source:  [X] ->should be-> Invert Destination: [X]
  Source Address: This Firewall -> Destination Address: This Firewall


#27
Yeah qfeeds was enabled but it is blocking it again. I noticed qfeeds blocks legitimatie site/servers more often. Hope it gets better from user input.
#28
Thanks, and correct. Website is working again.
#29
another false positive. you seem to block https://internet.nl/ their ip.
As soon when I disable Q-feeds it is working.
#30
Hi, good ask. From my point of view there is not one way to go. There are multiple roads to follow, just what you like most.
I'm no pro on this topic, but after my extended search/reading/trying; I came to this setup:

Opnsense with Adguard Home plugin + as upstream DNS Opnsense Bind (with DNSSEC) (with NO DNS Forwarders)

This way only the DNS Root servers get queried, and not one DNS server has all your queries, most privacy other than with DoH DoT DNSCrypt.