1. Home
  2. Linux
  3. Block bittorrent traffic on network linux bithammer

How To Block Bittorrent Traffic On A Network On Linux With BitHammer

The torrent protocol is a legal grey area, and though it has some legitimate uses, the technology has a bad reputation. If you’re sick of people downloading torrents on your network at home, there may be a Linux-powered solution that lets you block Bittorrent traffic on your home network.

The solution is BitHammer, a simple Linux tool that, when run, will scan traffic on the network it’s running on, add downloading devices to a list and prevent the download (as long as the program is running).

Note: BitHammer is experimental software and may not work in every use case. Use this software at your own risk!

Install BitHammer

The BitHammer application runs in the terminal and is up on Github. It’ll work on pretty much every Linux system, as it’s a generic binary package. To install it, you’ll first need to install the Git package, as well as the Python dependencies that the program needs.

Ubuntu

sudo apt install git python python-scapy

Debian

sudo apt-get install git python python-scapy

Arch Linux

sudo pacman -S git python python-scapy

Fedora

sudo dnf install git python python-scapy

OpenSUSE

sudo zypper install git python python-scapy

Generic Linux

Using BitHammer on Linux requires very little dependencies, as it’s a terminal application. Specifically, you must install Git to grab the sources, as well as Python and Python-scapy. Open up a terminal and search your package manager for these packages and install them.

With the dependencies on your Linux PC, it’s time to install the BitHammer application. In a terminal, grab the latest code from Github.

git clone https://github.com/nazrhyn/bithammer.git

Move the terminal into the BitHammer sources folder with CD.

cd bithammer

In the terminal, use the mkdir command and make a new folder in /opt/.

sudo mkdir -p /opt/bithammer

Move the BitHammer files into the new folder, with the mv command.

sudo mv * /opt/bithammer

The core files for BitHammer are in the right place. However, the app won’t launch with the “bithammer” command until it’s in the /usr/bin folder. To fix this, create a symlink from /opt/bithammer to /usr/bin.

sudo ln -s /opt/bithammer/bithammer /usr/bin/bithammer

Now that the symlink is ready to go, the BitHammer Torrent blocking tool runs with the following command:

sudo bithammer

Set Up BitHammer

The BitHammer tool is automatic and needs no configuration. At any time, you’ll be able to run the command, and for as long as the tool is running, it should shut torrent traffic off. However, keep in mind that running the tool isn’t workable, as terminals sometimes shut off, etc.

Instead of relying on remembering to run the bithammer command every time your Linux PC turns on, it’s much smarter to set up a script that starts it up automatically.

Setting up an automatic BitHammer script is the first step to automating BitHammer. In a terminal, enter the following commands.

touch ~/Desktop/bithammer-start.sh
echo '#!/bin/bash' >> ~/Desktop/bithammer-start.sh

echo ' ' >> ~/Desktop/bithammer-start.sh
echo 'bithammer &>/dev/null &' >> ~/Desktop/bithammer-start.sh

With the script’s commands laid out, it’s time to update the permissions to the script. In a terminal, run the chmod command and update bithammer-start.

sudo chmod +x ~/Desktop/bithammer-start.sh

sudo mv ~/Desktop/bithammer-start.sh /usr/local/bin/

Next, create a new systemd file. This file will allow bithammer-start to automatically start when your Linux machine turns on.

sudo touch /etc/systemd/system/bithammer.service

Open the new BitHammer systemd file in the Nano text editor.

sudo nano /etc/systemd/system/bithammer.service

Paste the code below into Nano:

[Unit]
Description=Starts BitHammer.

[Service]
ExecStart=bash /usr/local/bin/bithammer-start.sh

[Install]
WantedBy=multi-user.target

Save the edit with Nano by pressing the Ctrl + O keyboard combination. Close the editor by pressing Ctrl + X on the keyboard.

Finally, finish up the process by starting up the new service.

sudo systemctl start bithammer.service

sudo systemctl enable bithammer.service

Not a fan of always having the BitHammer tool running? Thankfully, since the systemd init system handles everything, disabling the service is easier than ever.

To disable automatic startup for BitHammer, disable the service with systemctl.

sudo systemctl stop bithammer.service

Alternatives To BitHammer

BitHammer is an interesting tool, but some may find it to be a bit extreme. If you’re not a fan of torrent traffic, but don’t feel as though you need a special Linux app, you may want to go another way. The leading way to block BitTorrent traffic on a home network is to deny the special ports that the protocol uses.

Note: banning the default torrent ports is a good step, and will deter many beginner users from being able to use torrents on your network. Keep in mind that this won’t always work if users are able to change ports in their client.

Open your router’s interface and ban user access to ports 6881 through 6999. Again, this isn’t a perfect solution but it will help immensely.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.