★ wanayoo — archive 1999 https://github.com/kti/python-netfilterqueue/issues/58Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind callback is not work #58

Open
patronplatform opened this issue Jul 8, 2020 · 1 comment
Open

bind callback is not work #58

patronplatform opened this issue Jul 8, 2020 · 1 comment

Comments

@patronplatform
Copy link

@patronplatform patronplatform commented Jul 8, 2020

hi guys i want to make a packet queue with this simple code :


from netfilterqueue import NetfilterQueue

def print_and_accept(pkt):
    print(pkt)


nfqueue = NetfilterQueue()
nfqueue.bind(0, print_and_accept)

but
"print_and_accept" is not fire and work !
program doesnt print packet and internet is worked well !
how ?
and how can fix it

@slrendell
Copy link

@slrendell slrendell commented Aug 8, 2020

You need to accept the packet after you print it and you need to call run on nfqueue.

from netfilterqueue import NetfilterQueue

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


nfqueue = NetfilterQueue()
nfqueue.bind(0, print_and_accept)
nfqueue.run()

You also need to insert a rule in to iptables to queue the packets.

sudo iptables -I INPUT 1 -j NFQUEUE --queue-num 0

Remove the rule after with

sudo iptables -D INPUT 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.