Page 1 of 1

how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 7:31 am
by gabak
i have this scenario. I got an ISP and i would like to put some html+jpg in my routerboard and some way when my ISP is down mikrotik will foward that picture or html to everyone saying SORRY THE SERVICE WILL BE DOWN FOR A WHILE.

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 7:55 am
by mrz
You have to set up web server somewhere and then just use netwatch that will enable nat rule which forwards all tcp/80 traffic to your internal webserver. And if link is back will disable that previous rule.

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 8:04 am
by gabak
You have to set up web server somewhere and then just use netwatch that will enable nat rule which forwards all tcp/80 traffic to your internal webserver. And if link is back will disable that previous rule.
hi
yes i had it like that but i dont want to use a pc just for that i figured it could be posible to have all this solution in other routerboard instead of having a lot of things to do what i need. If you have any other ideal , i ll apreciate it a lot

thank you a lot for your quick replay

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 8:09 am
by mrz
As far as I know there are no other solutions. You can't use routers as webservers.

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 10:30 am
by normis
well, you could enable hotspot in these moments, and modify the login page to show your message :)

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 2:56 pm
by gabak
well, you could enable hotspot in these moments, and modify the login page to show your message :)
thxs for ur answer , plz could you give me some basic guideline to follow , i never used hotspot option

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 3:07 pm
by normis
well, you need to try the hotspot setup and see for yourself. in the situation you mentioned, you will need not hotspot created by wizard, but a manually created hotspot (so that it doesn't make any dhcp-servers, upnp rules or other stuff you don't need). this will not be easy to explain, maybe yo want to hire a consultant to do this.

if created correctly, in case of ISP problems you would just click the hotspot 'enable' button and all clients will be force-redirected to the login page, which of course would no longer have any login forms, but your own message. disable hotspot and internet access will be back

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 3:14 pm
by mrz
if you are using RB400 series routers, then you can use new metarouter feature.
Import openwrt image, install apache and use it as web server
it could be easier than messing with hotspot
http://wiki.mikrotik.com/wiki/Metaroute ... al_machine

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 8:29 pm
by Znuff
Wouldn't it be easier for you guys to stop shoving that hotspot in our face and just create a simple configurable webserver for RouterOS? Doesn't need to run anything special. No Server Side scripting, no nothing. Just to serve static files.

Would be usefull to be able to add more than one on different ports. Let's say a user could create a webserver on port 82 where you can redirect all your non-paying customers. You could create another one on port 83 to serve a page that the service is down, another one on port 84 and do whatever-stuff-you-want.

Also, you should think about adding a lm-sensors package for x86 in the near future. Many of us that have needs for high-troughput links are stuck with basic x86 platforms in many places and there are no ways to monitor the voltages/fans/temperatures.

Re: how can i show to all my customers when internet is down?

Posted: Wed May 27, 2009 9:48 pm
by gabak
Wouldn't it be easier for you guys to stop shoving that hotspot in our face and just create a simple configurable webserver for RouterOS? Doesn't need to run anything special. No Server Side scripting, no nothing. Just to serve static files.

Would be usefull to be able to add more than one on different ports. Let's say a user could create a webserver on port 82 where you can redirect all your non-paying customers. You could create another one on port 83 to serve a page that the service is down, another one on port 84 and do whatever-stuff-you-want.

Also, you should think about adding a lm-sensors package for x86 in the near future. Many of us that have needs for high-troughput links are stuck with basic x86 platforms in many places and there are no ways to monitor the voltages/fans/temperatures.
that sounds good , but please could you tell me some guidelines to follow and do what you are saying to see if it 's works?

Re: how can i show to all my customers when internet is down?

Posted: Thu May 28, 2009 1:06 am
by Znuff
Get a secondary web server. Easiest solution by far.

Re: how can i show to all my customers when internet is down

Posted: Mon May 31, 2010 2:08 am
by bigguns
Has anyone manage to get this type of rule up and running?
Given now that the system has moved on, is there any 'easy' way of doing this?

Re: how can i show to all my customers when internet is down

Posted: Mon May 31, 2010 5:56 am
by Myron
i have this scenario. I got an ISP and i would like to put some html+jpg in my routerboard and some way when my ISP is down mikrotik will foward that picture or html to everyone saying SORRY THE SERVICE WILL BE DOWN FOR A WHILE.

yeah is a good thing like gabak idea when the internet down is shows SORRY THE SERVICE WILL BE DOWN FOR A WHILE so that the customer are aware, i have my another rb running hotspot in a hotel sometimes the isp down and the guest call front office asking wats going on with the internet, if mik has a notification in page like this >>> (sorry the service temporarily down) so they are aware.

thanks

Re: how can i show to all my customers when internet is down

Posted: Mon May 31, 2010 8:28 am
by normis
the solution was already provided in the second post from above

Re: how can i show to all my customers when internet is down

Posted: Mon May 31, 2010 12:03 pm
by bigguns
Hi,
Is there no way to just to put a simple Html files on the router, and all traffic route to that file should the netwatch detect something?

Re: how can i show to all my customers when internet is down

Posted: Mon May 31, 2010 12:12 pm
by normis
no, there isn't. routeros doesn't have a webserver you can use. currently it's only for system use for hotspot and some other things

Re: how can i show to all my customers when internet is down

Posted: Mon May 31, 2010 12:16 pm
by bigguns
Ok given, there is a hotspot running on the RB I'd like to do this on - could it not be done all on that hotspot (without having to create another hotspot)?

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 8:05 am
by trevorlc1234
Hey Bigguns,

This is what I did and it works perfectly. It only works when using the hotspot package.

Add the following code to your login.html hotspot page as such
<center><img src='http://www.SOME-EXTERNAL-WEBSITE.com/images/systemup.gif' onerror="this.src='/images/systemdown.gif'" / align="middle"></center>
Upload this attached image to some external website, and adjust the link in the code above for the first img src link to point to this systemup.gif image. Obviously edit the link in the above to the path where you put this gif file. Something like a imagehost service would work well
Image

Then take this image gif
Image
and place it in the /hotspot/images on your mikrotik router.

Now you need to add a allow dst-host entry in your walled-garden for the http://www.SOME-EXTERNAL-WEBSITE.com that you used in the above code for your login.html, so that when your login page gets loaded when your users first login, the login.html page will attempt to load the enternal website with that systemup.gif, successfully loading up the http://www.SOME-EXTERNAL-WEBSITE.com/im ... stemup.gif proving that the internet is UP... If it fails to load that image, the internet must be down, so it then loads just the local image systemdown.gif stored in /hotspot/images of your mikrotik router.

Now after I figured that out I ran into a problem. Alot of us use cookies to keep our users logged in for 24hour or however long. So if the internet goes down, our currently active users would never see the login page because their sessions stay active until their cookies expire and they are not requested to login.

So to solve this problem.
We need to use the Netwatch feature to ping a known up ip address, like google.com and if it fails to ping the IP, then our internet must be down, so we run a script to remove all active sessions and cookies from the mikrotik router, causing the users to be directed back to the login page, thus seeing the systemdown.gif message. The code for the netwatch is as follows.
:local dumplist [/ip hotspot active find]
:foreach i in=$dumplist do={
    /ip hotspot active remove $i
}
:local dumplist [/ip hotspot cookie find]
:foreach i in=$dumplist do={
    /ip hotspot cookie remove $i
}
You netwatch should look sometihng like this
Image

Thats all there is too it. I know its a lot, but if you follow the instructions and try it out, it will work perfectly.
When the internet is up, they will see the systemup.gif on your login page,
When the internet is down, they will see the systemdown.gif page and all active sessions and cookies will get removed, forcing active users when they try to load a webpage, back to the login page to see the systemdown notice.

Once this is setup, the only requirement is that
1. that systemup.gif is accessable on the external website, you can use something like imagehost to host the systemup.gif
2. that google can be pinged.

Its a thing of beauty isn't it.

The only fault I see in it is if google.com is not pingable, because a route to the host is not up, but the rest of the internet is, then you may cause your active users to be booted back to the login page.
But there are other script out there if you look that you can use, that will test a couple of IP addresses and say if all 3 or however many you specify fail at pinging, then run the script code to remove active users and sessions.
The other thing is that, if after the internet goes down, the sessions and cookies are removed, the active users ge booted back to the login page and sees the main login page with the notice. If the try to login again, then they there cookie will get re-established, and they will be logged in again for the cookie liketime. They will no longer see the hotspot login page with the notice again. Maybe again with a better script written, like I mentioned above to ping 3 locations, you could schedule it to run every 10 seconds or whatever, meaning, that if it continued to fail eachtime the schedule ran, it would remove active cookies again. Thus booting those active users out again that tried to login after they were booted the first time. So it will continually clean the active sessions and cookies, as long as the 3 pings test fail.

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 8:15 am
by bigguns
Wow that is very nicly done - I shall be putting that on my system later today! I will let you know how it goes.

But good job

Karma to you Sir!

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 8:22 am
by normis
wow, would never imagine to use "onerror" to determine connectivity :) nicely done!! give trevorlc1234 some karma :)

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 8:33 am
by trevorlc1234
Thanks guys,

I find it works very well. Let me know how it goes BigGuns

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 9:05 pm
by risipetillo
KISS Principle at it's best, I love it !!

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 9:59 pm
by Chupaka
trevorlc1234, nice idea! please make Wiki page not to lose this post! http://wiki.mikrotik.com/wiki/MikroTik_RouterOS

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 11:01 pm
by trevorlc1234
I will do, that's a great idea. I will improve the netwatch script there also so it tests 3 differnt ip's before failing and like I mentioned above make it continue to clear active sessions while the connection is down so every user is always directed back to the login page. Just stuck in traffic now. dead stop... Heading ip to my cottage where I operate my WISP, so I can test the improved netwatch script I write tonight to include on the wiki page. Got some new equipment to install up there too yay. Won't be boating this weekend looks like it's going to rain so time for some WISP upgrades

Re: how can i show to all my customers when internet is down

Posted: Thu Jun 03, 2010 11:05 pm
by fewi
Just an idea, but maybe instead of continuing to clean active connections you could just disable all the login methods (cookie, PAP, CHAP, HTTPS etc.) when an outage is detected and all active connections have initially been cleared. That way no one can login in the first place. Then re-enable them again once the outage is over.

Re: how can i show to all my customers when internet is down

Posted: Fri Jun 04, 2010 5:14 am
by lukkes
really good idea, another easy way can do this it's make an script that check the internet connection by ping, or simple netwatch and when the connection is down just enable a hotspot with customized login page, it's simple... when the connection is up again the script disable the hotspot
like this or something: /ip hotspot [/ip hotspot find] disabled=yes or not..

Re: how can i show to all my customers when internet is down

Posted: Sun Jun 06, 2010 3:42 am
by bigguns
Hey
Sorry it took me so long to come back on this one - I'm now using your coding and I can report that this is working 100% very nicely indeed. Just what I had been hoping for.

trevorlc1234 - could you send tell me your email address please.

Re: how can i show to all my customers when internet is down

Posted: Mon Jun 07, 2010 6:09 am
by trevorlc1234
Hey Bigguns,

Glad the script is working for you. Im not sure how to send you my email. My forum account doesn't let me PM and I don't want to post it here.

I have added a Wiki page on this at
http://wiki.mikrotik.com/wiki/Notify_yo ... nnectivity

I will eventually improve on the monitoring script to montior 3 hosts before posting the notice that internet is down. When I do this I will update the Wiki page with the code script.

Re: how can i show to all my customers when internet is down

Posted: Mon Jun 07, 2010 7:10 pm
by bigguns
Hey, nice job with the wiki page.

Can you email me at XXXX (i will pick it up and then route all traffic to the blackhole afterwards.

Thanks

Re: how can i show to all my customers when internet is down

Posted: Mon Jun 07, 2010 8:12 pm
by trevorlc1234
Ok send now. should be there

Re: how can i show to all my customers when internet is down

Posted: Mon Jun 07, 2010 10:56 pm
by riaanmaree
Just some advice:

This all sounds and look very cool, but just make sure that you are indeed aware of the outage when it happens by monitoring it with The Dude or something like that.

Users might be patient for days before phoning when they see a message saying "we are aware of the problem", but you may not be aware of it if they don't phone you!
:lol: