简体   繁体   中英

Hide Scapy Warning Message IPv6

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.

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 *

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM