# phaedonv/netban architecture

> Architecture diagram of the GitHub repository phaedonv/netban, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phaedonv/netban
- Repository: https://github.com/phaedonv/netban

## Overview

netban is a manual Linux IPv4 subnet-ban tool. The principal workflow takes a network and optional duration or permanent flag, then installs a temporary or permanent ban in nftables; permanent bans are also recorded for restoration. Other documented operations list bans and drop counters, unban networks, restore permanent entries, and purge runtime bans. The README documents behavior but no source excerpts were provided, so the graph uses only documented relationships and does not infer internal call structure.

Main entry points: [`netban`](https://github.com/phaedonv/netban/blob/main/netban) (netban command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Ban commands"]
  node_netban["netban command"]
  node_normalize["Subnet normalization"]
  node_ban_actions["Ban actions"]
  node_list_status["List and counters"]
  node_unban_purge["Unban and purge"]
end

subgraph group_firewall["Firewall state"]
  node_nftables["nftables rules"]
  node_kernel_sets[("Kernel ban sets")]
end

subgraph group_persistence["Persistence and restore"]
  node_permanent_list["Permanent list"]
  node_systemd["systemd service"]
end

node_operator(("Operator"))

node_operator -->|"runs command"| node_netban
node_netban -->|"masks host bits"| node_normalize
node_netban -->|"dispatches ban"| node_ban_actions
node_ban_actions -->|"installs rules"| node_nftables
node_nftables -->|"maintains sets"| node_kernel_sets
node_ban_actions -->|"records permanent"| node_permanent_list
node_operator -->|"requests status"| node_list_status
node_list_status -->|"shows bans and drops"| node_kernel_sets
node_list_status -->|"shows saved bans"| node_permanent_list
node_operator -->|"requests removal"| node_unban_purge
node_unban_purge -->|"removes runtime rules"| node_nftables
node_systemd -->|"runs restore"| node_netban
node_netban -->|"reads for restore"| node_permanent_list
node_netban -->|"reloads permanent bans"| node_nftables

click node_netban "https://github.com/phaedonv/netban/blob/main/netban"
click node_normalize "https://github.com/phaedonv/netban/blob/main/netban"
click node_ban_actions "https://github.com/phaedonv/netban/blob/main/netban"
click node_list_status "https://github.com/phaedonv/netban/blob/main/netban"
click node_unban_purge "https://github.com/phaedonv/netban/blob/main/netban"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_netban,node_normalize,node_ban_actions,node_list_status,node_unban_purge toneBlue
class node_nftables,node_kernel_sets toneAmber
class node_permanent_list,node_systemd toneMint
class node_operator toneIndigo
```

## Components

### Ban commands

- [netban command](https://github.com/phaedonv/netban/blob/main/netban): `netban`
- [Subnet normalization](https://github.com/phaedonv/netban/blob/main/netban): `netban`
- [Ban actions](https://github.com/phaedonv/netban/blob/main/netban): `netban`
- [List and counters](https://github.com/phaedonv/netban/blob/main/netban): `netban`
- [Unban and purge](https://github.com/phaedonv/netban/blob/main/netban): `netban`

### Firewall state

- **nftables rules**
- **Kernel ban sets**

### Persistence and restore

- **Permanent list**
- **systemd service**

### Other components

- **Operator**

## Connections

- Operator → netban command: runs command (evidence: `README.md`)
- netban command → Subnet normalization: masks host bits (evidence: `README.md`)
- netban command → Ban actions: dispatches ban (evidence: `README.md`)
- Ban actions → nftables rules: installs rules (evidence: `README.md`)
- nftables rules → Kernel ban sets: maintains sets (evidence: `README.md`)
- Ban actions → Permanent list: records permanent (evidence: `README.md`)
- Operator → List and counters: requests status (evidence: `README.md`)
- List and counters → Kernel ban sets: shows bans and drops (evidence: `README.md`)
- List and counters → Permanent list: shows saved bans (evidence: `README.md`)
- Operator → Unban and purge: requests removal (evidence: `README.md`)
- Unban and purge → nftables rules: removes runtime rules (evidence: `README.md`)
- systemd service → netban command: runs restore (evidence: `README.md`)
- netban command → Permanent list: reads for restore (evidence: `README.md`)
- netban command → nftables rules: reloads permanent bans (evidence: `README.md`)
