network-security/SKILL.md
Use when designing, hardening, or auditing network-layer security for self-managed Debian/Ubuntu SaaS infrastructure — firewalls (nftables/UFW), WAF (ModSecurity + OWASP CRS), VPN (WireGuard, OpenVPN, IPsec), TLS/PKI ops, IDS/IPS (Suricata, Fail2ban), zero-trust, SSH hardening, DDoS mitigation, DNS security. Complements web-app-security-audit (app layer) and cicd-devsecops (secrets/CI).
npx skillsauth add peterbamuhigire/skills-web-dev network-securityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
network-security or would be better handled by a more specific companion skill.references only as needed.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.references/ directory for deep detail after reading the core workflow below.Defensive network architecture for self-managed Debian/Ubuntu SaaS infrastructure. Covers layers 3/4/7 — from nftables rules up to zero-trust identity-aware proxies.
Core principle: Defense in depth. No single control is a silver bullet. Firewall, WAF, TLS, IDS, segmentation, identity — every layer fails safely when the next one still holds.
Scope: Network-layer security on your own servers. For app-code vulnerabilities use web-app-security-audit. For secrets/CI hardening use cicd-devsecops. For Linux OS hardening beyond network use linux-security-hardening.
Cross-references: web-app-security-audit, cicd-devsecops, cicd-jenkins-debian, linux-security-hardening, microservices-architecture-models, realtime-systems
See references/ for: firewalls.md, waf.md, tls-pki.md, vpn.md, ssh-bastion.md, ids-ips.md, ddos.md, dns-security.md, zero-trust.md, crypto-fundamentals.md, network-segmentation.md, audit-checklist.md, incident-runbook.md
Before configuring a single rule, know what you are defending against.
Primary adversaries:
| Adversary | Motivation | Typical vectors | |-----------|------------|-----------------| | External opportunist | Resource theft, crypto-mining, spam relay | Exposed services, default creds, unpatched CVEs | | Targeted attacker | Data exfil, ransomware, espionage | Phishing, supply chain, 0-day, credential theft | | Insider | Data theft, sabotage | Abuse of legitimate access | | Lateral attacker | Privilege escalation after initial foothold | Weak internal segmentation, shared creds |
Defense layers (outside → in):
| # | Domain | Reference |
|---|--------|-----------|
| 1 | Host firewall (nftables/UFW) | references/firewalls.md |
| 2 | Edge WAF (ModSecurity + OWASP CRS) | references/waf.md |
| 3 | TLS/PKI operations | references/tls-pki.md |
| 4 | VPN (WireGuard, OpenVPN, IPsec) | references/vpn.md |
| 5 | SSH hardening + bastion | references/ssh-bastion.md |
| 6 | IDS/IPS + Fail2ban | references/ids-ips.md |
| 7 | DDoS mitigation | references/ddos.md |
| 8 | DNS security | references/dns-security.md |
| 9 | Zero-trust architecture | references/zero-trust.md |
Supporting reference material: references/crypto-fundamentals.md (primitives), references/network-segmentation.md (topology), references/audit-checklist.md (50-point audit), references/incident-runbook.md (5 response playbooks).
Run this against every fresh Debian 12 / Ubuntu 24.04 VPS before it serves production traffic.
apt update && apt upgrade -y
apt install -y nftables ufw fail2ban unattended-upgrades auditd rkhunter
systemctl enable --now unattended-upgrades
dpkg-reconfigure -plow unattended-upgrades
Edit /etc/apt/apt.conf.d/50unattended-upgrades to include security updates and enable automatic reboot at a quiet hour.
ufw default deny incoming
ufw default allow outgoing
ufw allow 22/tcp comment 'ssh'
ufw allow 80/tcp comment 'http'
ufw allow 443/tcp comment 'https'
ufw logging on
ufw enable
ufw status verbose
For production-grade stateful rules, migrate to nftables — see references/firewalls.md for a full /etc/nftables.conf template.
Create /etc/sysctl.d/99-network-hardening.conf:
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.conf.all.log_martians = 1
net.core.somaxconn = 4096
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_source_route = 0
Apply: sysctl --system
Edit /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
MaxAuthTries 3
LoginGraceTime 30
ClientAliveInterval 300
ClientAliveCountMax 2
X11Forwarding no
AllowAgentForwarding no
AllowUsers deploy admin
Then systemctl reload ssh. Full hardening in references/ssh-bastion.md.
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
In /etc/fail2ban/jail.local set bantime = 1h, findtime = 10m, maxretry = 5, enable [sshd] jail with nftables backend. Reload: systemctl restart fail2ban.
apt install -y certbot python3-certbot-nginx
certbot --nginx -d example.com -d www.example.com --redirect --hsts --staple-ocsp
Certbot installs a systemd timer that renews automatically. Verify: systemctl list-timers | grep certbot.
systemctl list-unit-files --state=enabled
systemctl disable --now <service>
Kill defaults you do not use: avahi-daemon, cups, rpcbind, postfix (unless you actually send mail).
ss -tlnp # which services listen on which ports
nft list ruleset # current firewall state
sshd -T | grep -iE 'permitroot|password|pubkey'
fail2ban-client status sshd
certbot certificates
server {
listen 443 ssl http2;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_timeout 1d;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always;
add_header X-Frame-Options DENY always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
add_header Content-Security-Policy "default-src 'self'" always;
# ModSecurity
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
# Rate limit
limit_req zone=api burst=20 nodelay;
limit_conn addr 10;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Full WAF setup and rule tuning: references/waf.md.
Bind to loopback or WireGuard interface only:
# postgresql.conf
listen_addresses = '127.0.0.1,10.10.0.1'
# my.cnf
bind-address = 127.0.0.1
Lock down pg_hba.conf with hostssl ... md5 from app tier CIDR only. Require TLS at the server level (ssl = on, ssl_cert_file, ssl_key_file). For multi-tenant rules, see mysql-best-practices and postgresql-administration.
bind 127.0.0.1
protected-mode yes
requirepass <strong-password>
rename-command CONFIG ""
rename-command FLUSHALL ""
rename-command FLUSHDB ""
Never expose Redis to the internet. If distributed access is needed, route via WireGuard or stunnel.
Once the perimeter is hardened, replace implicit "internal network = trusted" with explicit verification.
Minimum viable zero-trust in 3 steps:
auth_request directive.10.x address reachable only via WG peer; bind all non-public services to the WG interface.Full migration roadmap and config examples: references/zero-trust.md.
Install Suricata as IDS:
apt install -y suricata
suricata-update
systemctl enable --now suricata
Configure /etc/suricata/suricata.yaml with your external interface and HOME_NET. Alerts land in /var/log/suricata/eve.json as JSON.
Ship logs off-host to SigNoz / Loki / OpenSearch via Filebeat or Vector. Local-only logs disappear when the host is compromised.
Alert triggers to set:
Full configuration: references/ids-ips.md.
When an incident is in progress:
Five step-by-step playbooks (SSH brute force, data exfil, DDoS in progress, cert compromise, lateral movement): references/incident-runbook.md.
The full 50-point audit is in references/audit-checklist.md. Headline items:
Do not:
DynamicUser=true when possible.iptables and nftables on the same host — pick one.Domain references:
references/firewalls.md — nftables, UFW, stateful rules, DMZ, hardening templatesreferences/waf.md — ModSecurity 3, OWASP CRS, tuning, Nginx integrationreferences/tls-pki.md — TLS 1.3, Let's Encrypt, internal CA, mTLS, monitoringreferences/vpn.md — WireGuard, OpenVPN, IPsec, site-to-site, mesh patternsreferences/ssh-bastion.md — sshd_config hardening, bastion topology, MFAreferences/ids-ips.md — Suricata, Fail2ban, log shipping, alert triagereferences/ddos.md — L3/L4/L7 attack taxonomy, sysctls, edge mitigationreferences/dns-security.md — DNSSEC, DoH/DoT, split-horizon, CAA recordsreferences/zero-trust.md — BeyondCorp, IAP, mTLS, migration roadmapSupporting references:
references/crypto-fundamentals.md — 2026 primitive recommendationsreferences/network-segmentation.md — 3-tier topology, namespaces, VLANsreferences/audit-checklist.md — 50-point VPS auditreferences/incident-runbook.md — 5 response playbooksRelated skills:
web-app-security-audit — app-layer vulnerabilities (XSS, SQLi, auth flaws)cicd-devsecops — secrets management, dependency scanning, supply chaincicd-jenkins-debian — Debian server provisioning and Jenkins hardeninglinux-security-hardening — OS-level hardening beyond networkmicroservices-architecture-models — service mesh, gateway patternsrealtime-systems — WSS/TLS for WebSocket connectionsdual-auth-rbac — session + JWT authentication patternsdata-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...