Hide Scapy Warning Message IPv6

喜欢而已 提交于 2021-01-27 07:29:20

问题


I tried multiple times to hide, but no success. Any help?

I already tried -

from scapy.all import *
import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)

Still get the same warning on console.

WARNING: No route found for IPv6 destination :: (no default route?)

FYI, I'm using Scapy with Python 2.7 on OS Mavericks.


回答1:


You need to import logging and adjust the settings for the logging message first.

What's happening is you import scapy into your namespace, trigger the error - and then change the logging settings.

import logging
logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *



回答2:


If you want to disable IPv6 in scapy but leave warnings (which is a good thing), use the following code:

from scapy.config import conf
conf.ipv6_enabled = False
from scapy.all import *

The source code of scapy.all reveals this little secret.




回答3:


I know that this question is old, but I might have found an elegant answer. Are you building IPv6 packets? If not, then what you could do is, instead of:

from scapy.all import *

Use:

from scapy.layers.inet import IP

The problem is there are two IP classes, one in the package from scapy.layers.inet and one in from scapy.layers.inet6. Should you use the former import statement, you will import both even though you are only building version 4 packets.

All of this is assuming you are intending to use IPv4 only, which I reckon is the case.



来源:https://stackoverflow.com/questions/24812604/hide-scapy-warning-message-ipv6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!