-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathget.sh
More file actions
executable file
·67 lines (59 loc) · 1.39 KB
/
get.sh
File metadata and controls
executable file
·67 lines (59 loc) · 1.39 KB
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
67
#!/bin/sh
last=$(date);
url="https://stat.ripe.net/data/country-resource-list/data.json?resource=IR&v4_format=prefix"
filterv4='.data.resources.ipv4[]'
filterv6='.data.resources.ipv6[]'
output=$( curl --http2-prior-knowledge -s -X POST -H 'Connection: close' $url )
rsc_fwv4()
{
echo "#Last update: $last";
echo "/ip firewall address-list remove [/ip firewall address-list find list=NoNAT]";
echo "/ip firewall address-list";
}
rsc_fwv6()
{
echo "#Last update: $last";
echo "/ipv6 firewall address-list remove [/ipv6 firewall address-list find list=IRv6]";
echo "/ipv6 firewall address-list";
}
rsc_respinav4()
{
echo ":do { add address=5.160.0.0/16 list=NoNAT} on-error={}";
echo ":do { add address=46.209.0.0/16 list=NoNAT} on-error={}";
echo ":do { add address=77.104.64.0/18 list=NoNAT} on-error={}";
}
rsc_intranetv4()
{
echo ":do { add address=10.0.0.0/8 list=NoNAT} on-error={}";
}
# $1: ip list
# $2: address list name
# $3:
# v4: IPv4 only
# v6: IPv6 only
# default: without section
rsc_address_add()
{
if [ $3 = "v4" ]
then
rsc_fwv4
rsc_respinav4
rsc_intranetv4
elif [ $3 = "v6" ]
then
rsc_fwv6
fi
for prefix in $1
do
echo ":do { add address=$prefix list=$2} on-error={}";
done;
}
# main
if [ "$1" != "v4" ]
then
rsc_address_add "$( echo $output | jq -r $filterv6 )" IRv6 v6
fi
if [ "$1" != "v6" ]
then
rsc_address_add "$( echo $output | jq -r $filterv4 )" NoNAT v4
fi