How To Install python-scapy on Debian 9

In this tutorial we learn how to install python-scapy on Debian 9. python-scapy is Packet generator/sniffer and network scanner/discovery

Introduction

In this tutorial we learn how to install python-scapy on Debian 9.

What is python-scapy

python-scapy is:

Scapy is a powerful interactive packet manipulation tool, packet generator, network scanner, network discovery, packet sniffer, etc. It can for the moment replace hping, 85% of nmap, arpspoof, arp-sk, arping, tcpdump, tethereal, p0f, ….

In scapy you define a set of packets, then it sends them, receives answers, matches requests with answers and returns a list of packet couples (request, answer) and a list of unmatched packets. This has the big advantage over tools like nmap or hping that an answer is not reduced to (open/closed/filtered), but is the whole packet.

There are three methods to install python-scapy on Debian 9. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python-scapy Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python-scapy using apt-get by running the following command:

sudo apt-get -y install python-scapy

Install python-scapy Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python-scapy using apt by running the following command:

sudo apt -y install python-scapy

Install python-scapy Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python-scapy using aptitude by running the following command:

sudo aptitude -y install python-scapy

How To Uninstall python-scapy on Debian 9

To uninstall only the python-scapy package we can use the following command:

sudo apt-get remove python-scapy

Uninstall python-scapy And Its Dependencies

To uninstall python-scapy and its dependencies that are no longer needed by Debian 9, we can use the command below:

sudo apt-get -y autoremove python-scapy

Remove python-scapy Configurations and Data

To remove python-scapy configuration and data from Debian 9 we can use the following command:

sudo apt-get -y purge python-scapy

Remove python-scapy configuration, data, and all of its dependencies

We can use the following command to remove python-scapy configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-scapy

Dependencies

python-scapy have the following dependencies:

References

Summary

In this tutorial we learn how to install python-scapy package on Debian 9 using different package management tools: apt, apt-get and aptitude.