Jump to content

Recommended Posts

Posted

В связи с включением Wireguard в прошивку попробовал поднять выборочную маршрутизацию через ipset, список адресов с antifilter_download и iptables по комбинации различных гайдов (типа https://keenetic-gi.ga/2018/01/16/selective-routing.html и https://habr.com/ru/post/440030/). В итоге кое-как это поднялось, но есть одна огромная проблема - очень нестабильная связь. Через определенный промежуток времени, равный вызову keepalive интерфейса wg, просто пропадала связь с сайтом, который ранее был недоступен и заново не восстанавливалась. Обновляешь, он опять открывается и бац, пропадает загрузка и сайт загружен на процентов 50 оказывается. Скрипты под спойлером.

Содержимое скрипта по пути /opt/etc/ndm/netfilter.d/100-fwmarks.sh

Spoiler

#!/bin/sh

[ "$type" == "ip6tables" ] && exit 0
[ "$table" != "mangle" ] && exit 0

[ -z "$(iptables-save | grep vpn_subnets)" ] && \
    iptables -w -A PREROUTING -t mangle -m set --match-set vpn_subnets dst,src -j MARK --set-mark 100
[ -z "$(iptables-save | grep vpn_ipsum)" ] && \
    iptables -w -A PREROUTING -t mangle -m set --match-set vpn_ipsum dst,src -j MARK --set-mark 100
exit 0

Содержимое скрипта /opt/etc/ndm/fs.d/100-create_ipsets_and_routing_tables.sh

Spoiler

#!/bin/sh

[ "$1" != "start" ] && exit 0

dir=/opt/root

echo "Run download lists"
curl -z $dir/subnet.lst https://antifilter.download/list/subnet.lst --output $dir/subnet.lst

curl -z $dir/ipsum.lst https://antifilter.download/list/ipsum.lst --output $dir/ipsum.lst

ipset create vpn_subnets hash:net
ipset create vpn_ipsum hash:net hashsize 100000 maxelem 100000
### Create set
cat $dir/subnet.lst | xargs -n1 ipset add vpn_subnets_tmp
cat $dir/ipsum.lst | xargs -n1 ipset add vpn_ipsum_tmp

### Create routing tables for marked packets
if [ -z "$(ip route list table 100)" ]; then
    ip rule add fwmark 100 table 100
    ip route add default dev nwg0 table 100
fi

exit0

 

 

  • 3 months later...
Posted (edited)

Возникла точно такая же проблема, удалось ли найти какое-нибудь решение?

Заметил возможную проблему, правила, которые добавляются в 100-fwmarks.sh практически мгновенно удаляются (раньше висели и их можно было отгрепать в iptables-save). Возможно, это и приводит к обрывам.

 

Edited by Nikolay Borisov

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

This site uses cookies. By clicking "I accept" or continuing to browse the site, you authorize their use in accordance with the Privacy Policy.