Created
May 5, 2018 20:04
-
-
Save hazarkarabay/7c398578905fc7d0967c5fa98bf0fd3e to your computer and use it in GitHub Desktop.
Mikrotik'te ASN bilgisinden IP range bulan ve address list'e ekleyen script.
This file contains hidden or 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
# ASN bazinda VPN scripti | |
# 2018 Hazar | |
:local VPNAddrList "vpnize-auto"; | |
:local ASNlist { | |
202196="booking"; | |
43996="booking"; | |
14907="wiki"; | |
11820="wiki"; | |
43821="wiki"; | |
13414="twitter"; | |
35995="twitter"; | |
63179="twitter"; | |
54888="twitter"; | |
} | |
:log info "VPN icin ASN update basliyor."; | |
/system logging disable 0; | |
# Temizlik. | |
/ip firewall address-list remove [find list=$VPNAddrList]; | |
:foreach asn,com in=$ASNlist do={ | |
/tool fetch url=("https://www.enjen.net/asn-blocklist/index.php?asn=AS" . $asn . "&type=iplist&api=1") dst-path=("AS" . $asn . ".txt"); | |
:put ("AS" . $asn . ".txt"); | |
if ([:len [/file find name=("AS" . $asn . ".txt")]] > 0) do={ | |
:local content [/file get [/file find name=("AS" . $asn . ".txt")] contents] ; | |
:local contentLen [ :len $content ] ; | |
:local lineEnd 0; | |
:local line ""; | |
:local lastEnd 0; | |
:do { | |
:set lineEnd [:find $content "\n" $lastEnd ]; | |
:set line [:pick $content $lastEnd $lineEnd]; | |
:set lastEnd ( $lineEnd + 1 ); | |
:if ($line != "") do={ | |
/do {ip firewall address-list add list=$VPNAddrList address=$line comment=("ASNVPN Script: " . $com);} on-error={} | |
} | |
:put ($com . ": " . $line); | |
} while ($lastEnd < $contentLen); | |
# Temizlik | |
#/file remove ("AS" . $asn . ".txt"); | |
} else={ | |
:put ("AS" . $asn . " route detayi alinamadi."); | |
} | |
} | |
/system logging enable 0; | |
:log info "VPN icin ASN update tamamlandi."; |
Does not works with "AS16625"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does only add IP address to files but doesn't add anything to firewall>address-list