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

# WCF Agent Technical Guide

> How the WCF Agent works: sync cycle, configuration, supported devices, monitoring, and troubleshooting.

## Overview

The WCF Agent is a Docker container that runs in your network. On each cycle it:

1. Reads its configuration from the OneFirewall console.
2. Downloads the list of IPv4 addresses to block.
3. Writes the list to a file, and runs a command that sends it to your device.
4. Reports the result to the console.

The agent starts all connections to OneFirewall. It needs no inbound access from the internet. You change its settings in the console, and it applies them on the next cycle without a restart.

This page is for the engineers who deploy and run the agent. It covers the `wcf-agent:v4` image. For host sizing and Docker setup, see [WCF Installation](https://docs.onefirewall.com/essentials/wcf-installation.md).

You need an agent only if your device cannot download a feed itself. If it can, as [FortiGate](https://docs.onefirewall.com/wcf-agents/fortigate.md), [Palo Alto](https://docs.onefirewall.com/wcf-agents/paloalto.md), and [pfSense](https://docs.onefirewall.com/wcf-agents/pfsense.md) can, connect it directly to OneFirewall.

## How It Works

```mermaid theme={null}
flowchart LR
  Console[OneFirewall console] -->|1. Configuration| Agent[WCF Agent]
  Console -->|2. IPv4 list| Agent
  Agent -->|3. Run command| Device[Firewall]
  Agent -->|3. Update feed| Feed[HTTP feed, port 8085]
  Clients[Firewalls that download feeds] -->|GET /blacklist.txt| Feed
  Agent -->|4. Result| Console
```

The container starts with `init.sh`. This script starts the HTTP feed server, then repeats this cycle:

| Step | Action |
| - | - |
| 1 | `init.sh` reads the connector to get `sync_time`. |
| 2 | The agent reads the connector configuration: `GET /api/v1/feedback?agid=<gaid>`. If `running` is `no`, the cycle goes to step 7. |
| 3 | The agent downloads the list: `GET /api/v1/ipv4/<score_threshold>`. A page has up to 100,000 entries. While a response has a `next_page` header, the agent requests the next page. |
| 4 | For each active integration, the agent expands the networks, applies `maximum_rules`, and writes `blacklist_onefirewall.txt` with one address per line. |
| 5 | The agent runs the integration's `command`. |
| 6 | The agent sends the command's exit code and the list: `POST /api/v1/feedback`. |
| 7 | The agent waits `sync_time` minutes (5 if not set), then starts again. |

A run is stopped if it takes more than one hour. The wait starts when the run ends, so the time between reports is the run time plus `sync_time`.

### What the List Contains

* **Addresses:** IPv4 only. OneFirewall selects the addresses at or above `score_threshold`, and applies your organization's manual blocks, unblocks, and [blocking rules](https://docs.onefirewall.com/essentials/configurations.md).
* **Order:** your manual blocks come first, then the highest scores. If `maximum_rules` cuts the list, the lowest scores are removed first.
* **Networks:** the agent replaces each network with its individual addresses. For `/30` and larger networks, it leaves out the network and broadcast addresses. For example, `198.51.100.0/29` becomes the six addresses from `.1` to `.6`. Each address counts towards `maximum_rules`.
* **Invalid entries:** the agent skips lines that are not IPv4 addresses or networks.

The agent sends the full list on every cycle, not only the changes. Each page it downloads uses [OneFirewall Coins](https://docs.onefirewall.com/essentials/ofa-coins.md), so a shorter `sync_time` uses more Coins.

## Install the Agent

### Requirements

* A Linux host with Docker and Docker Compose.
* A OneFirewall token from a user with the **Member** or **Member Admin** role. **Read Only** users cannot download the list or report results. **Member Mobile** users receive device passwords masked, so the agent cannot sign in to devices.
* These network connections:

| Direction | Port | Purpose |
| - | - | - |
| Outbound | TCP 443 to OneFirewall | Configuration, list, and results |
| Outbound | TCP 22 to the device | Check Point SecureXL and file copy (SCP) |
| Outbound | The Sophos API port | Sophos. Use the port set in `address`. |
| Inbound | TCP 8085 from your firewalls | HTTP feed, only if you use it |

This agent does not receive syslog. To send logs to OneFirewall, see [Logs & Network Events](https://docs.onefirewall.com/essentials/logs-events/logs-events.md).

### Steps

1. In the console, open the page to install a connector. Select your device, score threshold, and sync time.

2. Download the generated `docker-compose.yml` to an empty folder on the host. The file contains your token, so restrict access to it:

   ```bash theme={null}
   chmod 600 docker-compose.yml
   ```

3. In the `command` section, change `bash -x init.sh` to `bash init.sh`. The `-x` option writes the token to the container log.

4. Start the agent:

   ```bash theme={null}
   docker compose up -d
   docker compose logs -f --tail 50
   ```

5. In the console, open **Connector Status** (also called Agent Status), select the connector, and fill in the device settings. See [Integrations](#integrations).

6. After the next cycle, [check that the agent works](#check-that-the-agent-works).

If you cannot access the image, contact [support@onefirewall.com](mailto:support@onefirewall.com).

### Files

| Path on the host | Contents |
| - | - |
| `onefirewall/config/config.json` | Connection settings. The generated Compose file writes this file each time the container starts. |
| `onefirewall/db/` | Copies of past lists and other files made by the delivery scripts. |

The HTTP feed is not stored on the host. If you recreate the container, the feed is not available until the first successful cycle.

## Configuration

### Connection Settings

The agent reads these settings from `config.json`:

```json theme={null}
{
  "gaid": "OFA-AGENT-xxxxxxxx",
  "api_url": "https://app.onefirewall.com/api/v1/ipv4",
  "api_url_bulk": "https://app.onefirewall.com/api/v2/ips",
  "api_url_feedback": "https://app.onefirewall.com/api/v1/feedback",
  "auth_name": "Authorization",
  "api_jwt_key": "<your token>"
}
```

| Key | Description |
| - | - |
| `gaid` | The connector ID. It must match the connector in the console. Use a different ID for each agent. |
| `api_url` | The address of the IPv4 list. The agent also uses its server address to read the configuration. |
| `api_url_feedback` | The address for results. `init.sh` also uses it to read `sync_time`. |
| `auth_name` | The HTTP header that carries the token. Must be `Authorization`. |
| `api_jwt_key` | The OneFirewall token. |
| `api_url_bulk` | Included in the generated file. Not used in the sync cycle. |

With the generated Compose file, change these values in its `environment` section, because `config.json` is overwritten when the container starts. Then run `docker compose up -d` to apply the change.

### Console Settings

All other settings come from the connector in the console. If you add them to `config.json`, the agent ignores them.

| Key | Description |
| - | - |
| `running` | `no` pauses the agent. Any other value lets it run. |
| `score_threshold` | The minimum score to block, from 1 to 1000. Required. |
| `sync_time` | Minutes to wait between runs. |
| `maximum_rules` | The maximum number of addresses. Required: without it, the list is empty. If a network is expanded at the limit, the list can have one extra address. Set this to at least one less than the device's limit. |
| `ips` | The integrations and their settings. |

> [!WARNING]
>
> Do not remove integrations from `ips`. To turn one off, set `active` to `false`.
>
> The agent stops with an error if any of these keys is missing: `pflist`, `modsec`, `cloudflare`, `cisco`, `haproxy`, `csv`, `sophos`, `iptables`, `httpd`, `checkpoint`, `checkpoint_securexl`, `aws`.

The JSON examples below show only the integration you need to change. Edit that part of the console configuration, and keep the rest.

## Integrations

Activate **one integration per agent**. Active integrations run at the same time and share one list file, which some scripts delete. The console also keeps only the last result from each agent. To update several devices, use a separate agent, connector, and folder for each one. If they share a host, also give each agent a different host port.

| Integration | Delivery method |
| - | - |
| `httpd` | Publishes the list over HTTP |
| `checkpoint_securexl` | Loads the list into Check Point SecureXL over SSH |
| `sophos` | Updates IP host groups through the Sophos API |
| `csp` | Copies the list to another host with SCP |
| `csv`, `iptables` | Runs your own command |

> [!WARNING]
>
> In this version, `fortigate`, `checkpoint`, `cisco`, `cloudflare`, `aws`, `haproxy`, `modsec`, and `pflist` do not send any rules, even when `active` is `true`. The log says they are enabled, but the agent does not update the device or report a result. The `ids` settings have no effect either.
>
> For FortiGate, use the [FortiGate guide](https://docs.onefirewall.com/wcf-agents/fortigate.md). For Check Point, use `checkpoint_securexl` or [Check Point feeds](https://docs.onefirewall.com/wcf-agents/checkpoint-feeds.md). Other devices can use the `httpd` feed if they can download a text list.

### HTTP Feed (`httpd`)

```json theme={null}
"httpd": {
  "active": true,
  "command": "cp blacklist_onefirewall.txt httpd/blacklist.txt"
}
```

Set your firewall to download this address:

```text theme={null}
http://<agent-host>:8085/blacklist.txt
```

Use the exact path. Other unknown paths return the list too, but with a `404` status, which many firewalls treat as an error.

The feed has no password and does not use HTTPS. Make it available only on your management network. For example, publish the port on one internal address of the host:

```yaml theme={null}
ports:
  - "10.0.0.5:8085:8080"
```

Also limit which devices can connect. Docker can bypass host firewall tools such as `ufw`, so test the restriction from another machine.

### Check Point SecureXL (`checkpoint_securexl`)

```json theme={null}
"checkpoint_securexl": {
  "active": true,
  "connections": "ofa@192.0.2.10",
  "password": "<password>",
  "command": "bash artifacts/checkpoint/install-securexl.sh",
  "vsids": "1,2"
}
```

| Key | Description |
| - | - |
| `connections` | One gateway, as `user@host`. |
| `password` | The SSH password. Do not use spaces or shell special characters. |
| `vsids` | Virtual system IDs, separated by commas. It cannot be empty: without an ID, the scripts change nothing but can still report success. |

The user needs permission to run the SecureXL commands. Every script except `install-securexl-list-ip-add-remove.sh` also needs write access to `/home/ofa/` on the gateway.

Choose the script for your gateway. All the scripts are in `artifacts/checkpoint/`:

| Script | Use it for | How it updates the list | If the list is empty |
| - | - | - | - |
| `install-securexl.sh` | Gateways with blades and virtual systems | Copies the file to all blades and replaces the deny list | Keeps the current rules |
| `install-securexl-new.sh` | The same gateways, with the list kept in `$FWDIR/conf/deny_lists/` | Copies the file to that folder and all blades, then reloads the deny list | Skips the reload, but replaces the saved file with an empty one |
| `install-securexl-noblades.sh` | Gateways without blades. Set `vsids` to `"0"` so the script runs once. | Clears the deny list, then loads the new one | **Removes all rules** |
| `install-securexl-list-ip-add-remove.sh` | Gateways with virtual systems, when only changes should be sent | Adds and removes individual addresses | **Removes all the rules it added** |

`install-securexl-list-ip-add-remove.sh` does not turn on SecureXL deny lists, so turn them on first. It compares each list with `db/previous_blacklist.txt`, and updates that file before it contacts the gateway. If an update fails, the script does not retry those changes. It can also report success after a failure, so check the log.

To check the rules on the gateway, use the commands for your version in [Check Point SecureXL](https://docs.onefirewall.com/wcf-agents/secure-xl.md).

### Sophos (`sophos`)

```json theme={null}
"sophos": {
  "active": true,
  "user": "<api user>",
  "password": "<password>",
  "address": "192.0.2.20:4444",
  "command": "bash artifacts/sophos/update_blacklist_sophos.sh"
}
```

Set `address` to the Sophos host and API port, without `https://`. Do not use spaces or shell special characters in `user` or `password`. On Sophos, allow API access from the agent host.

The script creates IP host groups named `OneFirewallBlackListAutomatic0`, `OneFirewallBlackListAutomatic1`, and so on. Each group has up to 998 addresses. Add the groups to your firewall rules as described in the [Sophos guide](https://docs.onefirewall.com/wcf-agents/sophos.md).

* **Limit:** the script sends up to 26 groups, or 25,948 addresses, and ignores the rest. Set `maximum_rules` to `25000`.
* **Old groups:** if the list gets shorter, groups that are no longer needed keep their old addresses. Clear them, or remove them from your rules.
* **Status:** **OK** does not confirm that Sophos accepted the update. Check the groups in Sophos, and the API responses in the container:

  ```bash theme={null}
  docker compose exec onefirewall-wcf-agent cat /tmp/update_blacklist.log
  ```

### File Copy with SCP (`csp`)

In the configuration, the key for this integration is `csp`.

```json theme={null}
"csp": {
  "active": true,
  "connections": "ofa@192.0.2.30",
  "password": "<password>",
  "command": "bash artifacts/csp.sh",
  "feeds": "onefirewall.txt"
}
```

`feeds` is the path of the file on the destination host. A relative path starts in the user's home folder. The password cannot contain a single quote or spaces.

Lists with fewer than 95,000 lines are copied as one file. Longer lists are split into files of 94,000 lines: `onefirewall.txt`, `onefirewall-2.txt`, and so on. For the split to work, the path must have exactly one dot, before the extension.

If the list is empty, the script copies nothing and reports **OK**. If the list gets shorter, old numbered files stay on the destination host. Delete them, or they will still be used.

### Your Own Command (`csv` and `iptables`)

These integrations run `command` and add `blacklist_onefirewall.txt` to the end. The console does not create the `command` key for them, so add it yourself. The agent does not use `acl`, `reload_command`, `csv_logs`, or `csv_reload_command`.

This example copies the list to `onefirewall/db/local/list.txt` on the host:

```json theme={null}
"csv": {
  "active": true,
  "command": "bash artifacts/local.sh"
}
```

You can use your own script if it is available inside the container. Commands start in `/opt/onefirewall/WCF-Agent-latest`. Return `0` for success and another number for failure. If the list is empty, leave the device unchanged and return an error.

`iptables` does not change firewall rules by itself. The image has no `ipset` tool or `iptables` script, and the container cannot change the host's firewall by default.

## Check That the Agent Works

**1. Check the log.** A successful run includes these lines (here for `httpd`):

```text theme={null}
INFO: Download rules from:  https://app.onefirewall.com/api/v1/ipv4/150
Length 48210
INFO: IPS HTTPD Enabled
INFO: reload_rules Exit with code 0
INFO: Feedback sent
```

`Length` is the number of lines downloaded, before networks are expanded. `Punto B` in the log is the number of addresses sent to the integration.

**2. Check Connector Status.** The result and the time of the last report are separate:

| Status | Meaning |
| - | - |
| **OK** | The last reported command returned `0`. |
| **FAIL** and a number | The last reported command returned that code. See [Exit Codes](#exit-codes). |
| Green time | The last report is newer than `sync_time`. |
| Yellow time | The last report is at least `sync_time` old. This is normal for a short time, because the run time adds to the wait. |
| Red time | The last report is at least three times `sync_time` old. Check the agent. |

**3. Check the device.** Make sure the rules are there and the number of addresses is what you expect. For the HTTP feed:

```bash theme={null}
curl -fsS http://<agent-host>:8085/blacklist.txt | grep -c .
```

> [!WARNING]
>
> **OK** means that the command succeeded, not that the list is complete. Monitor the number of addresses on the device, and set an alert for zero or a sudden drop.

### If a Download Fails

| Problem | Result |
| - | - |
| The agent cannot read its configuration | The run stops. Current rules do not change. |
| The connection fails during the list download | The run stops. Current rules do not change. |
| OneFirewall returns an error for the first page, for example `402` (not enough Coins) | The list is empty, and the command still runs. The HTTP feed becomes empty. For Check Point, see the table of scripts. Sophos groups and files already copied with SCP do not change. |
| OneFirewall returns an error for a later page | The agent uses the pages it already has, so addresses on the missing pages can be unblocked. |

In the last two cases, the log shows `Invalid status code`, but Connector Status can still show **OK**. Set an alert for that message, and keep enough Coins in your balance.

If `init.sh` gets no valid response when it reads `sync_time`, it starts the next cycle without waiting. During an outage, this can cause many requests and log lines.

## Operations

| Task | What to do |
| - | - |
| Change settings | Edit the connector in **Connector Status**. A new `sync_time` applies after the next run. |
| Pause | Turn the connector off, or set `running` to `no`. Rules on the device and the HTTP feed stay as they are. The agent stops reporting, so the time turns red. |
| Remove all rules | Pause the agent and stop the container, then remove the rules or groups on the device. Stopping the agent does not remove them. |
| Restart | `docker compose restart` |
| Update | `docker compose pull && docker compose up -d`. This recreates the container if the image changed. If you use the HTTP feed, see [Files](#files). |
| Change the token | Update the token in `docker-compose.yml`, then run `docker compose up -d`. |

### Disk Space

The SecureXL scripts, except `install-securexl-noblades.sh`, and the SCP script save a copy of the list in `onefirewall/db/` each time they run. They do not delete old copies. SCP also saves the parts of split lists. Monitor disk space, and delete old copies regularly. This command deletes copies older than seven days:

```bash theme={null}
find onefirewall/db -maxdepth 1 -type f \
  -name '*.blacklist_onefirewall.txt*' -mtime +7 -delete
```

Run it from the folder that contains `docker-compose.yml`. Do not delete `previous_blacklist.txt`: `install-securexl-list-ip-add-remove.sh` needs it to find addresses to remove.

### Security

* **Protect logs:** the agent writes the full command to the log, including any device password. Limit who can read Docker logs, and do not share logs before you remove passwords and tokens.
* **Protect credentials:** limit access to `docker-compose.yml` and `onefirewall/config/`.
* **Limit who can edit connectors:** the agent runs the `command` set in the console. Anyone who can change it can run commands inside the container.
* **Use a separate account:** create a device account only for the agent, with the fewest permissions it needs. Allow it to sign in only from the agent host.
* **Isolate the agent:** use a dedicated host on a management network. Allow only the connections listed in [Requirements](#requirements).

## Troubleshooting

| Problem | Cause and solution |
| - | - |
| `ERROR: config.json file is missing` | The file is missing or is not valid JSON. Check `onefirewall/config/config.json`. |
| `401` when the agent starts | The token is missing, invalid, or expired. Change the token, and check that `auth_name` is `Authorization`. |
| `Invalid status code <402>` | There are not enough Coins. Add Coins, then check the rules on the device. |
| `Invalid status code <403>` | The user's role cannot download the list. Use a token from a **Member** or **Member Admin**. |
| The download address ends in `/undefined` | OneFirewall returned no settings for this `gaid`, or `score_threshold` is missing. Check the ID, the organization, and the connector. |
| `Cannot read properties of undefined (reading 'active')` | A required integration is missing from `ips`. Add it with `"active": false`. |
| `Running is disabled` | The connector is paused. Turn it on in the console. |
| An integration is enabled, but there is no `reload_rules` line | The integration does not send rules in this version. See [Integrations](#integrations). |
| The list is empty, but there is no download error | Check that `maximum_rules` is set and `score_threshold` is not too high. |
| The command starts with `undefined` and fails with code `127` | The `command` key is missing. Add it to the integration. |
| `ERROR: Feedback was not send` | The agent could not report its result, but the command may have worked. Check the connection and the user's role. A `409` response means another organization already uses this `gaid`. |
| The agent repeats without waiting | `init.sh` could not read `sync_time`. Check the connection, `api_url_feedback`, and the token. |

### Exit Codes

Codes depend on the script. For your own scripts, use your own codes.

| Integration | Code | Meaning |
| - | - | - |
| SecureXL | `10` | Could not connect to the gateway or turn on SecureXL |
| SecureXL | `20` | Could not copy the file to the gateway |
| SecureXL | `21` | Could not copy the file to `deny_lists` or the blades |
| SecureXL | `31` | Could not clear the deny list (`install-securexl-noblades.sh`) |
| SecureXL | `36` | Could not load the list (`install-securexl-noblades.sh`) |
| SecureXL | `38` | Could not load the list (`install-securexl.sh` or `install-securexl-new.sh`) |
| SecureXL | `40` | The list file is missing. Check that only one integration is active. |
| SCP | `10` | Could not copy the file |
| SCP | `20` | Could not find the file on the destination host after the copy |
| Any | `127` | Command not found |

## Related Pages

* [WCF Installation](https://docs.onefirewall.com/essentials/wcf-installation.md): prepare the host and install Docker.
* [Sensor Configuration](https://docs.onefirewall.com/wcf-agents/config-sensor.md): set up a connector in the console.
* [Configurations](https://docs.onefirewall.com/essentials/configurations.md): organization and agent settings.
* [API reference](https://docs.onefirewall.com/api-reference/introduction.md): the OneFirewall API.


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