[Day 10] 3. NFQueue and the IPS mode of Suricata
NFQueue:
NFQueue is a feature of Linux's Netfilter framework that allows packets to move from the kernel to user space. This lets applications like Suricata inspect and modify packets. If NFQueue support is missing, Suricata can't interact with iptables to inspect and block packets, so you won’t be able to proceed further.
Lab Setup:
- Debian 1: Suricata configured with iptables.
- Debian 2: Used to ping Debian 1.
Pre-requisite:
- Suricata must be configured on your system.
Steps to Set Up Suricata with NFQueue:
1. Check if Suricata has NFQueue support:
Run this command to verify:
bashsuricata --build-info | grep NFQueue
You should see:
plaintextNFQueue support: yes
If it doesn’t show this, do not proceed.
2. Edit Suricata's .yaml
configuration file:
.yamlOpen Suricata's configuration file:
bashsudo nano /etc/suricata/suricata.yaml
Search for
nfq:plaintextmode: accept repeat-mark: 1 repeat-mask: 1 route-queue: 2
Uncomment these lines.
3. Install iptables:
Check if iptables is installed:
bashsudo which iptables
If not, install it:
bashsudo apt-get install iptables -y
Then add the following rules:
bashsudo iptables -I INPUT -p icmp -j NFQUEUE --queue-num 2
sudo iptables -I OUTPUT -p icmp -j NFQUEUE --queue-num 2
- : Insert the rule.
-I - : Specifies the protocol (ICMP in this case).
-p - : Jumps to queue 2.
-j
4. Add a rule in local.rules
:
local.rulesEdit Suricata’s local rules file:
bashsudo nano /etc/suricata/rules/local.rules
Add the following rule to block ICMP:
plaintextdrop icmp any any -> any any (msg: "Kuch Bhi Block ICMP"; sid: 123; rev: 1;)
5. Stop Suricata:
Stop Suricata to apply changes:
bashsudo systemctl stop suricata
sudo systemctl status suricata
6. Run Suricata in IPS Mode:
Run Suricata to listen on queue 2:
bashsudo suricata -c /etc/suricata/suricata.yaml -q 2
7. Test with a Ping from the Second Machine:
On Debian 2, ping Debian 1:
bashping <deb1_ip>
8. Check Suricata Logs:
Check Suricata logs to see the blocked ICMP packet:
bashsudo tail -f /var/log/suricata/fast.log
You should see the packet was sent to Debian 1 but was blocked, with the message "Kuch Bhi Block ICMP".
Read Next
[Day 10] 4. Elasticsearch Logstash Kibana (ELK)
### **What is ELK?** ELK stands for **Elasticsearch, Logstash, and Kibana**. It is a set of tools used for searching, analyzing, and visualizing la...
[Day 11] 1. Logstash
## **Logstash** Logstash is a **server-side data processing pipeline**. It is a tool used to collect, process, and forward data. Logstash helps to...