scapy.interfaces

Interfaces management

class scapy.interfaces.InterfaceProvider[source]

Bases: object

header_sort = 1
headers = ('Index', 'Name', 'MAC', 'IPv4', 'IPv6')
l2listen() Type[scapy.supersocket.SuperSocket][source]

Return L2listen socket used by interfaces of this provider

l2socket() Type[scapy.supersocket.SuperSocket][source]

Return L2 socket used by interfaces of this provider

l3socket() Type[scapy.supersocket.SuperSocket][source]

Return L3 socket used by interfaces of this provider

libpcap = False
load() Dict[str, scapy.interfaces.NetworkInterface][source]

Returns a dictionary of the loaded interfaces, by their name.

name = 'Unknown'
reload() Dict[str, scapy.interfaces.NetworkInterface][source]

Same than load() but for reloads. By default calls load

class scapy.interfaces.NetworkInterface(provider: scapy.interfaces.InterfaceProvider, data: Optional[Dict[str, Any]] = None)[source]

Bases: object

is_valid() bool[source]
l2listen() Type[scapy.supersocket.SuperSocket][source]
l2socket() Type[scapy.supersocket.SuperSocket][source]
l3socket() Type[scapy.supersocket.SuperSocket][source]
update(data: Dict[str, Any]) None[source]

Update info about a network interface according to a given dictionary. Such data is provided by providers

class scapy.interfaces.NetworkInterfaceDict[source]

Bases: collections.UserDict

Store information about network interfaces and convert between names

dev_from_index(if_index: int) scapy.interfaces.NetworkInterface[source]

Return interface name from interface index

dev_from_name(name: str) scapy.interfaces.NetworkInterface[source]

Return the first network device name for a given device name.

dev_from_networkname(network_name: str) NoReturn[source]

Return interface for a given network device name.

load_confiface() None[source]

Reload conf.iface

register_provider(provider: type) None[source]
reload() None[source]
show(print_result: bool = True, hidden: bool = False, **kwargs: Any) Optional[str][source]

Print list of available network interfaces in human readable form

Parameters
  • print_result – print the results if True, else return it

  • hidden – if True, also displays invalid interfaces

scapy.interfaces.dev_from_index(if_index: int) scapy.interfaces.NetworkInterface[source]

Return interface for a given interface index

scapy.interfaces.dev_from_networkname(network_name: str) scapy.interfaces.NetworkInterface[source]

Return Scapy device name for given network device name

scapy.interfaces.get_if_list() List[str][source]

Return a list of interface names

scapy.interfaces.get_working_if() scapy.interfaces.NetworkInterface[source]

Return an interface that works

scapy.interfaces.get_working_ifaces() List[scapy.interfaces.NetworkInterface][source]

Return all interfaces that work

scapy.interfaces.network_name(dev: Union[scapy.interfaces.NetworkInterface, str]) str[source]

Resolves the device network name of a device or Scapy NetworkInterface

scapy.interfaces.resolve_iface(dev: Union[scapy.interfaces.NetworkInterface, str]) scapy.interfaces.NetworkInterface[source]

Resolve an interface name into the interface

scapy.interfaces.show_interfaces(resolve_mac: bool = True) None[source]

Print list of available network interfaces