Как стать автором
Обновить
1
0

Пользователь

Отправить сообщение

У меня на DD-WRT заработало. Сделал так.

1) Включил SSH. webUI Services ->Services Secure Shell (SSH) галка Enable Daemon.

2) Подключил к роутеру флешку включил поддержку usb. Для этого сначала отформатировал флешку в ext3 воткнул в роутер. В webUI на закладке Services -> USB ставим галки:

Core USB Support

USB Storage Support

Automatic Drive Mount

флешка подмонтировалась в каталог /tmp/mnt/sda1. Возможно потребуется перезагрузка.

3)ssh

cd /tmp/mnt/sda1

mkdir zapret

4) На компе скачал с гита проект. Через winscp закинул файлы из binaries/mips32r1-lsb. В /tmp/mnt/sda1/zapret

ssh

cd /tmp/mnt/sda1/zapret

chmod +x ./*

5) На компе создал файлы S51tpws и hostlist.txt. Через winscp закинул в ту же папку.

hostlist.txt.

googlevideo.com
googleapis.com
yt3.ggpht.com
youtube.com
youtu.be
nhacmp3youtube.com
youtubei.googleapis.com
ggpht.com
ytimg.com
l.google.com
play.google.com
googleusercontent.com
gstatic.com
yt4.ggpht.com
ytimg.l.google.com
gstatic.com
android.googleapis.com
youtube-ui.l.google.com
ytstatic.l.google.com

S51tpws

#!/bin/sh

SCRIPT=/mnt/sda1/zapret/tpws
PIDFILE=/var/run/tpws.pid
HOSTLISTFILE=/mnt/sda1/zapret/hostlist.txt
ARGS="--daemon --bind-addr 192.168.15.1 --port 999 --disorder --tlsrec=sni --split-pos=2 --pidfile $PIDFILE --hostlist $HOSTLISTFILE"


start() {
  if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
    echo 'Service TPWS is already running' >&2
    return 1
  fi
  $SCRIPT $ARGS
  iptables -t nat -A PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 999
  iptables -t nat -A PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 999
  echo 'Started TPWS service'
}

stop() {
  if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
    echo 'Service TPWS is not running' >&2
    return 1
  fi
  echo 'Stopping TPWS service...'
  kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  iptables -t nat -D PREROUTING -i br0 -p tcp --dport 80 -j REDIRECT --to-port 999
  iptables -t nat -D PREROUTING -i br0 -p tcp --dport 443 -j REDIRECT --to-port 999

}

status() {
  if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
    echo 'Service TPWS is running'
  else
    echo 'Service TPWS is stopped'
  fi
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
    status
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
esac

chmod +x /mnt/sda1/zapret/S51tpws

6) Добавил скрипт в автозапуск. webUI Administration-> Commands в текстовое поле Commands вставляем команды.

sleep 30
/tmp/mnt/sda1/zapret/S51tpws start

жмем Save Startup.

sleep 30 - нужен чтоб точно до запуска скрипта подмонтировалась флешка.

7) Ребут роутера.

https://habr.com/ru/articles/833564/comments/#comment_27154876

мой вариант решения

start() {
  if [ -f $PIDFILE ] && kill -0 $(cat $PIDFILE); then
    echo 'Service TPWS is already running' >&2
    return 1
  fi
  $SCRIPT $ARGS
  nft add table ip tpws
  nft add chain ip tpws prerouting { type nat hook prerouting priority 0 \; }
  nft add rule ip tpws prerouting iifname "br-lan" tcp dport 80 redirect to :999
  nft add rule ip tpws prerouting iifname "br-lan" tcp dport 443 redirect to :999
  nft add rule ip tpws prerouting iifname "br-lan" udp dport 443 redirect to :999
  echo 'Started TPWS service'
}

stop() {
  if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
    echo 'Service TPWS is not running' >&2
    return 1
  fi
  echo 'Stopping TPWS service...'
  kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  nft delete table ip tpws
  
}

Информация

В рейтинге
Не участвует
Зарегистрирован
Активность

Специализация

System Administration, Network Engineer