Let's AI Opnsense!

Started by gmcfarling, July 02, 2025, 04:02:34 PM

Previous topic - Next topic
Hi,

I am a programmer, well soon to retire programmer, but I have an itch today.  I have been an advanced user of OPNsense for years and I have built from ground up many routers as well as used Protectli hardware.  I am currently running their latest and greatest.  I think tweakers like myself that make changes all the time and get into hot water and the wife comes in and asks "are you messing with my internet again!" then I pull out a "safe copy" of backup and presto problem gone we want to do this smarter.  Here is a new idea how about we make our own LLM?  We make a local AI that we can load a document of a backup configuration and it reads it and we can ask AI what we can do better?  No information about our LAN goes into the wild, but the wild comes to us and gets fresh updates from team OPNsense so we can have a safer network?

Gary M.

July 02, 2025, 06:06:54 PM #1 Last Edit: July 02, 2025, 07:38:11 PM by meyergru
I thought it was hot here in Germany, but you must live somewhere way hotter... ;-)

The day an AI can do that (i.e.: meaningfully, not: at all), I am going to retire. Speaking of my own experience, you could throw me an OpnSense configuration file without context and I could not even guess what you are up to. We see that all day with questions here: no context, just "It does not work". So, I guess you would at least need some more information, like network topology and some other stuff.

When I tried with ChatGPT, all it could do was to tell me how my sysctl settings were "safe"...
Intel N100, 4* I226-V, 2* 82559, 16 GByte, 500 GByte NVME, Leox LXT-010H-D

1100 down / 450 up, Bufferbloat A+

One way to do this is to use a local llm model and set up an mcp server that describes the API endpoints in a language the LLM understands.

If you search for opnsense mcp server you might find something.
Hardware:
DEC740

August 14, 2026, 06:09:02 AM #3 Last Edit: August 14, 2026, 06:11:18 AM by patlegu
Hello,

I've done some experiment around AI and opnsense. I start last year by training a SLM with some opnsense functions, less than 12, to see how it goes. Two month later, my Lora was working well with the 102 functions and I decide to make a lab to check what it can do alone on a real opnsense connected directly to internet.

My lab was an Agentic SOC (Security Operation Center) with 3 kind of SLMs (1 opnsense, 1 SOC, 1 CERT). The purpose was to check what was possible to do with some small servers without GPU. You can find some informations on this here . It has worked pretty good and the opnsense agent was able to had or remove some rules to the firewall. It's not what you have in mind but can give some ideas. It worked well, in the sense that more specialized agents had to be created as the attacks occurred.

I've tried after that to go from the side-car version to the full opnsense integrated SLM. version. Still in French. It was working pretty good excepted that you have to have more CPU and RAM due to inference directly in the box.

I hope this information regarding the use of SLMs with OPNsense has been helpful.

I am currently looking into whether this operational approach using LoRAs (OPNsense, WireGuard, CrowdSec) is still relevant, given how much LLMs have evolved over the past eight months.
I have started a new project(English) addressing various issues related to managing sensitive information in cybersecurity, particularly concerning firewalls—specifically, how to use an LLM without compromising sovereignty or the confidentiality of configurations. With a small testing interface. Should have bug as it's under heavy dev for the moment.

I hope I haven't been too long-winded or boring.
Pat.

1. I hope you are aware of one unsolvable trust problem once the models or # of tokens get too big to handle with a local LLM: Even if you limit the model to read-only access and implement user safeguards a.s.o.: the user must still trust big tech by using their AIs.

Keep in mind, that there are lots of sensitive data in the firewall configurations, ranging from VPN keys to potentially, CA private keys.
To see where I am going with this, just read this in a similarly sensitive context - the author of that tool does either not comprehend of what he is doing or he really is a sock-puppet (also, at the time he first presented his project, he had no verifiable history in the tech community). He even claims that his tool is "The Proxmox MCP you can hand the keys" - yet all of his attempts are futile in that he is neither an expert in Proxmox nor AI models and he cannot even program himself (all is done by Claude).

I sure hope you do not fall for the same misconceptions.

2. That being said, your links do not work at this time. I always get a 404, so I cannot verify or try out anything you have done - I would never do that on a production machine, BTW and urge others to apply the same caution. There have been attempts lately to lure unaware OpnSense users into installing tools on their boxes, up to creating a facade company website with a catchy name. So, I also hope the moderators are closely watching this.

By now, I would say: Let's not AI OpnSense if the MCP server is implemented in a way that makes non-local LLMs neccessary or needs anything installed on the box itself. I know that is a high hurdle, but hey!
Intel N100, 4* I226-V, 2* 82559, 16 GByte, 500 GByte NVME, Leox LXT-010H-D

1100 down / 450 up, Bufferbloat A+

August 14, 2026, 05:52:26 PM #5 Last Edit: August 14, 2026, 05:56:16 PM by patlegu
Hello,

The pages should be accessibles now; there were some minor issues with the site's geographic exclusion settings.

No worries, I understand your point of view. I'm not trying to sell anything. What you'll find in my notebook (nope.breizhland.eu) is strictly for my personal use. I log my tests there, along with site translations for quick reference, cheat sheets, and so on. If others find it useful, that's great, but it's not the primary goal. To circle back to my previous message: all my tests are run on the CPU using SLMs (Small Language Models) with the lightest possible system footprint. The results aren't always perfect, but that's part of the game.

My colleagues didn't think a practical implementation was possible, but it turned out to be—thanks to automation tools (OpenTofu, Ansible, etc.) that dynamically manage the creation and teardown of SLMs as supplementary resources. Admittedly, at the individual SLM level, it's 10 times slower on a CPU, but it costs 25 to 30 times less. You can have multiple SLMs processing incident queues or work orders. I'm not claiming this is *the* solution, but others might well find it useful at some point. Or not. :-) I don't use an MCP server; I rely solely on custom-built corpora. Training and validation are based on JSONL files containing thousands of lines, which serve as the foundation for training these LoRAs.

As for my current project, I'm simply exploring ways to use SaaS-based LLMs while keeping sensitive information out of their reach. I don't claim the results will be definitive. We'll see—the project might not pan out—but I'll have learned a lot along the way.

Regarding firewall security, I completely agree. Adding an internal AI component only increases the attack surface; this test was intended solely to observe the potential outcome. Nothing was deployed to production based on this, and I certainly wouldn't recommend doing so—quite the opposite, in fact.

In any case, thanks for the feedback. Have a great day.
Pat.

I almost forgot: all these "projects" are merely PoCs and have no other value. They should not be put into production as-is.

Coincidentally this video was published today https://youtu.be/a3RI4DjFBzw

Yes, and ironically, NetworkChuck gave the root API key to the AI agent... :-(

Well, before that he bought a chinese box with RealTek NICs, so what could we expect?
Intel N100, 4* I226-V, 2* 82559, 16 GByte, 500 GByte NVME, Leox LXT-010H-D

1100 down / 450 up, Bufferbloat A+