Community discussions

MikroTik App
 
elico
Member Candidate
Member Candidate
Topic Author
Posts: 158
Joined: Mon Nov 07, 2016 3:23 am

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

Sun Dec 04, 2022 11:28 pm

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
 
elico
Member Candidate
Member Candidate
Topic Author
Posts: 158
Joined: Mon Nov 07, 2016 3:23 am

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

Mon Dec 05, 2022 12:09 am

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.
 
elbob2002
Member Candidate
Member Candidate
Posts: 285
Joined: Tue May 15, 2018 8:15 pm
Location: Ireland

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

Sat Dec 17, 2022 11:51 am

Thanks! I was just looking to do something similar this morning and came across this.
 
bocaditos
just joined
Posts: 4
Joined: Tue Nov 14, 2023 6:54 pm

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

Sat Nov 30, 2024 8:56 pm

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.
 
User avatar
DenSyo77
newbie
Posts: 27
Joined: Tue Jan 09, 2024 10:38 am
Contact:

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

Fri Dec 27, 2024 8:35 am

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]
 
bocaditos
just joined
Posts: 4
Joined: Tue Nov 14, 2023 6:54 pm

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

Fri Dec 27, 2024 9:34 am

Thanks. I'll see if it helps. Regards.