scapy.route
Routing and handling of network interfaces.
- class scapy.route.Route[source]
Bases:
object
- add(*args: Any, **kargs: Any) None [source]
Add a route to Scapy’s IPv4 routing table. add(host|net, gw|dev)
- Parameters:
host – single IP to consider (/32)
net – range to consider
gw – gateway
dev – force the interface to use
metric – route metric
Examples:
- ip route add 192.168.1.0/24 via 192.168.0.254::
>>> conf.route.add(net="192.168.1.0/24", gw="192.168.0.254")
- ip route add 192.168.1.0/24 dev eth0::
>>> conf.route.add(net="192.168.1.0/24", dev="eth0")
- ip route add 192.168.1.0/24 via 192.168.0.254 metric 1::
>>> conf.route.add(net="192.168.1.0/24", gw="192.168.0.254", metric=1)
- delt(*args: Any, **kargs: Any) None [source]
Remove a route from Scapy’s IPv4 routing table. delt(host|net, gw|dev)
Same syntax as add()
- make_route(host: str | None = None, net: str | None = None, gw: str | None = None, dev: str | None = None, metric: int = 1) Tuple[int, int, str, str, str, int] [source]
- route(dst: str | None = None, dev: str | None = None, verbose: int = 2, _internal: bool = False) Tuple[str, str, str] [source]
Returns the IPv4 routes to a host.
- Parameters:
dst – the IPv4 of the destination host
dev – (optional) filtering is performed to limit search to route associated to that interface.
- Returns:
tuple (iface, output_ip, gateway_ip) where -
iface
: the interface used to connect to the host -output_ip
: the outgoing IP that will be used -gateway_ip
: the gateway IP that will be used