Input format#

Fireman reads YAML or JSON files, chosen by suffix (.yaml, .yml or .json). Both have the same layout. This page lists every field. For other formats, see Extending.

Here is the sample estate the docs use throughout:

# A small estate: one firewall, `edge`, between the internet, a DMZ and the LAN.
# The docs use it throughout. `inbound` is seeded with anomalies; `outbound` is
# clean.

addresses:
  - name: lan
    values: [10.1.0.0/16]
  - name: dmz
    values: [192.168.10.0/24]
  - name: web-servers
    values: [192.168.10.10, 192.168.10.11, 192.168.10.12]

fqdns:
  - name: update-server
    fqdn: updates.example.com
    addresses: [203.0.113.10]
    resolved_at: 2026-11-20T08:00:00Z
  - name: partner-api
    fqdn: api.partner.example
    addresses: [203.0.113.50]
    resolved_at: 2026-11-20T08:00:00Z

services:
  - name: web
    entries:
      - {protocol: 6, ports: [80, 80]}
      - {protocol: 6, ports: [443, 443]}
  - name: ssh
    entries:
      - {protocol: 6, ports: [22, 22]}
  - name: dns
    entries:
      - {protocol: 17, ports: [53, 53]}
      - {protocol: 6, ports: [53, 53]}

groups:
  # Every DMZ host except the web servers. A global group sees the global
  # `web-servers`, even inside `edge`, which has its own.
  - name: dmz-hosts
    kind: address
    include: [dmz]
    exclude: [web-servers]

firewalls:
  - name: edge
    addresses:
      # edge publishes only two of the three web servers.
      - name: web-servers
        values: [192.168.10.10, 192.168.10.11]
    policies:
      - name: inbound
        rules:
          - order_id: 10
            name: block-abusers
            action: deny
            sources: [198.51.100.0/24]
            destinations: [web-servers]
            services: [web]
          - order_id: 20
            name: allow-web
            action: accept
            sources: [any]
            destinations: [web-servers]
            services: [web]
          - order_id: 30
            name: allow-partner-https
            action: accept
            sources: [203.0.113.0/24]
            destinations: [web-servers]
            services:
              - {protocol: 6, ports: [443, 443]}
          - order_id: 40
            name: block-scanners
            action: deny
            sources: [192.0.2.0/24]
            destinations: [web-servers]
            services: [web]
          - order_id: 50
            name: allow-partner-api
            action: accept
            sources: [partner-api]
            destinations: [web-servers]
            services: [web]
          - order_id: 60
            name: allow-admin-ssh
            action: accept
            sources: [lan]
            destinations: [dmz-hosts]
            services: [ssh]
      - name: outbound
        rules:
          - order_id: 10
            name: allow-dns
            action: accept
            sources: [lan]
            destinations: [any]
            services: [dns]
          - order_id: 20
            name: allow-updates
            action: accept
            sources: [dmz-hosts]
            destinations: [update-server]
            services: [web]
          - order_id: 30
            name: allow-web-out
            action: accept
            sources: [lan]
            destinations: [lan, dmz]
            destination_negate: true
            services: [web]
          - order_id: 40
            name: allow-ping
            action: accept
            sources: [lan]
            destinations: [any]
            services:
              - {protocol: 1, icmp_type: 8}

Layout#

A file is a mapping with up to five sections, all optional:

Section

Holds

addresses

global address objects

fqdns

global FQDN objects

services

global service objects

groups

global groups

firewalls

firewalls

Each section is a list. An empty file is fine and loads nothing. A key may appear only once in each mapping (YAML << merges can still be overridden).

You can pass several files to fireman load; they are merged into one estate. Sections of the same scope are joined in file order, and a firewall or policy can be split across files: its parts are joined by name.

Firewalls and policies#

firewalls:
  - name: edge
    addresses: [] # optional: this firewall's own objects,
    fqdns: [] # which override global ones with the same name
    services: []
    groups: []
    policies:
      - name: inbound
        rules: []

Field

Type

Notes

name

name

required

addresses, fqdns, services, groups

list

optional, same as the global sections

policies

list

optional

A policy has a name and optional rules. Rules only exist inside a policy. A firewall with no sections and a policy with no rules are kept, empty.

Repeating a firewall name in one file, or a policy name in one firewall, is an error; the same name in another file is merged, as above.

See Concepts for how a firewall’s own objects override global ones.

Names#

Every object, group, firewall, policy and rule name is a string of 1 to 1024 characters with no leading or trailing whitespace and no line breaks of any kind (\r, form feeds, U+2028 and the like count too). Within one scope (global, or one firewall), names are unique across addresses, fqdns, services and groups together. The name any is reserved, and no firewall may be named global, since that names the global scope in error messages.

Rules#

- order_id: 20
  name: allow-web
  action: accept
  sources: [any]
  destinations: [web-servers]
  services: [web]

Field

Type

Default

Notes

order_id

integer

required, 0 or more, unique in the policy; lower matches first

name

name

none

unique in the policy

action

string

required, accept or deny

description

string

""

up to 1024 characters

sources

list

required, 1 to 100 unique address values

destinations

list

required, 1 to 100 unique address values

services

list

required, 1 to 100 unique service values

source_negate

boolean

false

match every source except sources

destination_negate

boolean

false

match every destination except destinations

service_negate

boolean

false

match every service except services

Rules are matched in order_id order, not file order. Reports name a rule by its name when it has one, else by its order_id.

A rule matches a packet when its source, destination and service all match. Each list matches the union of its values.

Address values#

An item in sources or destinations is one of:

  • any, which matches every address;

  • the name of an address object, FQDN object or address group;

  • an address literal: 203.0.113.7 or 198.51.100.0/24.

A name always wins over a literal that looks the same, so an object called 10.0.0.1 is used as the object. A string that is neither a visible name nor a valid literal is an error.

Service values#

An item in services is one of:

  • any, which matches every protocol and port;

  • the name of a service object or service group;

  • an inline entry, written like the entries of a service object: {protocol: 6, ports: [443, 443]}.

any and negation#

A list that contains any matches everything, even if it names other things too. That is allowed and stored as written.

The *_negate flags turn a list into its complement. The sample estate’s allow-web-out rule allows web traffic from the LAN to anywhere except the LAN and DMZ:

sources: [lan]
destinations: [lan, dmz]
destination_negate: true
services: [web]

Negating a list that contains any would match nothing, so it is rejected.

Address objects#

addresses:
  - name: web-servers
    values: [192.168.10.10, 192.168.10.11, 192.168.10.12]

Field

Type

Notes

name

name

required

values

list

required, 1 to 100 IPv4 addresses (10.0.0.1) or networks (10.0.0.0/24)

FQDNs#

An FQDN object is a domain name plus the addresses it resolved to. Fireman never looks names up: you, or the firewall export, supply the addresses.

fqdns:
  - name: update-server
    fqdn: updates.example.com
    addresses: [203.0.113.10]
    resolved_at: 2026-11-20T08:00:00Z
  - name: partner-api
    fqdn: api.partner.example
    addresses: [203.0.113.50]

Field

Type

Default

Notes

name

name

required

fqdn

string

required, a hostname such as updates.example.com

addresses

list

required, 1 to 100 IPv4 addresses or networks

resolved_at

datetime

none

when the addresses were taken; must carry a timezone

The fqdn needs at least two labels of letters, digits and hyphens (1 to 63 characters each, no hyphen at either end), and the last label can’t be all digits. Wildcards and a trailing dot are rejected. Case is kept.

FQDN objects are addresses: use them wherever an address name goes. An FQDN with no addresses is an error, since Fireman can’t know what it matches. Resolve it in your source or converter (see Extending), or remove the object and edit what uses it.

Service objects#

services:
  - name: dns
    entries:
      - { protocol: 17, ports: [53, 53] }
      - { protocol: 6, ports: [53, 53] }

Field

Type

Notes

name

name

required

entries

list

required, 1 to 100 entries

Service entries#

The protocol number decides the kind of entry.

Port entry

For TCP (6), UDP (17), DCCP (33) and SCTP (132). ports is a required, inclusive [low, high] range, each 0 to 65535. One port is written [443, 443].

{ protocol: 6, ports: [8000, 8080] }
ICMP entry

For ICMP (1). icmp_type and icmp_code are optional, each 0 to 255. No type matches all of ICMP; a type with no code matches every code of that type. A code without a type is rejected.

{protocol: 1, icmp_type: 8}               # echo request
{protocol: 1, icmp_type: 3, icmp_code: 4} # fragmentation needed
Protocol entry

Any other protocol from 0 to 255, matched by number alone, such as 47 (GRE) or 50 (ESP). It takes no other field. The IPv6-only protocols 43, 44, 58, 59, 60, 135 and 140 are rejected.

{ protocol: 47 }

Groups#

A group matches what its include names match, minus what its exclude names match.

groups:
  - name: dmz-hosts
    kind: address
    include: [dmz]
    exclude: [web-servers]

Field

Type

Default

Notes

name

name

required

kind

string

required, address or service

include

list

required, 1 to 100 unique names

exclude

list

[]

up to 100 unique names

The names must be objects or groups of the group’s own kind (FQDN objects count as addresses). A group can’t name itself, a name can’t be in both lists, groups can’t form a cycle (a → b → a), and a chain of nested groups may hold at most 64 groups (global/inventory: group 'g0' nests 65 groups deep, more than 64). The limit counts groups of one scope, so a firewall chain that ends in a global chain can reach 128. A global group only sees global names; a firewall’s group sees the firewall’s names first, then global ones.

The model behind the file#

Loading turns the file into these models (in fireman.model). Global sections become Inventory.objects, and a firewall’s sections become its objects: the files write them flat, the model nests them under Objects.

        classDiagram
    direction LR
    class Inventory {
        objects: Objects
        firewalls: Firewall[]
    }
    class Objects {
        addresses: AddressObject[]
        fqdns: FqdnObject[]
        services: ServiceObject[]
        groups: GroupT[]
    }
    class Firewall {
        name: str
        objects: Objects
        policies: Policy[]
    }
    class Policy {
        name: str
        rules: Rule[]
    }
    class Rule {
        order_id: int
        name: str | None
        action: accept | deny
        description: str
        sources: str[]
        destinations: str[]
        services: str or entry[]
        source_negate: bool
        destination_negate: bool
        service_negate: bool
    }
    class AddressObject {
        name: str
        values: address or network[]
    }
    class FqdnObject {
        name: str
        fqdn: str
        addresses: address or network[]
        resolved_at: datetime | None
    }
    class ServiceObject {
        name: str
        entries: PortEntry | IcmpEntry | ProtocolEntry[]
    }
    class GroupT {
        <<union>>
    }
    class AddressGroup {
        name: str
        kind: address
        include: str[]
        exclude: str[]
    }
    class ServiceGroup {
        name: str
        kind: service
        include: str[]
        exclude: str[]
    }
    Inventory --> Objects
    Inventory --> Firewall
    Firewall --> Objects
    Firewall --> Policy
    Policy --> Rule
    Objects --> AddressObject
    Objects --> FqdnObject
    Objects --> ServiceObject
    Objects --> GroupT
    GroupT <|-- AddressGroup
    GroupT <|-- ServiceGroup
    

From Python, the same models validate dictionaries directly:

from fireman.model import Rule

rule = Rule.model_validate(
    {"order_id": 10, "action": "accept", "sources": ["any"], "destinations": ["10.0.0.0/24"], "services": ["any"]}
)

Strict input#

Fireman rejects bad values and never fixes them up:

  • No type coercion: order_id: "10" and ports: ["80", 80] are errors. In YAML, write numbers unquoted and addresses as plain strings.

  • Networks must not have host bits set: 10.1.0.0/16 is fine, 10.1.0.1/16 is an error.

  • Networks are written in CIDR form, exactly as Fireman would print them: 10.0.0.0/8, not a netmask (10.0.0.0/255.0.0.0), a hostmask (10.0.0.0/0.255.255.255) or a zero-padded prefix (10.0.0.0/08). Addresses take no zero-padded octets either (010.0.0.1 is an error).

  • IPv4 only. IPv6 addresses, networks and IPv6-only protocols are rejected.

  • Unknown keys are errors, at every level, so typos don’t pass silently.

  • Lists that must be unique (sources, include, …) reject duplicates rather than dropping them.

Load errors#

fireman load reports every problem it finds in one go, one per line, and stores nothing. It checks in three stages, and a later stage only runs once the earlier ones pass:

  1. File structure: parse errors, repeated keys, unknown sections, sections that aren’t lists, firewalls or policies without a name or repeated in the file. These lines start with the file name and the location in the file. Repeated keys are reported on their own, by line in YAML.

    bad.yaml: rules: Rules belong in a policy
    bad.yaml: firewalls.0.colour: Unknown section
    bad.yaml: firewalls.1.name: duplicate firewall 'edge'
    
    dup.yaml: line 6: duplicate key 'rules'
    
  2. Each item on its own: fields, types and values. These lines start with the scope, the section and the item’s index in it (from 0), then the field.

    global/addresses[0].values.0.network: Input is not a valid IPv4 network
    global/fqdns[0].fqdn: invalid FQDN '*.example.com'
    global/fqdns[1].resolved_at: Input should have timezone info
    global/services[0].entries.0.port.ports.0: Input should be a valid integer
    global/services[1].entries.0.icmp: icmp_code 0 needs an icmp_type
    global/services[2].entries.0.protocol.protocol: protocol 58 is IPv6-only, and IPv6 is not supported
    global/groups[0]: Unable to extract tag using discriminator 'kind'
    edge/inbound/rules[0].order_id: Input should be a valid integer
    edge/inbound/rules[0].colour: Extra inputs are not permitted
    edge/inbound/rules[1].sources: duplicate values: 'any'
    edge/inbound/rules[2]: sources cannot negate 'any', it would match nothing
    

    The entry kind (port, icmp, protocol, or network/address for address values) shows up in the path, so you can see which kind Fireman took the value for. A missing kind on a group reads as “Unable to extract tag”. An empty list reads values: Tuple should have at least 1 item after validation, not 0.

  3. The whole estate: duplicate names, unknown names, wrong kinds, kind changes in overrides, group cycles and groups nested too deep.

    global/inventory: duplicate name 'dup'
    global/inventory: name 'any' is reserved
    edge/inbound/inventory: duplicate rule order_id 10
    global/inventory: group cycle: a -> b -> a
    edge/inventory: overrides 'lan' (address) with service
    edge/inbound/inventory: rule 10 sources: unknown address name or invalid address 'lna'
    edge/inbound/inventory: rule 10 services: unknown service name 'ssh'
    edge/inbound/inventory: rule 30 sources: 'lan' is service, expected address
    edge/inbound/inventory: rule 'web' destinations: unknown address name or invalid address '10.0.0.1/8'
    

    Duplicates inside one scope are reported first; the cross-checks on names follow once they are fixed.