Static configuration using sets
Sets are used to manage entries for drop and ignore policies that need to persist across restarts.
Sets overview
Location
Sets are located in Couic working directory (see working_dir configuration variable).
- bogons.couic
- zombies.couic
- infra.couic
Properties
Set file example:
# test set
# (comments and empty lines are ignored)
1.1.1.1/32
2606:4700:4700::1111/128
2.2.2.0/24A set has several properties:
- File format: a text file with the
.couicextension - Maximum size: 5MB per set file
- Name constraints: up to 48 characters; allowed characters:
[a-zA-Z0-9-_] - Scope: node-specific (not synchronized to other nodes via peering)
- Expiration: entries defined in a set never expire
- Mutability: entries defined by a set cannot be added/removed via the API
- Loading: all sets are loaded at Couic startup
- Tagging: entries from a set are tagged with the name of the set they come from
Using couicctl
couicctl drop list┌────────┬──────────────────────────┬────────────┬────────────┐
│ Policy ┆ CIDR ┆ Tag ┆ Expiration │
╞════════╪══════════════════════════╪════════════╪════════════╡
│ drop ┆ 8.8.8.8/32 ┆ ┆ never │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ drop ┆ 8.8.8.8/24 ┆ ┆ never │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ drop ┆ 1.0.0.1/32 ┆ test.couic ┆ never │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ drop ┆ 2.2.2.2/24 ┆ test ┆ never │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ drop ┆ 1.1.1.1/32 ┆ test.couic ┆ never │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ drop ┆ 2606:4700:4700::1111/128 ┆ test.couic ┆ never │
├╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
│ drop ┆ 2606:4700:4700::1001/128 ┆ test.couic ┆ never │
└────────┴──────────────────────────┴────────────┴────────────┘You can hot reload the sets on a node using the API or CLI with the command: couicctl sets reload. This command performs a differential update between the current entries in memory and the set files, ensuring that existing blocks remain unchanged if they are not modified.
Creating Sets
Add sets manually
You can create persistent file-based sets by manually creating .couic files in /var/lib/couic/sets/{drop,ignore}/. These are automatically loaded at Couic startup and can be hot-reloaded with couicctl sets reload.
couic user and have 600 permissions (read/write for owner only) for security reasons. Couic will refuse to load files with incorrect ownership or permissions.Add local network to ignore policy
sudo touch /var/lib/couic/sets/ignore/lan.couic
sudo chown couic: /var/lib/couic/sets/ignore/lan.couic
sudo chmod 600 /var/lib/couic/sets/ignore/lan.couic
sudo vim /var/lib/couic/sets/ignore/lan.couic
sudo couicctl sets reloadSets reloaded successfullyList ignore policy entries:
couicctl ignore list┌────────┬────────────────┬───────────┬────────────┐
│ Policy ┆ CIDR ┆ Tag ┆ Expiration │
╞════════╪════════════════╪═══════════╪════════════╡
│ ignore ┆ 192.168.0.0/24 ┆ lan.couic ┆ never │
└────────┴────────────────┴───────────┴────────────┘Add sets using couicctl
Block an entire ASN using RIPE database
The couicctl sets create command supports importing prefixes directly from an ASN via the RIPE NCC RIPEstat API:
couicctl sets create --from-asn AS200373 drop asn200373Fetching prefixes for ASN: AS200373
Retrieved 42 prefixes from RIPE NCC RIPEstat
Set created successfully with 42 entries
Don't forget to run 'couicctl sets reload' to apply the changesAS200373 and 200373 are valid.To apply the changes:
couicctl sets reloadImport CIDRs from a file
You can bulk-import CIDRs from a text file using the --from-file option:
# Malicious IPs from threat intel feed
203.0.113.0/24
198.51.100.0/24
# IPv6 ranges
2001:db8::/32
# Empty lines and comments are ignored
192.0.2.0/24couicctl sets create --from-file file.txt drop threat-intelReading CIDRs from file: file.txt
Loaded 4 CIDRs from file
Set created successfully with 4 entries
Don't forget to run 'couicctl sets reload' to apply the changesBulk operations with xargs
You can combine the new helpers with xargs for bulk operations:
Batch import with reload at the end
cat cidr-list.txt | xargs couicctl sets create drop blocklist && couicctl sets reload