NDC & PKI
[Day 2] 3. SNORT Rules
D
DITISS AdminWriting a SNORT Rule
- To create a rule, start with an empty text file and write the rule in it.
- Each rule is separated by a space.
- This file must be saved with a extension.
.rules
Basic Rule Syntax
Example:
plaintextalert ip any any -> any any (msg: "Any alert message"; sid: 1000001;)
Explanation of Components:
- alert: Specifies the action to take (in this case, to generate an alert).
- ip: Protocol to monitor (here, IP protocol).
- any any -> any any:
- ,
source IP->source port->direction,destination IP.destination port - : Refers to any IP address or port.
any
- (msg: "Any alert message"): Custom message to display when the rule is triggered.
- sid: A unique identifier for the rule.
- stands for "SNORT ID".
sid - This helps SNORT differentiate between multiple rules.
What This Rule Does
This particular rule generates an alert for:
- Traffic from any source IP and port,
- To any destination IP and port,
- Displaying the message: "Any alert message".
Saving the Rule
- Save this file in the folder inside the
rulesdirectory.Snort - Use any name you prefer, but the file must have the extension.
.rules
Example:
plaintextanything.rules
Linking the Rule in the Configuration
-
Open the
file.snort.conf -
Add the following line to include your custom rule file:
plaintextinclude $RULE_PATH/anything.rules -
Save the configuration file.
Testing the Rule
Run the following command to validate your new rule file:
shellsnort -i 4 -c c:\Snort\etc\snort.conf -l c:\Snort\log -T
Explanation of the Command:
- : Specifies the interface number.
-i 4 - : Path to the SNORT configuration file.
-c c:\Snort\etc\snort.conf - : Path to the log folder.
-l c:\Snort\log - : Testing mode to validate the configuration.
-T
Successful Validation
If the output states "Successfully validated", your rule file is correctly configured and ready for use.
Read Next
8/26/2026
[Day 2] 4. Network Adapters in VMWare
VMware provides several types of virtual network adapters, each with distinct behaviors for connecting virtual machines (VMs) to each other, the host...
8/26/2026
[Day 2] 5. SYSLOG Server
#### **What is a SYSLOG Server?** A SYSLOG server is a centralized system that collects, stores, and manages log messages from various devices, ser...