Kali ini saya akan bagi script untuk dumping ip-ip dalam suatu ASNUMBER tertentu. Buatlah script dengan ekstensi dot sh pada console linux anda. Jangan lupa di chmod 777 file.sh tadi kemudian jalaankan script.
rm -rf ASN rm -rf IP touch ASN touch IP clear echo "=========================================" echo -n "asnumber / ipnya berapa ? = " read asnum if [[ $asnum =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then whois -h whois.radb.net -i origin $asnum | grep '^notify:' | awk '{print "ini kak deskripsinya: = "$2}' fi echo -n "address-list-nya ? contoh: cidr_akamai = " read addrlist echo -n "comment-nya apa ? contoh: akamai = " read comment rm -rf "$asnum"-"$comment".rsc echo "========#[tunggu sebentar ya kak]#=======" echo "" if [[ $asnum =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then whois -h whois.radb.net -i origin $asnum | grep '^origin:' | awk '{print $2}' >> ASN sort -u -o ASN ASN tail -f IP & for ASN in $(cat ASN | awk '{print $1}'); do { whois -h whois.radb.net -- "-i origin $ASN" | grep '^route:' | perl -MNet::Netmask -ne'm!(\d+\.\d+\.\d+\.\d+/?\d*)! or next; $h = $1; $h =~ s/(\.0)+$//; $b=Net::Netmask->new($h); $b->storeNetblock(); END {print map {$_->base()."/".$_->bits()."\n"} cidrs2cidrs(dumpNetworkTable)}'; } >> IP sleep 3 done echo ""; sort -V IP | uniq | awk '{print "/ip firewall address-list add list='$addrlist' comment='$comment' address=" $1}' >> /var/www/html/dump/"$asnum"-"$comment".rsc #sed -i '4d' "$addrlist".rsc cat /var/www/html/dump/"$asnum"-"$comment".rsc else whois -h whois.radb.net -i origin $asnum | grep '^route:' | perl -MNet::Netmask -ne'm!(\d+\.\d+\.\d+\.\d+/?\d*)! or next; $h = $1; $h =~ s/(\.0)+$//; $b=Net::Netmask->new($h); $b->storeNetblock(); END {print map {$_->base()."/".$_->bits()."\n"} cidrs2cidrs(dumpNetworkTable)}' >> temp.txt sort -V temp.txt | uniq | awk '{print "/ip firewall address-list add list='$addrlist' comment='$comment' address=" $1}' >> /var/www/html/dump/"$asnum"-"$comment".rsc cat /var/www/html/dump/"$asnum"-"$comment".rsc rm temp.txt fi
Hasilnya sepeti berikut ini :
Jangan khawatir jika ada double ip yang tertera dalam file tersebut karena sudah difilter dan dipastikan UNIQ, alias tidak mungkin sama!
Tidak sampai di situ saja, hasil generate anda berwujud file rsc yang siap di import di mikrotik anda setiap anda men-generate as number baru, berikut penampakannya :
Semoga bermanfaat. Terima kasih.