Ik heb een Asus RT-AC66U router met een MerlinWRT firmware erop draaien.
Via deze site heb ik een script draaien dat landen zou moeten blocken gebasseerd op hun IP adres (land van herkomst dus): https://github.com/RMerl/asuswrt-merlin/wiki/Using-ipset
Als landen die ik wil blocken heb ik dit rijtje inmiddels in mijn script zitten:
in pk cn ph sa kr af ru ua ro th tr us br it hu mx co pl hk kp kz my ng sg vn ar fr
De router laadt het script netjes. De laatste entry die ik zie mbt dit is deze: _retry: net/ipv4/netfilter/ip_set_nethash.c: nethash_retry: rehashing of set BlockedCountries triggered: hashsize grows from 448398 to 6725977
Toch krijg ik van mijn achterliggende NAS soms meldingen dat er vanuit Rusland, Turkije of Thailand wordt geprobeerd in te loggen (meestal op poort 587 van mijn Mailserver). Die poort staat wel open, maar je zou toch denken dat het script (wat geladen is) dat alsnog zou moeten tegenhouden?
Als ik test of men vanuit bijv Amerika op mijn NAS kan (dus via HTTPS incl de poort die nodig is), dan zie ik in mijn Asus een ACCEPT tegenkomen.Mijn NAS houdt het uiteindelijk alsnog tegen, maar het is toch raar dat mijn router het niet stopt?
Via deze site heb ik een script draaien dat landen zou moeten blocken gebasseerd op hun IP adres (land van herkomst dus): https://github.com/RMerl/asuswrt-merlin/wiki/Using-ipset
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
| #!/bin/sh
# Loading ipset modules
lsmod | grep "ipt_set" > /dev/null 2>&1 || \
for module in ip_set ip_set_nethash ip_set_iphash ipt_set
do
insmod $module
done
# Preparing folder to cache downloaded files
IPSET_LISTS_DIR=/jffs/ipset_lists
[ -d "$IPSET_LISTS_DIR" ] || mkdir -p $IPSET_LISTS_DIR
# Different routers got different iptables syntax
case $(uname -m) in
armv7l)
MATCH_SET='--match-set'
;;
mips)
MATCH_SET='--set'
;;
esac
# Block traffic from Tor nodes
if [ "$(ipset --swap TorNodes TorNodes 2>&1 | grep 'Unknown set')" != "" ]
then
ipset -N TorNodes iphash
[ -e $IPSET_LISTS_DIR/tor.lst ] || wget -q -O $IPSET_LISTS_DIR/tor.lst http://torstatus.blutmagie.de/ip_list_all.php/Tor_ip_list_ALL.csv
for IP in $(cat $IPSET_LISTS_DIR/tor.lst)
do
ipset -A TorNodes $IP
done
fi
[ -z "$(iptables-save | grep TorNodes)" ] && iptables -I INPUT -m set $MATCH_SET TorNodes src -j DROP
# Block incoming traffic from some countries. cn and pk is for China and Pakistan. See other countries code at http://www.ipdeny.com/ipblocks/
if [ "$(ipset --swap BlockedCountries BlockedCountries 2>&1 | grep 'Unknown set')" != "" ]
then
ipset -N BlockedCountries nethash
for country in pk cn
do
[ -e $IPSET_LISTS_DIR/$country.lst ] || wget -q -O $IPSET_LISTS_DIR/$country.lst http://www.ipdeny.com/ipblocks/data/countries/$country.zone
for IP in $(cat $IPSET_LISTS_DIR/$country.lst)
do
ipset -A BlockedCountries $IP
done
done
fi
[ -z "$(iptables-save | grep BlockedCountries)" ] && iptables -I INPUT -m set $MATCH_SET BlockedCountries src -j DROP
# Block Microsoft telemetry spying servers
if [ "$(ipset --swap MicrosoftSpyServers MicrosoftSpyServers 2>&1 | grep 'Unknown set')" != "" ]
then
ipset -N MicrosoftSpyServers iphash
for IP in 23.99.10.11 63.85.36.35 63.85.36.50 64.4.6.100 64.4.54.22 64.4.54.32 64.4.54.254 \
65.52.100.7 65.52.100.9 65.52.100.11 65.52.100.91 65.52.100.92 65.52.100.93 65.52.100.94 \
65.55.29.238 65.55.39.10 65.55.44.108 65.55.163.222 65.55.252.43 65.55.252.63 65.55.252.71 \
65.55.252.92 65.55.252.93 66.119.144.157 93.184.215.200 104.76.146.123 111.221.29.177 \
131.107.113.238 131.253.40.37 134.170.52.151 134.170.58.190 134.170.115.60 134.170.115.62 \
134.170.188.248 157.55.129.21 157.55.133.204 157.56.91.77 168.62.187.13 191.234.72.183 \
191.234.72.186 191.234.72.188 191.234.72.190 204.79.197.200 207.46.223.94 207.68.166.254
do
ipset -A MicrosoftSpyServers $IP
done
fi
[ -z "$(iptables-save | grep MicrosoftSpyServers)" ] && iptables -I FORWARD -m set $MATCH_SET MicrosoftSpyServers dst -j DROP |
Als landen die ik wil blocken heb ik dit rijtje inmiddels in mijn script zitten:
in pk cn ph sa kr af ru ua ro th tr us br it hu mx co pl hk kp kz my ng sg vn ar fr
De router laadt het script netjes. De laatste entry die ik zie mbt dit is deze: _retry: net/ipv4/netfilter/ip_set_nethash.c: nethash_retry: rehashing of set BlockedCountries triggered: hashsize grows from 448398 to 6725977
Toch krijg ik van mijn achterliggende NAS soms meldingen dat er vanuit Rusland, Turkije of Thailand wordt geprobeerd in te loggen (meestal op poort 587 van mijn Mailserver). Die poort staat wel open, maar je zou toch denken dat het script (wat geladen is) dat alsnog zou moeten tegenhouden?
Als ik test of men vanuit bijv Amerika op mijn NAS kan (dus via HTTPS incl de poort die nodig is), dan zie ik in mijn Asus een ACCEPT tegenkomen.Mijn NAS houdt het uiteindelijk alsnog tegen, maar het is toch raar dat mijn router het niet stopt?
[ Voor 64% gewijzigd door Tallguy op 15-01-2017 17:37 ]
