Community discussions

MikroTik App
Topic Author
Posts: 403
Joined: Thu May 07, 2015 11:46 am

/tool fetch via specific interface?

Tue Apr 10, 2018 11:17 am

On my router I have two WANs (first is the default one, and the second will take over when first one is dead), and I need to do fetch of a given URL from the IP of second WAN port. The problem is, the IP of server I will fetch url from can change (CDN, actually) so I can't just route/mangle traffic to it from second WAN statically.

At the same time I found no way to specify outgoing interface for
/tool fetch
so the scheme fails.

How can I do that trick?
just joined
Posts: 4
Joined: Tue Feb 05, 2013 8:07 am
Location: Indonesia

Re: /tool fetch via specific interface?

Mon Dec 16, 2019 10:12 pm

on script, you can disable interface WAN default, before run fetch and enable it after that. Better with delay.
just joined
Posts: 1
Joined: Sun Apr 19, 2020 9:31 pm

Re: /tool fetch via specific interface?

Sun Apr 19, 2020 9:33 pm

I faced same problem, searching for solution.
User avatar
Forum Guru
Forum Guru
Posts: 1910
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at

Re: /tool fetch via specific interface?

Wed Apr 22, 2020 9:25 am

I think this can be done by adding a static route to site you like to fetch to the second wan interface.
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

Posts: 46
Joined: Sat Sep 22, 2018 6:13 pm

Re: /tool fetch via specific interface?

Tue Feb 02, 2021 11:50 am

sorry for write an old post, but i have a similar problem...

i have a mikrotik 4011 with 2 isp
ether1 to ISP1
ether2 to ISP2

ether2 have a dynamic ip and i want configure with ovh dynhost.
on old pfsense i set simple cronjob
curl --interface igb0 --user "<user>:<mypassword>" " ... myhostname>"
and worked perfectly

now i change old pfsense with GREAT Mikrotik :)
but how can i replicate that?

in fetch i can't use --interface or similar
so i think to create an address list with domain
and create a specific route to that address list (my opinion is not clear force a route with actual ip of because ovh can change your ip)

how can i solve problem?

thank you
just joined
Posts: 21
Joined: Sat May 26, 2018 10:05 pm

Re: /tool fetch via specific interface?

Tue Feb 09, 2021 7:04 pm

An easy approach is to resolve the address each time it tries to update, add the address to an address list with a timeout and use a prefixed mangle and routing mark to route traffic via the proper interface.

For example :
local currentIp [:resolve]
/ip firewall address-list add list=dyndns address=$currentIp timeout=20s
/tool fetch url=XXX
You can then keep a static set of rules to mangle and route the traffic
/ip firewall mangle add chain=prerouting protocol=tcp dst-port=80,443 dst-address-list=dyndns action=mark-routing new-routing-mark=via_wan2
/ip route add dst-address= gateway=x.x.x.x routing-mark=via_wan2
If your eth2 gateway changes you need to put an on-lease script in the dhcp-client for eth2 to fix the gateway. Somthing like
script="/ip route set gateway=$gateway [find routing-mark=\"via_wan2\""
You better check if the default variable for the gateway is actually $gateway in the documentation.


BTW, ping, ssh, telnet (although its broken post 6.45.6 or so) support the routing-table parameter to route traffic.
I've already requested they add it to tool fetch without much success, maybe more people requesting would put it on the road map.

Who is online

Users browsing this forum: No registered users and 24 guests