Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetfilterQueue Implementation

I am trying to use NetfilterQueue for my project. As a beginning, I tried to run this code. You know the source.

from netfilterqueue import NetfilterQueue

def print_and_accept(pkt):
print pkt
pkt.accept()

nfqueue = NetfilterQueue()
nfqueue.bind(1, print_and_accept)
try:
nfqueue.run()
except KeyboardInterrupt:
print        

I passed it the packets filtered by the following rule

sudo iptables -I INPUT -s iitp.ac.in -j NFQUEUE --queue-num 1

I got following error

Traceback (most recent call last):
  File "pkt_desc_1.py", line 8, in <module>
    if nfqueue.bind(0, print_and_accept) < 0:
  File "netfilterqueue.pyx", line 144, in netfilterqueue.NetfilterQueue.bind (netfilterqueue.c:2665)
OSError: Failed to create queue 1.

Can anybody help ?

I am new to the topic. So, please don't mind.

like image 663
Vinay Kumar Yadav Avatar asked Dec 19 '25 05:12

Vinay Kumar Yadav


1 Answers

identify process number (type)

ps aux | grep python

it will show processes in python

root      1633  0.0  0.4  16664  8680 pts/1    T    13:03   0:00 python netfilter.py
root      1687  0.0  0.0   6136   956 pts/0    S+   13:12   0:00 grep python

use kill process (type)

kill -9 1633 

hope this helps =D

like image 120
Val Pe Avatar answered Dec 20 '25 20:12

Val Pe