Mastering Snort Configuration: A Guide to NIDS Mode and Unified2 Logging

The most important operating mode of Snort is NIDS, Network Intrusion Detection. In NIDS mode, the snort.conf file is essential. Today, let’s carefully read through the snort.conf file to understand the function of each section and what each configuration does. Along the way, we can learn about the definitions and functions of many modules, including unified2 logging.

![Insert image description here](https://www.ids-sax2.com/wp-content/uploads/picture/i-blog-csdnimg-cn-cc3054c28e5d15da070bd6a175dec743.gif#pic_center)

I have selected a configuration file I use, sourced from the snortrules-snapshot version 2.9.8.3. At the beginning of the configuration file, it explains how to configure the complete functionality.

 # This file contains a sample snort configuration. # You should take the following steps to create your own custom configuration:##  1) Set the network variables.#  2) Configure the decoder#  3) Configure the base detection engine#  4) Configure dynamic loaded libraries#  5) Configure preprocessors#  6) Configure output plugins#  7) Customize your rule set#  8) Customize preprocessor and decoder rule set#  9) Customize shared object rule set

Here is a brief explanation of each configuration step, detailing what needs to be configured. Check the parameters inside for specifics. The requirements for development do not require complete understanding, but you must know how to use them unified2 logging

StepMeaning
1Configure multiple sets of IP variables, port variables, and some path information. The IP variables and port variables are used for rules, and the paths are used to find rule and library files.
2Configure decoder alerts. Most alerts in the decoding phase are turned off.
3Configure the base detection engine parameters, such as processing delay and debug printing.
4Configure the paths for dynamic loaded libraries, dynamic rule paths, and dynamic preprocessor engines.
5Configure the enabling and disabling of preprocessors. These preprocessors convert data from certain protocols into various variables, such as Modbus operations, which can then be used by subsequent rules.
6Configure the output method in high-speed mode.
7Configure custom rule sets.
8Configure preprocessor and decoder rule sets.
9Configure shared object rule sets.

Then, explanations are provided according to the configuration file.

1) Set the network variables

 # Set the network addresses to be protected
ipvar HOME_NET any

# Set the external network addresses. In most cases, keep it as any
ipvar EXTERNAL_NET any

# List of DNS servers on your network
ipvar DNS_SERVERS $HOME_NET# List of SMTP servers on your network
ipvar SMTP_SERVERS $HOME_NET# List of web servers on your network
ipvar HTTP_SERVERS $HOME_NET# List of SQL servers on your network 
ipvar SQL_SERVERS $HOME_NET# List of telnet servers on your network
ipvar TELNET_SERVERS $HOME_NET# List of SSH servers on your network
ipvar SSH_SERVERS $HOME_NET# List of FTP servers on your network
ipvar FTP_SERVERS $HOME_NET# List of SIP servers on your network
ipvar SIP_SERVERS $HOME_NET# List of ports running web servers
portvar HTTP_PORTS [36,80,81,82,83,84,85,86,87,88,89,90,311,383,443,555,591,593,623,631,664,801,808,818,901,972,1158,1220,1270,1414,1533,1581,1719,1720,1741,1801,1812,1830,1942,2231,2301,2375,2381,2578,2809,2869,2980,3000,3029,3037,3057,3128,3443,3702,4000,4343,4592,4848,5000,5054,5060,5061,5117,5222,5250,5416,5443,5450,5480,5555,5600,5814,5894,5984,5985,5986,6080,6173,6988,7000,7001,7005,7070,7071,7080,7144,7145,7180,7181,7510,7770,7777,7778,7779,8000,8001,8008,8014,8015,8020,8028,8040,8080,8081,8082,8085,8088,8090,8095,8118,8123,8161,8180,8181,8182,8222,8243,8280,8300,8333,8344,8393,8400,8443,8484,8500,8509,8694,8787,8800,8852,8880,8888,8899,8983,9000,9001,9002,9050,9060,9080,9090,9091,9111,9200,9201,9290,9443,9447,9700,9710,9788,9830,9850,9999,10000,10080,10100,10250,10255,10297,10443,11371,12601,13014,14592,15489,16000,16992,16993,16994,16995,17000,18081,19980,29991,30007,30018,30888,33300,34412,34443,34444,36099,40007,41080,44449,49152,49153,50000,50002,50452,51423,53331,54444,55252,55555,56712]# List of ports to check for shellcode. Shellcode is a piece of code used to exploit software vulnerabilities.
portvar SHELLCODE_PORTS !80# List of ports where Oracle attacks might be seen
portvar ORACLE_PORTS 1024:

# List of ports to look for SSH connections
portvar SSH_PORTS 22# List of ports running FTP servers
portvar FTP_PORTS [21,2100,3535]# List of ports running SIP servers
portvar SIP_PORTS [5060,5061,5600]# List of file data ports for file inspection
portvar FILE_DATA_PORTS [$HTTP_PORTS,110,143]# List of GTP ports used by the GTP preprocessor
portvar GTP_PORTS [2123,2152,3386]# Other variables, do not modify
ipvar AIM_SERVERS [64.12.24.0/23,64.12.28.0/23,64.12.161.0/24,64.12.163.0/24,64.12.200.0/24,205.188.3.0/24,205.188.5.0/24,205.188.7.0/24,205.188.9.0/24,205.188.153.0/24,205.188.179.0/24,205.188.248.0/24]# Your rule file paths (can be relative paths)
var RULE_PATH ../rules
var SO_RULE_PATH ../so_rules
var PREPROC_RULE_PATH ../preproc_rules

# If using the blacklist and whitelist preprocessor, configure these
var WHITE_LIST_PATH ../rules
var BLACK_LIST_PATH ../rules

The variables here are divided into three types:

OptionMeaningExample
ipvarUsed to define a set of IPs. This definition can be a single IP, multiple IPs, a range of IPs, and can be combined with negation and union operations.ipvar EXAMPLE [1.1.1.1,2.2.2.0/24,![2.2.2.2,2.2.2.3]]
portvarUsed to define a set of ports. This definition can also be a single port, multiple ports, a range of ports, and can be combined with negation and union operations.portvar
  portvar EXAMPLE4 [!70:90]
  portvar EXAMPLE5 [80,91:95,100:200]
varUsed to define a general variable.var PREPROC_RULE_PATH …/preproc_rules

Understanding how to write variables allows you to add your own variables for use in your own rules unified2 logging

2) Configure the decoder

Decoding is one of the first processes that packets undergo in Snort. The decoder’s job is to determine which underlying protocols (such as Ethernet, IP, TCP, etc.) are used in the packet and to save this data along with the location of the payload/application data in the packet (it does not attempt to decode) and the size of that payload for use by preprocessors and the detection engine.

It sounds like organizing packet data. It mainly includes multiple configurations, explained separately according to their functions.

# Stop General Decode Events:
config disable_decode_alerts

# Stop Alerts on Experimental TCP Options
config disable_tcpopt_experimental_alerts

# Stop Alerts on Obsolete TCP Options
config disable_tcpopt_obsolete_alerts

# Stop Alerts on T/TCP
config disable_tcpopt_ttcp_alerts

# Stop Alerts on All Other TCPOption Types:
config disable_tcpopt_alerts

# Stop Alerts on Invalid IP Options
config disable_ipopt_alerts

# Enable Alerts if the Length Field (IP, TCP, UDP) Indicates a Larger Packet than Captured
config enable_decode_oversized_alerts

# Drop Packets if the Length Field Indicates a Larger Packet than Captured (Inline Mode Required)
config enable_decode_oversized_drops

# Configure IP/TCP Checksum Mode
config checksum_mode: all

Other Decode Configurations

OptionDescription
disable_decode_alertsBy default, decoder alerts are enabled – use this option to disable these alerts.
enable_decode_dropsIf in inline mode, drop packets that are alerted on.
disable_ipopt_alertsDisable alerts generated due to bad IP options.
enable_ipopt_dropsDrop packets that are alerted on due to bad IP options.
disable_tcpopt_alertsDisable alerts generated due to bad TCP options.
enable_tcpopt_dropsDrop packets that are alerted on due to bad TCP options.
disable_ttcp_alertsDisable alerts generated due to detection of T/TCP.
enable_ttcp_dropsDrop packets that are alerted on due to T/TCP detection.
disable_tcpopt_obsolete_alertsDisable alerts generated due to detection of obsolete TCP options – Skeeter, Bubba and Unassigned.
enable_tcpopt_obsolete_dropsDrop packets that are alerted on due to obsolete TCP options.
disable_tcpopt_experimental_alertsDisable alerts generated due to detection of experimental TCP options (kinds 9,10,15,20,21,22,23,24 – see http://www.iana.org/assignments/tcp-parameters for what these are).
enable_tcpopt_experimental_dropsDrop packets that are alerted on due to experimental TCP options.
enable_decode_oversized_alertsEnable alerts generated due to the length field (IP, TCP, UDP) indicating a larger packet than we captured. Note that this is the only decoder alert option that is disabled by default.
enable_decode_oversized_dropsDrop packets that are alerted on due to the header length field indicating a larger packet than we captured.
checksum_mode: all|none|noip|notcp|noudp|noicmp|ip|tcp|udp|icmpBy default checksums are computed for IP, TCP, UDP and ICMP. Use this option to disable checksum checking of specific protocols. Use a space-separated list.
checksum_drop: all|none|noip|notcp|noudp|noicmp|ip|tcp|udp|icmpBy default packets with bad checksums are not dropped if in inline mode. Use a space-separated list. Note that Snort must be doing checksums for a particular protocol in order to drop packets with bad checksums for that protocol.

Configure Flowbits Maximum Range

Flowbits detection plugins use the stream preprocessor to track rule state across protocol sessions. This is most useful for TCP sessions as it allows rules to generally track the state of application protocols.

 # Configure the maximum value for flowbits. For more information, see README.flowbits
config flowbits_size: 64

# Configure Ignored Ports
config ignore_ports: tcp 21 6667:6671 1356
config ignore_ports: udp 1:17 53

Configure Active

Configure the number of attempts to send a TCP RST in the current window of the session (so that the user receiving the TCP can accept it). This “shotgun” sequence is only useful in passive mode. In inline mode, the reset is placed directly into the stream to replace the triggering packet, so no shotgun is needed.

 # Configure active responses in non-inline mode. For more information, see README.active
config response: eth0 attempts 2

Configure DAQ

Snort 2.9 introduced DAQ or Data Acquisition library for packet I/O. DAQ replaces direct calls to libpcap functions with an abstraction layer that facilitates operation on various hardware and software interfaces without changing Snort. When invoking Snort for pcap readback or inline operation, you can select the DAQ type and mode.

 # Configure DAQ related options for inline operation. For more information, see README.daq
config daq: 
config daq_dir:
config daq_mode: config daq_var: # ::= pcap | afpacket | dump | nfq | ipq | ipfw # ::= read-file | passive | inline # ::= arbitrary = #::= path as to where to look for DAQ module so’s

Configure GID, UID, Snaplen, BPF File, and Log Path

Here are some runtime configuration parameters, which were also introduced in a previous blog post. In the following supplement, two commonly used parameters are introduced, which can be configured through runtime parameters or placed in the configuration file to take effect.

 # Configure specific UID and GID to run Snort after dropping privileges. For more information see snort -h command line options
config set_gid:
config set_uid:

# Configure default snaplen. Snort defaults to the MTU of the interface in use. For more information see README
config snaplen:

# Configure default BPF file to filter traffic. For more information see snort -h command line options (-F)
config bpf_file:

# Configure default log path. For more information see snort -h command line options (-l)
config logdir:

3) Configure the Base Detection Engine

# Configure PCRE match limitations
config pcre_match_limit: 3500
config pcre_match_limit_recursion: 1500

# Configure detection engine  See the Snort Manual, Configuring Snort - Includes - Config
config detection: search-method ac-split search-optimize max-pattern-len 20

# Configure event queue.  For more information, see README.event_queue
config event_queue: max_queue 15 log 15 order_events content_length

##
# If using GTP, enable it here
# For more information, see README.GTP
##
config enable_gtp

##
# Per packet and rule latency execution
# For more information see README.ppm
##
# Per packet latency configuration
#config ppm: max-pkt-time 250, \
#   fastpath-expensive-packets, \
#   pkt-log

# Per rule latency configuration
#config ppm: max-rule-time 200, \
#   threshold 3, \
#   suspend-expensive-rules, \
#   suspend-timeout 20, \
#   rule-log alert

##
# Configure performance profiling for debugging
# For more information see README.PerfProfiling
##
config profile_rules: print all, sort avg_ticks
#config profile_preprocs: print all, sort avg_ticks

##
# Configure protocol-aware flushing
# For more information see README.stream5
##
config paf_max: 16000

4) Configure dynamic loaded libraries

 # Path to dynamic preprocessor libraries
dynamicpreprocessor directory /usr/lib64/snort-2.9.8.3_dynamicpreprocessor/

# Path to base preprocessor engine
dynamicengine /usr/lib64/snort-2.9.8.3_dynamicengine/libsf_engine.so

# Path to dynamic rules libraries
dynamicdetection directory /usr/local/lib/snort_dynamicrules

5) Configure preprocessors

# GTP Control Channel Preprocessor. For more information, see README.GTP
preprocessor gtp: ports { 2123 3386 2152 }

# Inline packet normalization. For more information, see README.normalize
preprocessor normalize_ip4
preprocessor normalize_tcp: block, rsv, pad, urp, req_urg, req_pay, req_urp, ips, ecn stream
preprocessor normalize_icmp4
preprocessor normalize_ip6
preprocessor normalize_icmp6

# Target-based IP fragment reassembly. For more information, see README.frag3
preprocessor frag3_global: max_frags 65536
preprocessor frag3_engine: policy windows detect_anomalies overlap_limit 10 min_fragment_length 100 timeout 180

# Target-Based stateful inspection/stream reassembly. For more information, see README.stream5
preprocessor stream5_global: track_tcp yes, \
   track_udp yes, \
   track_icmp no, \
   max_tcp 262144, \
   max_udp 131072, \
   max_active_responses 2, \
   min_response_seconds 5
preprocessor stream5_tcp: policy windows, detect_anomalies, require_3whs 180, \
   overlap_limit 10, small_segments 3 bytes 150, timeout 180, \
    ports client 21 22 23 25 53 70 79 80 110 111 113 119 135 136 137 139 143 161 445 513 514 587 591 593 636 993 995 1025 1026 1027 1028 1029 1080 1433 1720 1723 1755 1863 2000 2001 2002 2049 2121 2717 3000 3128 3306 3389 3689 3690 3724 4662 4899 5000 5060 5190 5222 5223 5432 5554 5631 5666 5800 5900 6000 6001 6112 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 7000 7001 7070 8080 8081 8180 8181 8443 8888 9000 9090 10000 12345 27374 31337 32771 32772 32773 32774 32775 32776 32777 32778 32779, \
    ports both 3680 8182 8384 8585 8687 8888 8990 1103 1138 3443 4655 5556 3591 5936 2363 1636 6480 1808 8189 1972 9899 9299 3994 9995 1158 1220 1270 1414 1533 1581 1719 1720 1741 1801 1812 1830 1942 2231 2301 2375 2381 2578 2809 2869 2980 3000 3001 3029 3037 3057 3128 3300 3443 3702 4000 4343 4592 4848 5000 5050 5060 5117 5225 5250 5416 5443 5450 5480 5555 5600 5814 5894 5984 5985 5986 6080 6173 6988 7000 7001 7005 7070 7144 7145 7180 7181 7510 7777 7778 7779 7800 7801 7900 7901 7902 7903 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 7919 7920 8000 8001 8008 8014 8015 8020 8028 8040 8080 8081 8082 8085 8088 8090 8095 8118 8123 8161 8180 8181 8182 8222 8243 8280 8300 8333 8344 8393 8400 8443 8484 8500 8509 8694 8787 8800 8852 8880 8888 8899 8983 9000 9001 9002 9050 9060 9080 9090 9091 9111 9200 9201 9290 9443 9447 9700 9710 9788 9830 9850 9999 10000 10080 10100 10250 10255 10297 10443 11371 11600 11699 11980 12999 13000 13001 13029 13037 13057 13128 13300 13443 13702 13900 14000 14343 14592 14850 15000 15050 15117 15225 15250 15416 15443 15500 15555 15600 15814 15894 15984 15985 15986 16080 16173 16988 17000 17001 17005 17070 17080 17144 17145 17180 17181 17510 17777 17778 17779 17800 17801 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 8000 8001 8008 8014 8015 8020 8028 8040 8080 8081 8082 8085 8088 8090 8095 8118 8123 8161 8180 8181 8182 8222 8243 8280 8300 8333 8344 8393 8400 8443 8484 8500 8509 8694 8787 8800 8852 8880 8888 8899 8983 9000 9001 9002 9050 9060 9080 9090 9091 9111 9200 9201 9290 9443 9447 9700 9710 9788 9830 9850 9999 10000 10080 10100 10250 10255 10297 10443 11371 11600 11699 11980 12999 13000 13001 13029 13037 13057 13128 13300 13443 13702 13900 14000 14343 14592 14850 15000 15050 15117 15225 15250 15416 15443 15500 15555 15600 15814 15894 15984 15985 15986 16080 16173 16988 17000 17001 17005 17070 17080 17144 17145 17180 17181 17510 17777 17778 17779 17800 17801 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920 8000 8001 8008 8014 8015 8020 8028 8040 8080 8081 8082 8085 8088 8090 8095 8118 8123 8161 8180 8181 8182 8222 8243 8280 8300 8333 8344 8393 8400 8443 8484 8500 8509 8694 8787 8800 8852 8880 8888 8899 8983 9000 9001 9002 9050 9060 9080 9090 9091 9111 9200 9201 9290 9443 9447 9700 9710 9788 9830 9850 9999 10000 10080 10100 10250 10255 10297 10443 11371 11600 11699 11980 12999 13000 13001 13029 13037 13057 13128 13300 13443 13702 13900 14000 14343 14592 14850 15000 15050 15117 15225 15250 15416 15443 15500 15555 15600 15814 15894 15984 15985 15986 16080 16173 16988 17000 17001 17005 17070 17080 17144 17145 17180 17181 17510 17777 17778 17779 17800 17801 17900 17901 17902 17903 17904 17905 17906 17907 17908 17909 17910 17911 17912 17913 17914 17915 17916 17917 17918 17919 17920

preprocessor stream5_udp: timeout 180

# Performance statistics. For more information, see the Snort Manual, Configuring Snort - Preprocessors - Performance Monitor
preprocessor perfmonitor: time 300 file /var/snort/snort.stats pktcnt 10000

# HTTP normalization and anomaly detection. For more information, see README.http_inspect
preprocessor http_inspect: global iis_unicode_map unicode.map 1252 compress_depth 65535 decompress_depth 65535
preprocessor http_inspect_server: server default \
    http_methods { GET POST PUT SEARCH MKCOL COPY MOVE LOCK UNLOCK NOTIFY POLL BCOPY BDELETE BMOVE LINK UNLINK OPTIONS HEAD DELETE TRACE TRACK CONNECT SOURCE SUBSCRIBE UNSUBSCRIBE PROPFIND PROPPATCH BPROPFIND BPROPPATCH RPC_CONNECT PROXY_SUCCESS BITS_POST CCM_POST SMS_POST RPC_IN_DATA RPC_OUT_DATA RPC_ECHO_DATA } \
    chunk_length 500000 \
    server_flow_depth 0 \
    client_flow_depth 0 \
    post_depth 65495 \
    oversize_dir_length 500 \
    max_header_length 750 \
    max_headers 100 \
    max_spaces 200 \
    small_chunk_length {105} \
    ports { 3680 8182 8384 8585 8687 8888 8990 1103 1138 3443 5555 5915 9362 3631 6648 1808 8189 1972 1158 1220 1270 1414 1533 1581 1719 1720 1741 1801 1812 1830 1942 2231 2301 2375 2381 2578 2809 2869 2980 3000 3029 3037 3057 3128 3300 3443 3702 4000 4343 4592 4848 5000 5050 5060 5117 5225 5250 5416 5443 5450 5480 5555 5600 5814 5894 5984 5985 5986 6080 6173 6988 7000 7001 7005 7070 7144 7145 7180 7181 7510 7777 7778 7779 7800 7801 7900 7901 7902 plaintext
cmd_validity EPSV <[{ char 12| char A char L char L }]>
cmd_validity MACB < string >
cmd_validity MDTM <[date nnnnnnnnnnnnnn[.n[n[n]]]] string >
cmd_validity MODE < char ASBCZ >
cmd_validity PORT < host_port >
cmd_validity PROT < char CSEP >
cmd_validity STRU < char FRPO [ string ]>
cmd_validity TYPE <{ char AE [ char NTC ]| char I | char L [ number ]}>
preprocessor ftp_telnet_protocol: ftp client default \
    max_resp_len 256\
    bounce yes\
    ignore_telnet_erase_cmds yes\
    telnet_cmds yes
# SMTP normalization and anomaly detection. For more information, see README.SMTP
preprocessor smtp: ports {25465587691}\
    inspection_type stateful \
    b64_decode_depth 0\
    qp_decode_depth 0\
    bitenc_decode_depth 0\
    uu_decode_depth 0\
    log_mailfrom \
    log_rcptto \
    log_filename \
    log_email_hdrs \
    normalize cmds \
    normalize_cmds { ATRN AUTH BDAT CHUNKING DATA DEBUG EHLO EMAL ESAM ESND ESOM ETRN EVFY }\
    normalize_cmds { EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT RSET SAML SEND SOML }\
    normalize_cmds { STARTTLS TICK TIME TURN TURNME VERB VRFY X-ADAT X-DRCP X-ERCP X-EXCH50 }\
    normalize_cmds { X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR }\
    max_command_line_len 512\
    max_header_line_len 1000\
    max_response_line_len 512\
    alt_max_command_line_len 260{ MAIL }\
    alt_max_command_line_len 300{ RCPT }\
    alt_max_command_line_len 500{ HELP HELO ETRN EHLO }\
    alt_max_command_line_len 255{ EXPN VRFY ATRN SIZE BDAT DEBUG EMAL ESAM ESND ESOM EVFY IDENT NOOP RSET }\
    alt_max_command_line_len 246{ SEND SAML SOML AUTH TURN ETRN DATA RSET QUIT ONEX QUEU STARTTLS TICK TIME TURNME VERB X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR }\
    valid_cmds { ATRN AUTH BDAT CHUNKING DATA DEBUG EHLO EMAL ESAM ESND ESOM ETRN EVFY }\
    valid_cmds { EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT RSET SAML SEND SOML }\
    valid_cmds { STARTTLS TICK TIME TURN TURNME VERB VRFY X-ADAT X-DRCP X-ERCP X-EXCH50 }\
    valid_cmds { X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50 XGEN XLICENSE XQUE XSTA XTRN XUSR }\
    xlink2state { enabled }
# Port scan detection. For more information, see README.sfportscan
# preprocessor sfportscan: proto { all } memcap { 10000000 } sense_level { low }
# ARP spoofing detection. For more information, see the Snort Manual - Configuring Snort - Preprocessors - ARP Spoof Preprocessor
# preprocessor arpspoof
# preprocessor arpspoof_detect_host: 192.168.40.1 f0:0f:00:f0:0f:00
# SSH anomaly detection. For more information, see README.ssh
preprocessor ssh: server_ports {22}\
                  autodetect \
                  max_client_bytes 19600\
                  max_encrypted_packets 20\
                  max_server_version_len 100\
                  enable_respoverflow enable_ssh1crc32 \
                  enable_srvoverflow enable_protomismatch

# SMB/DCE-RPC normalization and anomaly detection. For more information, see README.dcerpc2
preprocessor dcerpc2: memcap 102400, events [co ]
preprocessor dcerpc2_server: default, policy WinXP, \
    detect [smb [139,445], tcp 135, udp 135, rpc-over-http-server 593], \
    autodetect [tcp 1025:, udp 1025:, rpc-over-http-server 1025:], \
    smb_max_chain 3, smb_invalid_shares ["C$", "D$", "ADMIN$"]
# DNS spoofing detection. For more information, see README.dns
preprocessor dns: ports {53} enable_rdata_overflow

# SSL anomaly detection and traffic bypass. For more information, see README.ssl
preprocessor ssl: ports {443465563636989992993994995506178017802790079017902790379047905790679077908790979107911791279137914791579167917791879197920}, trustservers, noinspect_encrypted

# SDF sensitive data preprocessor. For more information see README.sensitive_data
preprocessor sensitive_data: alert_threshold 25
# SIP session initiation protocol preprocessor. For more information see README.sip
preprocessor sip: max_sessions 40000, \
   ports {506050615600}, \
   methods { invite \
             cancel \
             ack \
             bye \
             register \
             options \
             refer \
             subscribe \
             update \
             join\
             info \
             message \
             notify \
             benotify \
             do\
             qauth \
             sprack \
             publish \
             service\
             unsubscribe \
             prack }, \
   max_uri_len 512, \
   max_call_id_len 80, \
   max_requestName_len 20, \
   max_from_len 256, \
   max_to_len 256, \
   max_via_len 1024, \
   max_contact_len 512, \
   max_content_len 2048
# IMAP preprocessor. For more information see README.imap
preprocessor imap: \
   ports {143}\
   b64_decode_depth 0\
   qp_decode_depth 0\
   bitenc_decode_depth 0\
   uu_decode_depth 0
# POP preprocessor. For more information see README.pop
preprocessor pop: \
   ports {110}\
   b64_decode_depth 0\
   qp_decode_depth 0\
   bitenc_decode_depth 0\
   uu_decode_depth 0
# Modbus preprocessor. For more information see README.modbus
preprocessor modbus: ports {502}
# DNP3 preprocessor. For more information see README.dnp3
preprocessor dnp3: ports {20000}\
   memcap 262144\
   check_crc

# Reputation preprocessor. For more information see README.reputation
preprocessor reputation: \
   memcap 500, \
   priority whitelist, \
   nested_ip inner, \
   whitelist $WHITE_LIST_PATH/white_list.rules, \
   blacklist $BLACK_LIST_PATH/black_list.rules

Here you can enable multiple preprocessors and conveniently add rule files Insert image description here

6) Configure output plugins

If you want Snort to run faster (for example, maintaining a 1000 Mbps connection), you need to use unified2 logging and a unified2 log reader, such as barnyard2. This allows Snort to log alerts as quickly as possible in binary form, while another program performs slower operations, such as writing to a database.

 # unified2 # Recommended for most installations# output unified2: filename merged.log, limit 128, nostamp, mpls_event_types, vlan_event_types# Additional configurations for specific installation types# output alert_unified2: filename snort.alert, limit 128, nostamp# output log_unified2: filename snort.log, limit 128, nostamp # Configure syslog# output alert_syslog: LOG_AUTH LOG_ALERT# pcap# output log_tcpdump: tcpdump.log# Metadata reference data. Do not modify these lines
include classification.config
include reference.config

7) Customize your rule set

 # Site-specific rules
include $RULE_PATH/local.rules
include $RULE_PATH/app-detect.rules
#include $RULE_PATH/attack-responses.rules#include $RULE_PATH/backdoor.rules#include $RULE_PATH/bad-traffic.rules#include $RULE_PATH/blacklist.rules#include $RULE_PATH/botnet-cnc.rules#include $RULE_PATH/browser-chrome.rules#include $RULE_PATH/browser-firefox.rules#include $RULE_PATH/browser-ie.rules#include $RULE_PATH/browser-other.rules#include $RULE_PATH/browser-plugins.rules#include $RULE_PATH/browser-webkit.rules#include $RULE_PATH/chat.rules#include $RULE_PATH/content-replace.rules#include $RULE_PATH/ddos.rules#include $RULE_PATH/dns.rules#include $RULE_PATH/dos.rules#include $RULE_PATH/experimental.rules#include $RULE_PATH/exploit-kit.rules#include $RULE_PATH/exploit.rules#include $RULE_PATH/file-executable.rules#nclude $RULE_PATH/file-flash.rules#include $RULE_PATH/file-identify.rules#include $RULE_PATH/file-image.rules#include $RULE_PATH/file-java.rules#include $RULE_PATH/file-multimedia.rules#include $RULE_PATH/file-office.rules#include $RULE_PATH/file-other.rules#include $RULE_PATH/file-pdf.rules#include $RULE_PATH/finger.rules#include $RULE_PATH/ftp.rules#include $RULE_PATH/icmp-info.rules#include $RULE_PATH/icmp.rules#include $RULE_PATH/imap.rules#include $RULE_PATH/indicator-compromise.rules#include $RULE_PATH/indicator-obfuscation.rules#include $RULE_PATH/indicator-scan.rules#include $RULE_PATH/indicator-shellcode.rules#include $RULE_PATH/info.rules#include $RULE_PATH/malware-backdoor.rules#include $RULE_PATH/malware-cnc.rules#include $RULE_PATH/malware-other.rules#include $RULE_PATH/malware-tools.rules#include $RULE_PATH/misc.rules#include $RULE_PATH/multimedia.rules#include $RULE_PATH/mysql.rules#include $RULE_PATH/netbios.rules#include $RULE_PATH/nntp.rules#include $RULE_PATH/oracle.rules#include $RULE_PATH/os-linux.rules#include $RULE_PATH/os-mobile.rules#include $RULE_PATH/os-other.rules#include $RULE_PATH/os-solaris.rules#include $RULE_PATH/os-windows.rules#include $RULE_PATH/other-ids.rules#include $RULE_PATH/p2p.rules#include $RULE_PATH/phishing-spam.rules#include $RULE_PATH/policy-multimedia.rules#include $RULE_PATH/policy-other.rules#include $RULE_PATH/policy.rules#include $RULE_PATH/policy-social.rules#include $RULE_PATH/policy-spam.rules#include $RULE_PATH/pop2.rules#include $RULE_PATH/pop3.rules#include $RULE_PATH/protocol-dns.rules#include $RULE_PATH/protocol-finger.rules
include $RULE_PATH/protocol-ftp.rules
#include $RULE_PATH/protocol-icmp.rules#include $RULE_PATH/protocol-imap.rules#include $RULE_PATH/protocol-nntp.rules#include $RULE_PATH/protocol-other.rules#include $RULE_PATH/protocol-pop.rules#include $RULE_PATH/protocol-rpc.rules
include $RULE_PATH/protocol-scada.rules
#include $RULE_PATH/protocol-services.rules#include $RULE_PATH/protocol-snmp.rules#include $RULE_PATH/protocol-telnet.rules#include $RULE_PATH/protocol-tftp.rules#include $RULE_PATH/protocol-voip.rules#include $RULE_PATH/pua-adware.rules#include $RULE_PATH/pua-other.rules#include $RULE_PATH/pua-p2p.rules#include $RULE_PATH/pua-toolbars.rules#include $RULE_PATH/rpc.rules#include $RULE_PATH/rservices.rules#include $RULE_PATH/scada.rules
include $RULE_PATH/scan.rules
#include $RULE_PATH/server-apache.rules#include $RULE_PATH/server-iis.rules#include $RULE_PATH/server-mail.rules#include $RULE_PATH/server-mssql.rules
include $RULE_PATH/server-mysql.rules
#include $RULE_PATH/server-oracle.rules#include $RULE_PATH/server-other.rules#include $RULE_PATH/server-samba.rules#include $RULE_PATH/server-webapp.rules#include $RULE_PATH/shellcode.rules#include $RULE_PATH/smtp.rules#include $RULE_PATH/snmp.rules#include $RULE_PATH/specific-threats.rules#include $RULE_PATH/spyware-put.rules#include $RULE_PATH/sql.rules#include $RULE_PATH/telnet.rules#include $RULE_PATH/tftp.rules#include $RULE_PATH/virus.rules#include $RULE_PATH/voip.rules#include $RULE_PATH/web-activex.rules#include $RULE_PATH/web-attacks.rules#include $RULE_PATH/web-cgi.rules#include $RULE_PATH/web-client.rules#include $RULE_PATH/web-coldfusion.rules#include $RULE_PATH/web-frontpage.rules#include $RULE_PATH/web-iis.rules#include $RULE_PATH/web-misc.rules#include $RULE_PATH/web-php.rules#include $RULE_PATH/x11.rules

Add your rule files here in conjunction with the previously defined variablesInsert image description here

8) Customize preprocessor and decoder rule set

 # Decoder and preprocessor event rules# include $PREPROC_RULE_PATH/preprocessor.rules# include $PREPROC_RULE_PATH/decoder.rules# include $PREPROC_RULE_PATH/sensitive-data.rules

9) Customize shared object rule set

# Dynamic Library Rules
# include $SO_RULE_PATH/browser-chrome.rules
# include $SO_RULE_PATH/browser-ie.rules
# include $SO_RULE_PATH/browser-other.rules
# include $SO_RULE_PATH/exploit-kit.rules
# include $SO_RULE_PATH/file-executable.rules
# include $SO_RULE_PATH/file-flash.rules
# include $SO_RULE_PATH/file-image.rules
# include $SO_RULE_PATH/file-java.rules
# include $SO_RULE_PATH/file-multimedia.rules
# include $SO_RULE_PATH/file-office.rules
# include $SO_RULE_PATH/file-other.rules
# include $SO_RULE_PATH/file-pdf.rules
# include $SO_RULE_PATH/indicator-shellcode.rules
# include $SO_RULE_PATH/malware-cnc.rules
# include $SO_RULE_PATH/malware-other.rules
# include $SO_RULE_PATH/netbios.rules
# include $SO_RULE_PATH/os-linux.rules
# include $SO_RULE_PATH/os-other.rules
# include $SO_RULE_PATH/os-windows.rules
# include $SO_RULE_PATH/policy-other.rules
# include $SO_RULE_PATH/policy-social.rules
# include $SO_RULE_PATH/protocol-dns.rules
# include $SO_RULE_PATH/protocol-nntp.rules
# include $SO_RULE_PATH/protocol-other.rules
# include $SO_RULE_PATH/protocol-scada.rules
# include $SO_RULE_PATH/protocol-snmp.rules
# include $SO_RULE_PATH/protocol-tftp.rules
# include $SO_RULE_PATH/protocol-voip.rules
# include $SO_RULE_PATH/pua-p2p.rules
# include $SO_RULE_PATH/server-apache.rules
# include $SO_RULE_PATH/server-iis.rules
# include $SO_RULE_PATH/server-mail.rules
# include $SO_RULE_PATH/server-mysql.rules
# include $SO_RULE_PATH/server-oracle.rules
# include $SO_RULE_PATH/server-other.rules
# include $SO_RULE_PATH/server-webapp.rules
# Event threshold or suppression commands. See threshold.conf
include threshold.conf

Supplement

There are many other configuration parameters not listed here, which can be found in snort_manual.pdf, in chapter 2.1. Here are a few commonly used configurations:

 ## Configure the listening interface, same as snort -i
config interface:enp1s0

## Run as a daemon, same as snort -D
config daemon

It seems that all the parameters that can be executed can be configured in the configuration file.

I am just starting to read these configuration files. If there are any misunderstandings or translation errors, please point them out. Insert image description here