Page 1 of 1

REST API Creating and updating an ip firewall address list with domains

Posted: Sun Dec 04, 2022 11:28 pm
by elico
Hey,

I am using an external script to dump the DNS cache from the device and then populate an address list with specific domains.
I am able to dump and find the addresses but not sure how to add a batch of domains and/or addresses to the RouterOS device via REST API.
What:
should I use and also, what is the json content that should look like?
For example for "googlevideo" list the next domains:
rr3---sn-jjjpa-ua8e.googlevideo.com
rr3.sn-jjjpa-ua8e.googlevideo.com
rr3.sn-jjjpa-ua8e.googlevideo.com
rr1---sn-aigl6nzs.googlevideo.com
rr1.sn-aigl6nzs.googlevideo.com
rr1.sn-aigl6nzs.googlevideo.com

Re: REST API Creating and updating an ip firewall address list with domains

Posted: Mon Dec 05, 2022 12:09 am
by elico
OK so I took the time to write some code and give a programmatically example of an address-list update at:
https://github.com/elico/mikrotik-web-f ... ss-domains

It requires some environment variables like MT_HOST and MT_USER and MT_PASSWORD
I hope it helps someone.

Re: REST API Creating and updating an ip firewall address list with domains

Posted: Sat Dec 17, 2022 11:51 am
by elbob2002
Thanks! I was just looking to do something similar this morning and came across this.

Re: REST API Creating and updating an ip firewall address list with domains

Posted: Sat Nov 30, 2024 8:56 pm
by bocaditos
Hello. I am looking for a web application for my MikroTik that can write and delete IP addresses that I previously have on a list. I don't know if this is for this or if you know where I can find it.

Re: REST API Creating and updating an ip firewall address list with domains

Posted: Fri Dec 27, 2024 8:35 am
by DenSyo77
Create
POST http://router/rest/ip/firewall/address-list/add
{"address":"8.8.8.8","list":"Google","disabled":"false","comment":"No comment","dynamic":"false"}
*return .id value of new record

Read
POST http://router/rest/ip/firewall/address-list/print
{".query":["address=8.8.8.8","list=Google","#|"]}
*See this topic viewtopic.php?p=1053628&hilit=rest+api#p1053628

Update ([.id] - .id value of record with *)
PATCH http://router/rest/ip/firewall/address-list/[.id]
{"address":"8.8.8.8","list":"Google","disabled":"false","comment":"","dynamic":"true","timeout":"02:00:00"}

Delete ([.id] - .id value of record with *)
DELETE http://router/rest/ip/firewall/address-list/[.id]

Re: REST API Creating and updating an ip firewall address list with domains

Posted: Fri Dec 27, 2024 9:34 am
by bocaditos
Thanks. I'll see if it helps. Regards.