RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /Security and Privacy for Local AI
  6. /Ch. 8
Security and Privacy for Local AI

08. Firewall Configuration

Chapter 8 of 16 · 20 min
KEY INSIGHT

Firewall rules without monitoring are incomplete. Log dropped packets to identify blocked attacks and verify rules work as intended. Review logs weekly to catch drift from intended configuration.

Firewall configuration translates network policy into enforcement rules. For AI deployments, focus on three areas: protecting AI service ports, controlling outbound connections from AI servers, and restricting management access.

Protect AI service endpoints:

# Allow only authenticated access to Ollama API
# (If using authentication, restrict to auth proxy)
iptables -A INPUT -p tcp --dport 11434 \
    -m state --state NEW \
    -s 10.0.0.0/16 \
    -m recent --set --name OLLAMA
iptables -A INPUT -p tcp --dport 11434 \
    -m state --state NEW \
    -s 10.0.0.0/16 \
    -m recent --update --seconds 60 --hitcount 20 --name OLLAMA \
    -j DROP
# Rate limit to 20 new connections per minute per IP

# Allow web UI if exposed, through WAF/Proxy only
iptables -A INPUT -p tcp --dport 8080 -s 10.0.0.100 -j ACCEPT
# Only proxy server can reach AI web UI

Configure fail2ban for AI services:

# /etc/fail2ban/jail.d/ai-services.conf
[ollama-api]
enabled = true
port = 11434
filter = ollama-auth
logpath = /var/log/ollama.log
maxretry = 5
findtime = 600
bantime = 3600
action = iptables-allports[name=ollama-api]

# /etc/fail2ban/filter.d/ollama-auth.conf
[Definition]
failregex = ^.*Invalid API key from <HOST>.*$
            ^.*Authentication failed for.*$
ignoreregex =

Outbound restrictions for AI servers:

AI servers should generally not initiate outbound connections except to authorized internal services:

# Allow AI server to reach internal services only
iptables -A OUTPUT -p tcp --dport 5432 -d 10.0.2.10 -j ACCEPT  # PostgreSQL
iptables -A OUTPUT -p tcp --dport 6379 -d 10.0.2.11 -j ACCEPT  # Redis
iptables -A OUTPUT -p tcp --dport 9200 -d 10.0.2.12 -j ACCEPT  # Elasticsearch
iptables -A OUTPUT -p tcp --dport 22 -d 10.0.0.1 -j ACCEPT     # Management SSH

# Drop all other outbound (no direct internet access)
iptables -A OUTPUT -j DROP

IPv6 considerations:

# Also configure IPv6 firewall
ip6tables -P INPUT DROP
ip6tables -P OUTPUT DROP
ip6tables -A INPUT -i lo -j ACCEPT
ip6tables -A OUTPUT -o lo -j ACCEPT
ip6tables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
ip6tables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
EXERCISE

Configure ufw (or iptables) on your AI server to default-deny incoming connections, allow SSH from your admin IP, allow AI service ports from your internal subnet only, and block all outbound except to authorized data stores.

← Chapter 7
Network Security
Chapter 9 →
HTTPS for Local APIs