Community discussions

MikroTik App
 
User avatar
MarHazK
newbie
Topic Author
Posts: 27
Joined: Wed Mar 29, 2017 8:31 pm

Fetch URL file then execute the file

Fri May 14, 2021 5:45 am

I have server (CentOS) that gather all the active blacklisted IPs (most of the time that attempt SSH logins/spamhaus/RBL listed/etc.) and I have the blacklist.php that will generate that blacklisted IPs the hosted under Apache+PHP.

What I am going to do is, that blacklist.php will generate all the Mikrotik command like the following:
/ip firewall address-list add list=blacklist address=<blacklisted IPs from DB>
Then, that IPs will be listed under my Mikrotik's address list named "blacklist", and my Rules already add DROP the incoming/outgoing traffic into that rules.

However, I am clueless how to run the generated file into Mikrotik. Anyone know how to do this into the script?
Lets say the script's scenario is like this:
1. Execute /tool fetch url="http://blablabla/servercmd.php" http-method=post http-data="op=mikrotik" output="runremotescript"
2. Execute all the generated Mikrotik's commands in runremotescript

the runremotescript will be like this:
1. /ip firewall address-list add list=blacklist address=<generated from http://blablabla/servercmd.php>
Example:
/ip firewall address-list add list=blacklist address=123.25.25.128
TQ
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 4694
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Fetch URL file then execute the file  [SOLVED]

Fri May 14, 2021 10:00 am

The forum is FULL of example, use SEARCH function first:

viewtopic.php?f=9&t=166293&p=855056&hilit=fetch#p855056
viewtopic.php?f=9&t=127039&p=854216&hilit=fetch#p854216

But I prefer mine because file size limit are little, and I prefer read IP than read replicated commands that use more space than single IP,
 
User avatar
MarHazK
newbie
Topic Author
Posts: 27
Joined: Wed Mar 29, 2017 8:31 pm

Re: Fetch URL file then execute the file

Fri May 14, 2021 5:10 pm

thanks.. solved

Who is online

Users browsing this forum: No registered users and 15 guests