Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SCAPY send packet error OSError: [Errno 97] Address family not supported by protocol

I hit the below error when trying to send packet using:

  • Ubuntu: release 18.04
  • Python: 3.6.6
  • scapy version: 2.4.0
>>> send(IP(dst="192.168.1.1")/ICMP())
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-2-8333be02b5c1> in <module>
----> 1 send(IP(dst="192.168.1.1")/ICMP())

~/scapy/lib/python3.6/site-packages/scapy/sendrecv.py in send(x, inter, loop, count, verbose, realtime, return_packets, socket, *args, **kargs)
    298      [socket=None]) -> None"""
    299     if socket is None
--> 300         socket = conf.L3socket(*args, **kargs)
    301     return __gen_send(socket, x, inter=inter, loop=loop, count=count, verbose=verbose,
    302                       realtime=realtime, return_packets=return_packets)

~/scapy/lib/python3.6/site-packages/scapy/arch/linux.py in __init__(self, iface, type, promisc, filter, nofilter, monitor)
    405     def __init__(self, type = ETH_P_ALL, filter=None, promisc=None, iface=None, nofilter=0):
    406         self.type = type
--> 407         self.ins = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, socket.htons(type))
    408         self.ins.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 0)
    409         if iface:

/usr/lib/python3.6/socket.py in __init__(self, family, type, proto, fileno)
    142         # constructor of _socket.socket converts the given argument to an
    143         # integer automatically.
--> 144         _socket.socket.__init__(self, family, type, proto, fileno)
    145         self._io_refs = 0
    146         self._closed = False

OSError: [Errno 97] Address family not supported by protocol

Is there anything that might cause this on a fresh install of Scapy?

like image 261
user126713 Avatar asked Aug 30 '25 17:08

user126713


1 Answers

That probably would happen if you use VM or Windows Subsystem for Linux. Try standard installation, that solved the same problem for me.

like image 123
Seyed Mohsen Alavi Avatar answered Sep 02 '25 07:09

Seyed Mohsen Alavi