Last active
June 15, 2023 21:46
-
-
Save alexshpilkin/d814105b8a6e91e94841379be6dc7d11 to your computer and use it in GitHub Desktop.
Convert the RKN list to a Mikrotik firewall address list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Download the RKN list from https://github.com/zapret-info/z-i, massage it into | |
a Mikrotik script that manages a firewall address list, and put it up on a web | |
server. Note well that the list is gigantic---more than 80,000 entries as of | |
2018-04-28---so be sure to check if your router can handle it in advance (for | |
example, hAP Lite, with its measly 32M of memory, can’t). | |
On the router side, do something like | |
/tool fetch url="https://sheaf.site/rkn.rsc" dst-path=rkn.rsc | |
:import rkn.src | |
(although executing some guy’s scripts on your router is silly, you really | |
should host your own). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
set -o pipefail | |
curl -sS 'https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv' \ | |
| iconv -f cp1251 \ | |
| sed -re 's/^([^;]*);.*$/\1/' -e 's/ \| /\n/g' \ | |
| sort -u \ | |
| { echo '/ip firewall address-list'; | |
echo 'remove numbers=[find list=rkn]'; | |
sed -rne 's/^([0-9]+\.){3}[0-9]+(\/[0-9]+)?$/add list=rkn address=&/p'; } \ | |
>/tmp/rkn.rsc | |
mv /tmp/rkn.rsc rkn.rsc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Update RKN list | |
Wants=network-online.target | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/bin/update-rkn | |
User=root | |
WorkingDirectory=/srv/http/sheaf.site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Update RKN list daily | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
[Install] | |
WantedBy=timers.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment