Community discussions

MikroTik App
 
jayk
newbie
Topic Author
Posts: 44
Joined: Thu Dec 20, 2007 9:04 pm

Display Maintenance Message To Users

Thu Mar 06, 2014 4:20 pm

Is it possible to somehow display a maintenance notice to users of our WISP of upcoming maintenance outages, ect? It would be neat to display when they try to go to a web page or to just display every few hours. Maybe some type of a pass through web page. Not sure if it's even possible. I am very new to Mikrotik and still learning. Whenever we have to do some upgrades to our system we get a lot of calls about being down. This maintenance notice might help with that. I may be wishing for something that's not even possible. Any ideas or help would be appreciated.

Thanks
 
User avatar
aacable
Member
Member
Posts: 435
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: Display Maintenance Message To Users

Fri Mar 07, 2014 1:59 pm

Yes this is possible !

Simply create a NAT rule that redirects http port 80 requests to your local/external proxy service which deny all requests and redirect to local web server page which shows the MAINTENANCE PAGE.

Now create a NETWATCH rule that can keep monitoring any reliable HOST on internet , probably your ISP DNS or GOOGLE DNS , if the link is down, then DOWN script should be triggered which enables the NAT Rule, so in case of any link down all users will be routed to maintenance page, and when the link gets UP, the up script will disable the NAT rule, and internet will start work at user end normally.

Some Examples:

First the NAT rule which actually redirects port 80 requests to internet/external proxy server.
[Make sure the comments remains same in all rules of nat / netwatch, otherwise script will not works,
/ip firewall nat
add action=redirect chain=dstnat comment="Redirect to Proxy" disabled=yes dst-port=80 protocol=tcp to-ports=8080
Now ENABLE web proxy which will deny requests of all users port 80 requests and redirect them to local web server page showing the reason why internet is not working.
/ip proxy
set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=yes enabled=yes max-cache-size=unlimited max-client-connections=600 \
    max-fresh-time=3d max-server-connections=600 parent-proxy=0.0.0.0 parent-proxy-port=0 port=8080 serialize-connections=no src-address=0.0.0.0/ip proxy access

add action=deny disabled=no dst-port="" redirect-to=10.0.0.1/netdown.html

Now the Netwatch script which will keep monitoring the internet, and act accordingly
/tool netwatch
add disabled=no down-script=":log error \"ISP Link seems to be DOWN  , ENABLING  redirection to proxy so users will see mainteneace page / zaib\"\r\
    \n/ip firewall nat enable [find comment=\"Redirect to Proxy\"]" host=8.8.8.8 interval=5s timeout=1s up-script=":log error \"ISP Link seems to be UP again , Disa\
    bling redirection to proxy so users internet will start work again. / zaib\"\r\
    \n/ip firewall nat disable [find comment=\"Redirect to Proxy\"]\r\
    \n"
Result:
rule.png
You can achieve this task with more sophistication and controlled method by using scripts to do various functions like frequency, check multiple hosts instead of single, act according to latency load results, email function, and much much more,
as someone said
"SKY IS THE ONLY LIMIT"
You do not have the required permissions to view the files attached to this post.
 
jayk
newbie
Topic Author
Posts: 44
Joined: Thu Dec 20, 2007 9:04 pm

Re: Display Maintenance Message To Users

Thu Mar 13, 2014 5:37 pm

Awesome. Thanks for the reply. I will see what I can do with your scripts. I am new to Mikrotik and its scripting but with your post I think I can get it working.
 
Xyl2k
just joined
Posts: 20
Joined: Wed Mar 12, 2014 1:13 pm

Re: Display Maintenance Message To Users

Thu Apr 24, 2014 11:51 pm

/ip proxy
set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=yes enabled=yes max-cache-size=unlimited max-client-connections=600 \
max-fresh-time=3d max-server-connections=600 parent-proxy=0.0.0.0 parent-proxy-port=0 port=8080 serialize-connections=no src-address=0.0.0.0/ip proxy access</pre>
add action=deny disabled=no dst-port="" redirect-to=10.0.0.1/netdown.html
This script is not working

Image


70% of script around is not working , it will be helpully if you check twice your script before posting them
 
MovingNetworksFwd
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Tue Feb 18, 2014 1:50 am
Location: Arkansas
Contact:

Re: Display Maintenance Message To Users

Fri Apr 25, 2014 1:49 am

/ip proxy
set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=yes enabled=yes max-cache-size=unlimited max-client-connections=600 \
max-fresh-time=3d max-server-connections=600 parent-proxy=0.0.0.0 parent-proxy-port=0 port=8080 serialize-connections=no src-address=0.0.0.0/ip proxy access</pre>
add action=deny disabled=no dst-port="" redirect-to=10.0.0.1/netdown.html
Try this, there were some spacing problems.

/ip proxy set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=yes enabled=yes max-cache-size=unlimited max-client-connections=600 max-fresh-time=3d max-server-connections=600 parent-proxy=0.0.0.0 parent-proxy-port=0 port=8080 serialize-connections=no src-address=0.0.0.0
/ip proxy access add action=deny disabled=no dst-port="" redirect-to=10.0.0.1/netdown.html


You will have to make a file on the mikrotik called netdown.html which will be called anytime the rule is enacted.

Ryan
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Display Maintenance Message To Users

Fri Apr 25, 2014 2:43 am

All method described are not working in case of fail.

If your network is down there are five(or more really) possibility:

1) The client request http://www.google.com page which already are on your DNS, AND YOUR CLIENT USE YOUR DNS, and correctly the system display the maintenance page.

2) The client request http://www.google.com page which already are on CLIENT DNS cache, and correctly the system display the maintenance page.

3) The client request http://www.google.com page, but client use external DNS like 8.8.8.8.
The DNS are unable to resolve the address and the client browser display "server not found" instead a maintenance page.

4) The client request http://www.google.com, but you do not have http://www.google.com cached on your DNS.
The DNS are unable to resolve the address and the client browser display "server not found" instead a maintenance page.

5) The client request http://www.google.com, the client use YOUR DNS, and you have the DNS configurable to answer all the time with fixed IP for not found DNS (like OpenDNS), and in this way the client display correctly the maintenance page.




*******************
For aacable only:
Hint: STOP using third party source for check....
Think if one time Google stop service for maintenance on 8.8.8.8
Have you one idea about how much system are considered faulty / reboot / wrong routing.....



*******************

/ip proxy access add action=deny disabled=no dst-port="" redirect-to=10.0.0.1/netdown.html

You will have to make a file on the mikrotik called netdown.html which will be called anytime the rule is enacted.
You virtually gain another -1 on Karma.

Have you tried this? "make a file on the mikrotik called netdown.html"

You can not put file inside mikrotik routerboard and make it visible directly. except when using hotspot or customization package (if you buy one stock of 1000 Level3 devices)

"redirect-to=10.0.0.1/netdown.html" are referred to another web server, not routerboard itself.
 
MovingNetworksFwd
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Tue Feb 18, 2014 1:50 am
Location: Arkansas
Contact:

Re: Display Maintenance Message To Users

Fri Apr 25, 2014 5:39 am

[/quote]

You can not put file inside mikrotik routerboard and make it visible directly. except when using hotspot or customization package (if you buy one stock of 1000 Level3 devices)

"redirect-to=10.0.0.1/netdown.html" are referred to another web server, not routerboard itself.[/quote]

rextended,

Quite right on that one, when I do these I use the hotspot as a mini web server. The hotspot is set to allow all pages/addresses as permitted without being logged in (causing it to serve files). I put my unavailable page there which eliminates the need for a web server that is usually unavailable when the network is being worked on anyway. I forgot to note that since most providers I work with are redundantly served from multiple sites the up-times are 4-5 9's on those networks which also means I haven't done configuration of a page like this in quite some time. This is also likely not the best way to do it but it works when I need it and it is completely independent.

Ryan
 
User avatar
aacable
Member
Member
Posts: 435
Joined: Wed Sep 17, 2008 11:58 am
Location: ISLAMIC Republic of PAKISTAN
Contact:

Re: Display Maintenance Message To Users

Fri Apr 25, 2014 7:13 am

*******************
For aacable only:
Hint: STOP using third party source for check....
Think if one time Google stop service for maintenance on 8.8.8.8
rextended: Yes you are absolutely right
I posted just a very basic and simple solution that one can use to get get a very basic idea on hwo it can be achieved , But in a real network, more intelligent method should be used like multiple host check up , not only google dns.
I mentioned that earlier.
"You can achieve this task with more sophistication and controlled method by using scripts to do various functions like frequency, check multiple hosts instead of single, act according to latency load results, email function, and much much more"
 
Xyl2k
just joined
Posts: 20
Joined: Wed Mar 12, 2014 1:13 pm

Re: Display Maintenance Message To Users

Fri Apr 25, 2014 6:10 pm

[/quote]"redirect-to=10.0.0.1/netdown.html" are referred to another web server, not routerboard itself.[/quote]

and if there is really a maintenance problem , it will not grab that page from that server to post on user browser
 
delhite2
just joined
Posts: 13
Joined: Fri May 10, 2019 4:45 pm

Re: Display Maintenance Message To Users

Fri Apr 30, 2021 9:23 pm

there you go.
somebody improved on the script for showing a maintenance page posted here viewtopic.php?p=822430
and posted at this site https://buy.guru
it works perfectly and works flawlessly, attaching the direct link to script here.
but as written do remember to create a second folder and populate it, else it wont work!
https://buy.guru/script-hotspot-mikroti ... nancepage/
Last edited by delhite2 on Fri Apr 30, 2021 11:35 pm, edited 2 times in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Display Maintenance Message To Users

Fri Apr 30, 2021 10:16 pm

you bump a thread from 2014 for another site than have a copy-paste of aleady existent post from 12 Mar 2018 on mikrotik forum???
viewtopic.php?p=822430#p647548
and is not well copy-pasted because missing some pieces...
original author: Muqatil (Renato Bernardi)

you get revenue from buy-guru?
 
delhite2
just joined
Posts: 13
Joined: Fri May 10, 2019 4:45 pm

Re: Display Maintenance Message To Users

Fri Apr 30, 2021 11:06 pm

you bump a thread from 2014 for another site than have a copy-paste of aleady existent post from 12 Mar 2018 on mikrotik forum???
viewtopic.php?p=822430#p647548
and is not well copy-pasted because missing some pieces...
original author: Muqatil (Renato Bernardi)

you get revenue from buy-guru?
Sir that was not well made script, there are lots of differences if you look carefully.
The script i searched and posted captures and redirects properly even when ISP network is not online.
it also deletes existing clients which are logged in so that they know ISP is offline.
it add this
"/ip hotspot cookie remove [find];\"
which i missed and should have included.
if you use both you will realize the difference.
and i would have posted it together with my earlier post, in other thread but i was lazy and did not search hard enough for it, but thankfully you brought it up, if you have the privilege please merge my posts their.
Thanks.

Who is online

Users browsing this forum: Amazon [Bot], Bing [Bot], Majestic-12 [Bot], pmcsill, stefhapx6 and 66 guests