Skip to content

Suricata

Alert on traffic from every address on a list, or drop it. Suricata matches the source address against a dataset: a list of addresses it loads from a file.

Tested with Suricata 8.0.7 and a list of 80,000 addresses. Suricata 7.0 reached its end of life in July 2026.

You need aip-sync installed and your key stored. The examples use the persistent list. They keep the rule and its list in a folder of their own, /var/lib/suricata/aip, so suricata-update leaves them alone.

Set up once

1. Fill the list. Suricata needs a file with only IPv4 addresses. --out4 writes one:

sudo mkdir -p /var/lib/suricata/aip
sudo aip-sync --list persistent --out4 /var/lib/suricata/aip/aip-persistent.lst --changes

2. Add the rule. Save this as /var/lib/suricata/aip/aip.rules, on one line:

alert ip any any -> $HOME_NET any (msg:"AIP persistent: source on the list"; ip.src; dataset:isset,aip-persistent,type ipv4,load aip-persistent.lst,hashsize 65536; sid:1990001; rev:1;)
  • ip.src; dataset:isset,... matches when the source address is in the dataset.
  • load aip-persistent.lst reads the file from the same folder as the rule.
  • type ipv4 matters. Suricata 8.0.7 and earlier refuse plain IPv4 addresses in a type ip dataset.
  • The sid must not clash with your other rules. Numbers from 1,000,000 to 1,999,999 are meant for your own rules.

To drop instead of alert, write drop instead of alert. That only works when Suricata runs inline, as an IPS. Otherwise it only alerts.

3. Tell Suricata about the rule file, and turn on the command socket. In /etc/suricata/suricata.yaml:

rule-files:
  - suricata.rules
  - /var/lib/suricata/aip/aip.rules

unix-command:
  enabled: yes

4. Check, then restart Suricata:

sudo suricata -T -c /etc/suricata/suricata.yaml
sudo systemctl restart suricata

-T loads the configuration and the rules, then exits. It reports any mistake.

Update every day

Save this as /usr/local/sbin/aip-suricata and make it executable (chmod 755):

#!/bin/sh
# Get the newest persistent list and have Suricata reload it.
set -u
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
LST=/var/lib/suricata/aip/aip-persistent.lst
aip-sync --list persistent --out4 "$LST" --changes --quiet || exit
suricatasc -c ruleset-reload-nonblocking

A rule reload reads the dataset file again. Suricata keeps working with the old rules until the new ones are ready. If aip-sync fails, the script stops with an error, and Suricata keeps the addresses it has.

Then run it every day from cron. Save this as /etc/cron.d/aip-sync, with a time after 03:30 UTC in your server's time zone:

40 3 * * * root /usr/local/sbin/aip-suricata

Check it

Look up an address from the list in the running dataset. The answer should be item found in set:

sudo suricatasc -c "dataset-lookup aip-persistent ipv4 $(head -1 /var/lib/suricata/aip/aip-persistent.lst)"

Alerts appear in fast.log and eve.json with the message AIP persistent: source on the list.

IPv6

Add a second rule with type ip, its own dataset name and sid, and a file of the IPv6 addresses, written by adding --out6 to the aip-sync line. Today every address is IPv4.