DEV Community

Cover image for Is your offline AI stack truly offline?
Praise James for Actian for Developers

Posted on Originally published at actian.com

Is your offline AI stack truly offline?

This article was originally published on the Actian blog.

In this tutorial, you'll run an egress audit against a self-hosted AI stack. You'll block outbound traffic with a deny-by-default firewall, record every hostname and packet the stack tries to reach, and apply offline settings until nothing gets out. You'll need a Linux environment with Docker Engine, Docker Compose, iptables, and tcpdump. The egress audit repo has the full setup.

The test stack was a local RAG app built with LlamaIndex, Actian VectorAI DB Community Edition for retrieval, Ollama running Llama 3.2 3B, a local Hugging Face embedding model, and Arize Phoenix for tracing. It answered queries with the network cut, and it still tried to call out 52 times.

The results at a glance

Run DNS lookups Blocked packets Query answered
Pre-staged (models cached) 68 52 Yes
Cold start (caches removed) 61 32 No
Hardened (offline settings) 2 1 Yes
Component Call type Requested destination Pre-staged packets Cold-start packets
Ollama Cloud catalog and model registry ollama.com, registry.ollama.ai 3 4
RAG app and Hugging Face libraries Model metadata checks and downloads huggingface.co 48 26
Arize Phoenix Remote documentation service arizeai-433a7140.mintlify.app 1 1
VectorAI DB Deployment-usage notification elspv.pervasive.com 0 1

Counts include retries, so they're higher than the number of unique requests. In the cold-start run, the packet capture recorded 31 attempts and the firewall log recorded one more from VectorAI DB.

Before you begin

The audit ran on Ubuntu 24.04 under WSL2, with all four application components in Docker containers. Clone the repo and open the project folder.

git clone https://github.com/actian-devs/developer-content.git
cd developer-content/blog/egress-audit
Enter fullscreen mode Exit fullscreen mode

Follow the README to stage the Ollama and Hugging Face models while you still have internet access. Start the stack with the base Compose file, confirm the RAG app can answer the sample query, and then move on to the audit.

1. Block outbound traffic and start monitoring

The stack's internal network keeps running, so components can talk to each other while external connections are blocked. A logging DNS sinkhole records requested hostnames, and firewall rules in Docker's DOCKER-USER chain log and reject outbound packets.

Point Docker Compose at the base file and the audit overlay, which adds the DNS sinkhole. Run this in both terminals you use for the audit.

export COMPOSE_FILE=docker-compose.yml:docker-compose.audit.yml
Enter fullscreen mode Exit fullscreen mode

Prepare the containers without starting them.

docker compose down
docker compose up --no-start
Enter fullscreen mode Exit fullscreen mode

Turn on the firewall and clear the previous DNS and kernel logs so the new records match this run.

sudo ./audit/egress-deny.sh on
sudo truncate -s 0 capture/dns.log
sudo dmesg -C
Enter fullscreen mode Exit fullscreen mode

The policy allows traffic between containers on br-rag and blocks external IPv4 egress. In the second terminal, start the packet capture before the services launch.

sudo tcpdump -i br-rag -nn -s 0 -w capture/prestaged.pcap 2>&1 | tee -i capture/prestaged.tcpdump.txt
Enter fullscreen mode Exit fullscreen mode

Back in the first terminal, start the stack and run the test query.

docker compose up -d
docker compose run --rm app --question "How long are adult patient records kept?"
Enter fullscreen mode Exit fullscreen mode

Keep the capture running for 30 more minutes to catch scheduled retries and background requests, then stop tcpdump with Ctrl+C.

sleep 1800
Enter fullscreen mode Exit fullscreen mode

The DNS sinkhole configuration is in the repo's audit/dns folder.

2. Identify and classify every outbound caller

Give each container a fixed IP address so you can match network traffic to the component that sent it.

ollama:
  networks:
    rag:
      ipv4_address: 10.77.0.11
Enter fullscreen mode Exit fullscreen mode

Save the DNS and kernel logs from the run.

sudo cp capture/dns.log capture/prestaged.dns.log
sudo TZ=UTC dmesg --time-format iso > capture/prestaged.kernel.log
Enter fullscreen mode Exit fullscreen mode

Then group outbound activity by component and destination with the summarizer script. It reads the DNS log, packet capture, firewall log, and tcpdump statistics.

sudo ./audit/summarize.sh capture/prestaged
Enter fullscreen mode Exit fullscreen mode

Pre-staged egress audit showing 68 DNS lookups and 52 blocked packets across Ollama, the RAG application, and Arize Phoenix

Classify each attempt as a setup dependency, a runtime check, or a background request. Then repeat the run with empty caches to find dependencies that would stop an offline deployment from starting.

Cold-start egress audit showing 61 DNS lookups and 32 blocked packets

In the cold-start run, Ollama tried to reach its registry and the embedding libraries tried to download model files from Hugging Face. Both failed under the firewall, so the query never completed.

Outbound activity Seen in the audit When it occurs Primary risk
Ollama model registry pull Yes, cold start Setup Needs external access to download unstaged model files
Ollama external service request Yes Runtime, startup May disclose information about the deployment and breaks zero egress
Hugging Face model download Yes, cold start Setup Missing files can stop the RAG app from starting
Hugging Face metadata checks Yes, pre-staged Runtime, during model loading May reveal model identifiers and usage metadata
Arize Phoenix documentation request Yes Runtime, at startup Contacts an external service, with no trace-data exposure established
VectorAI DB deployment-usage notification Yes, cold start Periodic background Nonessential to retrieval, and still breaks strict zero egress
Hosted embedding or inference API No, hypothetical Runtime, if configured Can send prompts or document content to an external provider

The highest risk comes from calls that carry prompts or document chunks. LlamaIndex falls back to OpenAI's hosted embeddings when Settings.embed_model doesn't point to a local model, so check that setting first. The Hugging Face Hub docs also note that hf_hub_download can check for newer versions of files already in the local cache.

3. Disable unnecessary external dependencies

Apply offline settings in a Docker Compose override file. These are the settings the hardened rerun used.

services:
  ollama:
    environment:
      - OLLAMA_NO_CLOUD=1

  phoenix:
    environment:
      - PHOENIX_ALLOW_EXTERNAL_RESOURCES=false
      - PHOENIX_TELEMETRY_ENABLED=false

  app:
    environment:
      - HF_HUB_OFFLINE=1
Enter fullscreen mode Exit fullscreen mode
  • OLLAMA_NO_CLOUD=1 turns off Ollama's cloud features.
  • HF_HUB_OFFLINE=1 stops Hugging Face libraries from making HTTP requests to the Hub.
  • The two Phoenix flags restrict external resources and turn off telemetry.

Set Settings.embed_model to a local Hugging Face embedding model, and stage every model weight and embedding file before you enforce these settings. Some background requests have no setting to turn them off. For those, keep the network block in place and document the remaining attempts.

4. Re-test and keep the evidence

Repeat the pre-staged query with the offline settings and the deny-all firewall active, then compare the results with your first capture.

Hardened egress audit after applying offline settings to the RAG components

During a 32-minute observation window, the hardened run recorded one blocked connection, the VectorAI DB deployment-usage notification, and no attempts from Ollama, the RAG app, or Phoenix. Blocked packets fell from 52 to 1, DNS lookups fell from 68 to 2, and the app still answered the test query correctly.

Save the DNS logs, packet captures, firewall logs, and query output with the configuration for each run. That record shows an auditor the app worked without external connections and traces any attempts that remain.

Closing the gap in production

The audit tested firewall isolation, DNS logging, and application-level offline settings. A production air-gapped enclave also needs the following controls.

  • Remove external network routes and restrict DNS to approved internal services.
  • Bring model weights, container images, packages, and patches in through approved, verified, and signed physical media, and document each transfer.
  • Review every monitoring or tracing service, since they handle prompts and retrieved context.

An air-gapped RAG enclave with local inference and retrieval, deny-by-default network controls, and a signed-media update path

Wrapping up

Running a model and a vector database on your own hardware doesn't remove every external dependency. With the network cut, this stack still reached for model registries, metadata checks, and background services. VectorAI DB kept retrieval working locally the whole time, and a few offline settings brought the outbound attempts down to one.

What's next

Top comments (0)