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

Closed
unloadble opened this issue Jul 8, 2020 · 2 comments
Closed

bind callback is not work #58

unloadble opened this issue Jul 8, 2020 · 2 comments

Comments

@unloadble
Copy link

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 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

@oremanj
Copy link
Owner

oremanj commented Jan 12, 2022

Reply is correct, closing this since it hasn't seen any activity.

@oremanj oremanj closed this as completed Jan 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants