Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Hello everyone
I was wondering if there is a script for resolving and adding all the IPs of the websites which are on a link (example: https://test.com/sitelist.txt) to a address-list and add the host name as comment to the first IP of each website.
Example: Link/txt file is containing the following:

google.com
yahoo.com
android.com
apple.com

then the script resolve those addresses to find their IPs, then it will add them as following to the address-list:


add address=123.123.123.123 comment=google.com list=scan
add address=123.123.123.124 list=scan
add address=123.123.123.125 list=scan
add address=78.16.85.1 comment=yahoo.com list=scan
add address=124.15.21.110 comment=android.com list=scan
add address=124.15.21.120 list=scan
add address=141.165.84.125 comment=apple.com list=scan

Why do you like to do that. To try to block some?
Google etc changes IP all time and gives different IP depending location etc.

Not blocking them but to bypass the traffic from VPN tunnel.
google was only an example, the list is full of websites that mostly have only 1 IP.

Any idea/solution?

You should read this topic:

http://forum.mikrotik.com/t/blacklist-filter-update-script/89817/385

You can literally add hostnames to address-list and they are will be resolved automatically.

Yeah that’s totally right but in that case router is gonna query them every few minutes and spam up all my pi-hole query list.

Thanks man but I didn’t get how to use it, would you be so kind and elaborate it?

Up!

Open the file in an advanced text editor which allows advanced search and replace of one text block.
google.com
yahoo.com
android.com
apple.com
search only “¶” / “return” / “new line” / “enter” / \n / \r\n, or what is that “button” called in your country,
and replace with
"; :execute “/ip firewall address-list add address=[:resolve $site] comment=$site list=scan”
:local site "
Fix first and last line.

You obtain the script:
:local site “google.com”; :execute “/ip firewall address-list add address=[:resolve $site] comment=$site list=scan”
:local site “yahoo.com”; :execute “/ip firewall address-list add address=[:resolve $site] comment=$site list=scan”
:local site “android.com”; :execute “/ip firewall address-list add address=[:resolve $site] comment=$site list=scan”
:local site “apple.com”; :execute “/ip firewall address-list add address=[:resolve $site] comment=$site list=scan”
Speaking of doing it with scripts in RouterOS, it’s just not worth it to me.