I want to Create a script which resolves Web page to an IP, and put this IP into an address list.
After that i want to Schedule this script every minute or so.
Then i will Add a firewall rule to drop forwarded traffic to this address list.
Do you even need a script? /ip firewall address-list has the nice property of doing the resolve for you. Unlike most of RouterOS, address= can be a DNS name in the firewall address-lists. AFAIK, it follows the DNS TTL for refresh and will resolve CNAME or A to multiple records if needed. You can even add multiple DNS names to the same list to refer to the “collection of DNS names” in the firewall rules.
Now if you didn’t trust the TTL/update interval of these, then you’d need a scheduler. But the [:resolve] part may not be needed.
Totally, sorry I did miss he want to add to the list dynamically.
I think my missing point was more that [:resolve] gets one IP, but a site may have a few:
:put [:resolve www.youtube.com]
142.251.46.238
On Linux, dig [www.youtube.com](http://www.youtube.com) get the same list as /ip/firewall/address-list with a DNS does:
dig www.youtube.com
; <<>> DiG 9.10.6 <<>> www.youtube.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 9769
;; flags: qr rd ra; QUERY: 1, ANSWER: 17, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.youtube.com. IN A
;; ANSWER SECTION:
www.youtube.com. 49551 IN CNAME youtube-ui.l.google.com.
youtube-ui.l.google.com. 105 IN A 64.233.177.190
youtube-ui.l.google.com. 105 IN A 172.253.124.136
youtube-ui.l.google.com. 105 IN A 64.233.177.93
youtube-ui.l.google.com. 105 IN A 216.58.195.142
youtube-ui.l.google.com. 105 IN A 172.253.124.91
youtube-ui.l.google.com. 105 IN A 64.233.177.136
youtube-ui.l.google.com. 105 IN A 172.217.164.78
youtube-ui.l.google.com. 105 IN A 74.125.21.91
youtube-ui.l.google.com. 105 IN A 173.194.219.93
youtube-ui.l.google.com. 105 IN A 142.250.177.46
youtube-ui.l.google.com. 105 IN A 64.233.177.91
youtube-ui.l.google.com. 105 IN A 142.250.176.78
youtube-ui.l.google.com. 105 IN A 74.125.21.190
youtube-ui.l.google.com. 105 IN A 172.253.124.93
youtube-ui.l.google.com. 105 IN A 172.253.124.190
youtube-ui.l.google.com. 105 IN A 74.125.136.91
;; Query time: 10 msec
;; SERVER: 2600:1700:87f0:2f20::1#53(2600:1700:87f0:2f20::1)
;; WHEN: Wed Mar 09 10:41:18 PST 2022
;; MSG SIZE rcvd: 334
You both are missing the point, cant see the forest for the trees, lost in the minutia
The script request DOES NOT= REQUIREMENT.
Why? Simply a configuration has a task to perform to meet requirements. You are discussing tasks because the OP framed the request in such a way that fooled you.
Analogy. Op asks on forum, how do I design the internal mechanism on a plastic pistol. The requirement is to be able to kill someone, now do you really want to help a person do that
So it was a poor analogy LOL.
In other words, the OP has to confess THE WHY he wants such a script.
Since the OP is afraid of the truth we can only surmize that they are attempting to block websites from users on his LAN.
We know that to be a fools game with MT equipment, especially if the URLS are HTTPS.
So get your heads out of the sand and inform this poor chap that no matter how gucci, suave, sophisticated the scripts you foam at the mouth with like excited puppies, it AINT gonna resolve the requirement.