> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# [[firewall]]: add Windows Firewall rules

> Reference for [[firewall]] in bach.toml: let an app or some ports through Windows Firewall, for chosen networks, and have the rule removed with the app.

`[[firewall]]` adds Windows Firewall rules that let your app's traffic through: a server other computers connect to, or a program that is blocked by default. It needs [`installer.scope = "machine"`](/docs/guides/machine-wide-installs), like [`[[services]]`](/docs/reference/config/services).

```toml bach.toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[[firewall]]
name = "Hello server"
ports = "8080,9000-9010"             # or a single number: ports = 8080
protocol = "tcp"                     # ports need tcp or udp
networks = ["private", "domain"]     # not "public"; every network by default

[[firewall]]
name = "Hello agent"
file = "agent/agent.exe"             # a packaged .exe: any traffic of that program
direction = "in"                     # in (default) or out
```

| Setting | Default | Meaning |
| - | - | - |
| `name` | required | The rule's name in Windows Defender Firewall. Up to 128 characters; no `"` or `\`, and not `all`. |
| `file` | none | A packaged `.exe` the rule is for. The rule needs `file`, `ports` or both. |
| `ports` | none | Local ports: `8080` or `"8080,9000-9010"`. |
| `direction` | `in` | `in` lets other computers connect to the app, `out` lets the app connect out. |
| `protocol` | `any` | `any`, `tcp` or `udp`. Rules with `ports` need `tcp` or `udp`. |
| `networks` | every network | `domain`, `private`, `public`, or a list of them. |

## What to know

* Every rule allows traffic; Bach doesn't write blocking rules.
* Setup adds the rule after the files are in place, deletes an older rule of the same name first (so an update never leaves two), and deletes it when the app is removed.
* The delete is narrowed by the rule's program, direction, protocol and ports, so a rule of the same name that another program made stays.
* A setup file with `[[firewall]]` can't be an [MSI](/docs/guides/msi.md).
* `bach inspect` lists each rule as `Firewall`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.