script for find similar domains in dns cache
Posted: Sun Sep 02, 2018 2:40 am
hi all
i am using this script to collect instagram.com ip addresses in dns cache ( for block or separate route )
but it is working only for instagram.com , now i want to work for any domains that contain cdninstagram.com ( scontent-ams3-1.cdninstagram.com)
please help me
:local hosts {"instagram.com"}
:foreach k,v in=$hosts do={
:log info "Doing $v"
:local listname $v
:resolve $v
:local iscname [/ip dns cache all find where name=$v and type="CNAME"]
:if ($iscname != "") do={
:local newname [/ip dns cache all get $iscname data]
:log info "$v is CNAME to $newname"
:set v $newname
}
:resolve $v
:foreach i in=[/ip dns cache all find where name=$v and type="A"] do={
:local ipaddr [/ip dns cache all get $i data]
/ip firewall address-list add list=$listname address=$ipaddr comment=$v
:log info "IP address: $ipaddr"
}
/ipv6 firewall address-list remove [/ipv6 firewall address-list find where list=$listname]
:foreach i in=[/ip dns cache all find where name=$v and type="AAAA"] do={
:local ipaddr [/ip dns cache all get $i data]
/ipv6 firewall address-list add list=$listname address=$ipaddr comment=$v
:log info "IPv6 address: $ipaddr"
}
}
:log info "end"
i am using this script to collect instagram.com ip addresses in dns cache ( for block or separate route )
but it is working only for instagram.com , now i want to work for any domains that contain cdninstagram.com ( scontent-ams3-1.cdninstagram.com)
please help me
:local hosts {"instagram.com"}
:foreach k,v in=$hosts do={
:log info "Doing $v"
:local listname $v
:resolve $v
:local iscname [/ip dns cache all find where name=$v and type="CNAME"]
:if ($iscname != "") do={
:local newname [/ip dns cache all get $iscname data]
:log info "$v is CNAME to $newname"
:set v $newname
}
:resolve $v
:foreach i in=[/ip dns cache all find where name=$v and type="A"] do={
:local ipaddr [/ip dns cache all get $i data]
/ip firewall address-list add list=$listname address=$ipaddr comment=$v
:log info "IP address: $ipaddr"
}
/ipv6 firewall address-list remove [/ipv6 firewall address-list find where list=$listname]
:foreach i in=[/ip dns cache all find where name=$v and type="AAAA"] do={
:local ipaddr [/ip dns cache all get $i data]
/ipv6 firewall address-list add list=$listname address=$ipaddr comment=$v
:log info "IPv6 address: $ipaddr"
}
}
:log info "end"