Iptables - как заблокировать torrrent трафик

Материал из Wiki - Iphoster - the best ever hosting and support. 2005 - 2023
Перейти к:навигация, поиск

Доступная цена

Iptables - как заблокировать torrent трафик

Видео инструкция:


Правила iptables для блокировки torrent трафика:

# iptables -I FORWARD -m string --algo bm --string "BitTorrent" -j DROP
# iptables -I FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP
# iptables -I FORWARD -m string --algo bm --string "peer_id=" -j DROP
# iptables -I FORWARD -m string --algo bm --string ".torrent" -j DROP
# iptables -I FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP
# iptables -I FORWARD -m string --algo bm --string "torrent" -j DROP
# iptables -I FORWARD -m string --algo bm --string "announce" -j DROP
# iptables -I FORWARD -m string --algo bm --string "info_hash" -j DROP

Через скрипт:

# vi block_torrent.sh
#!/bin/sh
iptables -I FORWARD -m string --algo bm --string "BitTorrent" -j DROP
iptables -I FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP
iptables -I FORWARD -m string --algo bm --string "peer_id=" -j DROP
iptables -I FORWARD -m string --algo bm --string ".torrent" -j DROP
iptables -I FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP
iptables -I FORWARD -m string --algo bm --string "torrent" -j DROP
iptables -I FORWARD -m string --algo bm --string "announce" -j DROP
iptables -I FORWARD -m string --algo bm --string "info_hash" -j DROP
# chmod a+x block_torrent.sh
# sh block_torrent.sh

Проверяем через

# iptables -L

Сохраняем правила iptables для блокировки torrrent трафика на постоянной основе после перезагрузки сервера:

# apt install iptables-persistent -y
# /sbin/iptables-save > /etc/iptables/rules.v4