【问题标题】:Python and nfqueue errorPython 和 nfqueue 错误
【发布时间】:2015-03-03 01:17:27
【问题描述】:

我正在尝试从博客下载的 python 脚本,以便在机器发出 ping 指令后发送虚假的回显回复。 问题是当我运行脚本时,它给了我这个错误:

文件“/usr/lib/python2.7/dist-packages/nfqueue.py”,第 96 行,在 create_queue def create_queue(self,*args): 返回 _nfqueue.queue_create_queue(self, *args) RuntimeError: error during nfq_create_queue()

这是绑定队列的部分:

    import nfqueue

q = None

q = nfqueue.queue()
q.open()
q.bind(socket.AF_INET)
q.set_callback(cb)
q.create_queue(0) 

try:
        q.try_run()
except KeyboardInterrupt:
        print "Exiting..." 

q.unbind(socket.AF_INET)
q.close()

错误在q.create_queue(0)上,但是我不知道怎么办!

【问题讨论】:

    标签: python


    【解决方案1】:

    获得的消息可能来自已运行的 Python 脚本执行。

    假设您的脚本文件是 pyscriptname.py,运行以下命令来检查您的脚本的另一个实例是否已经在运行:

    ps -aux | grep "pyscriptname.py" | grep -v grep | wc -l
    

    如果返回值大于0,您可以通过运行以下命令来解决问题:

    kill -9 `ps aux | grep "pyscriptname.py" | grep -v grep | awk '{print $2}'`
    

    然后,您可以再次运行您的 python 脚本:

    python pyscriptname.py
    

    【讨论】:

    • 同样的问题,没有其他脚本副本正在运行。
    【解决方案2】:

    nfqueue 需要 root 权限。所以以root身份运行脚本或在sudo下运行它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-18
      • 1970-01-01
      • 2018-08-14
      • 1970-01-01
      • 2015-02-05
      • 2010-12-03
      相关资源
      最近更新 更多