Environment
Shell environment variables accessible inside the Lua config file.
Lua config file
The main
snort.lua file loaded with -c. Provides full control over all modules.Rules
Detection rules loaded via
ips.include, -R, or inline with --lua.Command line
Flags and
--lua overrides. Highest precedence — always wins over the Lua file.Command line
A typical invocation looks like:| Flag | Purpose |
|---|---|
-c snort.lua | Load the main Lua configuration file |
-R cool.rules | Load a rules file |
-r some.pcap | Read traffic from a pcap file (use -i eth0 for live) |
-A cmg | Alert format (fast + packet headers + hex payload) |
daq.batch_size value set in snort.lua.
Overriding Lua config inline
Use--lua to add or replace any Lua table without touching the config file:
Configuration file
The-c flag loads a Lua script that is executed when parsed. Start with the default snort.lua included in the distribution — it contains the essential structure.
Most module entries look like:
Include file resolution
When Snort resolves relative paths ininclude statements or module parameters, it searches in this order:
Use
include instead of Lua’s built-in dofile. The include function follows Snort’s search order; dofile executes before Snort sees the file, so you must provide absolute paths or cwd-relative paths with dofile.Global Lua variables
When running with-c, Snort injects the following read-only globals into the Lua environment before executing your config file:
Whitelist functions
When Snort is run with--warn-conf-strict, it warns on any Lua table in the config that does not map to a known module name. In --pedantic mode those warnings become errors.
To suppress warnings for custom Lua tables you intentionally define, call these functions anywhere in your config:
-v).
Strict validation flags
| Flag | Effect |
|---|---|
--warn-conf-strict | Warn on unknown Lua tables in the config |
--pedantic | Promote all warnings to errors |
Loading rules
Rules can be loaded in three ways, and they can be combined:include other rules files, so a single entry point can pull in an entire rule tree.
