Community discussions

MikroTik App
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Can Make mikrotik check if extrnal web proxy is working or ?

Tue Jun 22, 2010 12:49 pm

Hello
I am working on Mikrotik v 3.30
I want to use Parent proxy but Connection is down to users if Parent proxy goes down, so i am asking if there is a way to make Mikrotik check this parent proxy every while and if it is down it he uses a direct connection.

all i want is a Method to check other proxy servers if it is working or not via mikrotik?

Thanks for People who is help others.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Can Make mikrotik check if extrnal web proxy is working

Tue Jun 22, 2010 4:48 pm

Yes. If you just want to watch for generic connectivity use NetWatch (see manual) to fire a script when the external proxy stops pinging, and another one when it starts pinging again. If you want to monitor on an application level make mangle/NAT rules that force the router itself through the proxy for specific transactions and schedule a script that in turn calls another script that sets a global to false, downloads the file, then sets the global to true. If the download fails (strong case that the proxy is down, but you MUST make sure the final download source is very, very reliable) that second script will error out and the global will never be set to true, so the first script can detect proxy failure and then take the appropriate actions.
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Tue Jun 22, 2010 6:04 pm

Thanks for replay
for Netwatch i really try it but there is some proxys replar in ping but it is not replay in web proxy

and for
"If you want to monitor on an application level make mangle/NAT rules that force the router itself through the proxy for specific transactions and schedule a script that in turn calls another script that sets a global to false, downloads the file, then sets the global to true. If the download fails (strong case that the proxy is down, but you MUST make sure the final download source is very, very reliable) that second script will error out and the global will never be set to true, so the first script can detect proxy failure and then take the appropriate actions."

Would you please give me some samples
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Can Make mikrotik check if extrnal web proxy is working

Tue Jun 22, 2010 6:46 pm

Sorry, I won't have time to script that out beyond general suggestions.
Maybe someone else will.
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Wed Jun 23, 2010 9:29 am

Thanks for you
I got what you mean but just i want you to mention the commands to do the following actions and i will learn them and continue:
How can i force the router through the proxy?
How can i set the global to true or to false?
What you mean by monitor application level?

For example:
How can i downloads the file?
you can download the file using command "tool/fetch"

Just this what i want for now.
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Wed Jun 23, 2010 3:00 pm

Any Help!!
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Wed Jun 23, 2010 10:40 pm

Huuuuuup
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 3:28 pm

Please fewi help just tell me

How can i force the router through the proxy?
How can i set the global to true or to false?

and i will Make all scripts


Please help no one else answer
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 3:32 pm

make mangle/NAT rules that force the router itself through the proxy for specific transactions
unfortunately, you cannot dst-nat connections of local facilities... so at least you need two routers...
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 3:42 pm

Chupaka
that if i want to do this "make mangle/NAT rules that force the router itself through the proxy for specific transactions"

What about the main problem

"all i want is a Method to check other proxy servers if it is working or not via mikrotik?"

is there any way to do this in your mind?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 4:14 pm

sorry, I can't see the way to do it by ROS means... I'd post it if I know...
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 4:17 pm

Thanks for help brother
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 4:28 pm

Yeah, I was wrong. Destination NAT is before output, so you can't destination NAT router originated traffic. Instead of two routers you could also use a server behind the router that detects proxy failure and uses the API to make configuration changes but I agree that you can't do it natively in one router.
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 4:39 pm

and what is API?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 4:53 pm

API is a way your program may interact with router... you need additional server anyway
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 5:22 pm

ok is there a way to make another program check the proxy and change the mikrotik settings via windows but (Auto i mean) i have a program to check the proxy but how i can change the settings
 
kazanova
Member
Member
Posts: 406
Joined: Tue Sep 06, 2005 11:52 am

Re: Can Make mikrotik check if extrnal web proxy is working

Thu Jun 24, 2010 7:15 pm

can you give as name of programme
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Fri Jun 25, 2010 10:38 am

What you mean by give as name

it seems you are Masri i am also
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8712
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Fri Jun 25, 2010 7:18 pm

he means, 'give us' =)

what program do you use for proxy checking?
 
kazanova
Member
Member
Posts: 406
Joined: Tue Sep 06, 2005 11:52 am

Re: Can Make mikrotik check if extrnal web proxy is working

Fri Jun 25, 2010 10:49 pm

Chupaka that what i mean

iam lebanes :D
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working

Mon Jun 28, 2010 2:20 pm

Program called:

Proxy switcher
 
klibby
just joined
Posts: 10
Joined: Fri Nov 04, 2011 5:25 pm

Re: Can Make mikrotik check if extrnal web proxy is working

Sat Apr 06, 2013 1:25 am

Although this may not help the original poster since this is an old topic, I came across this and was running into the same issue fewi pointed out:
Destination NAT is before output, so you can't destination NAT router originated traffic. Instead of two routers you could also use a server behind the router that detects proxy failure and uses the API to make configuration changes but I agree that you can't do it natively in one router.
Although I found a solution to this, so if anybody like me comes across this thread, you can have the check process scripted in the same box. You don't need a destination NAT rule to force the MikroTik's http request through the proxy, instead you can point /tool fetch to your proxy using the address, host, src-path and method arguments instead of 'url'
/tool fetch address=10.10.10.10 host=www.example.com src-path=status.txt method=http;
Where 10.10.10.10 is the proxy server's IP

Instead of:
/tool fetch url="http://www.example.com/status.txt";
Below is a group of scripts that worked for me. You can add these, then setup a scheduler to run "check_status" at whatever interval you desire.
#### script: check_status
# Edit the following values for your configuration:
# 
# proxyIP = IP Address of your proxy server
# host = Domain name where your status page is hosted.
# path = Path for status page.
# vString = Some text to look for on status page to confirm proxy is online.
# timeout = Time in seconds to wait for fetch to download page before failing.
#
# As set, this would check that "some text to verify" is included on
# page downloaded from http://www.example.com/status.html
# via proxy server at 10.10.10.10:8080
#
:global proxyIP "10.10.10.10";
:global host "www.example.com";
:global path "status.html";
:global port 8080;
:global vString "some text to verify";
:local timeout 3;
:global fstatus;
:execute fetch_status;
:local count 0;
:while ( $fstatus != "success" && $count < ($timeout*10) ) do={
	:set count ($count+1);
	:delay 0.1;
	}
:if ($fstatus = "success") do={
	:execute check_proxy;
	} else={
	:execute disable_proxy;
	}
/system script environment remove [/system script environment find name=fstatus];

#### script: fetch_status
:global fstatus;
:global proxyIP;
:global host;
:global path;
:global port;
/tool fetch address=$proxyIP port=$port host=$host src-path=$path dst-path="status.txt" mode=http;
:set fstatus "success";

#### script: check_proxy
:global vString;
:local result [/file get status.txt contents];
:if ($result~$vString) do={
	:execute enable_proxy;
	} else={
	:execute disable_proxy;
	}
/file remove [/file find name~"status.txt"];

#### script: enable_proxy
# Script to run if proxy is online.

#### script: disable_proxy
#script to run if proxy is offline.

This will first check if the MikroTik can access the status page you specified through the proxy. Next it will verify some string exists within the status page to ensure you're not just seeing some redirect from the proxy. On the status page, you might also want to include the NO-CACHE meta tag. My status page is simple:
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
</head>
<body>
proxy-okay
</body>
</html>
 
User avatar
stlony
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 91
Joined: Mon Nov 19, 2007 6:25 pm
Location: Egypt
Contact:

Re: Can Make mikrotik check if extrnal web proxy is working or ?

Thu Apr 16, 2015 11:55 am

Thanks a lot for giving hand :)
I just read it today