Hotspot login/redirect page without internet

Did you copy paste the script into the terminal or did you use Winbox? There are too many escape characters
The DOWN script should be:

{\
/ip dns static enable [/ip dns static find where comment~"MAINTENANCE"];\
/ip hotspot profile set [/ip hotspot profile find where html-directory~"NORMALDIRECTORY"] html-directory="maintenancePage";\
/ip hotspot active remove [/ip hotspot active find];\
/radius disable [/radius find];}

The UP script should be:

{\
/ip dns static disable [/ip dns static find where comment~"MAINTENANCE"];\
/ip hotspot profile set [/ip hotspot profile find where html-directory~"maintenancePage"] html-directory="NORMALDIRECTORY";\
/radius enable [/radius find];}

Awesome, thank you, Muqatil!

Can’t express how grateful i am for your help!

If you dont mind, could you please explain the trick with DNS entry? Why shall we add it and what does it do?

Thank you!

Quite simple, as @rextended said, the browser still needs to be tricked that internet works.
The first thing that the browser do is a DNS request to resolve the domain (IE www.mikrotik.com) and then initialises the connection to the corresponding IP address. That connection can be intercepted by Hotspot and therefore the maintenance page is prompted.
The TTL of 10s will ensure a quick clearance of the fake DNS resolution as soon as the internet connectivity is back.
With the latest ROS versions you can use the internet-sensing feature instead of netwatch but I didn’t manage yet to test it.

Ya, it’s working… great idea.
thanks for Muqatil.

hello muqatil

why is my maintenance page not showing when connecting to a wifi hotspot. when I try to access it manually it shows error 404

can you please please tell what wrong?

have two folders: “NORMALDIRECTORY” - when the internet is working and “maintenancePage” when the internet is down.
problem.JPG
thanks in advance

Hello sir muqatil

I did every you told to do but it didn’t work. still not go to the maintenance page
problem.JPG

IT really WORK.

thanks a lot, sir muqatil

Hello everyone,

I know that the subject dates from more than 2 years but I have the same problem I tried to apply the method of Muqatil but without internet I am not redirected automatically
hotspot.png

the DNS redirection does not work for me, i just try it again by making a reset on the router and fresh start it, and when the Redirection is on, on an iPhone show that “Unable to open webpage, to many redirections” (is in spanish so im not sure if it says the same on the english version, im translating it) Im running rOS 6.46.2 on a RB951Ui-2HnD

im trying to do an offline hotspot, and if the router is not connected to the Internet the page wont even popup… I dont really need the online and offline page, because will show a web page hosted locally with a little calendar of activities for the school.

Any toughts @Muqatil ?
thanks in advance.
JB.

So I managed to get it working.
You need to do few additional things though, to get it to redirect properly and to fool the clients.
This is my down script

{
/ip dns static remove [/ip dns static find where name~“your hotspot fqdn”];
/ip dns cache flush ;
/ip dns static disable [/ip dns static find where comment~“CORRECTION”];
/ip dns static enable [/ip dns static find where comment~“MAINTENANCE”];
/ip hotspot profile set [/ip hotspot profile find where html-directory~“flash/hotspot”] html-directory=“flash/maintenancePage”;
/ip hotspot active remove [/ip hotspot active find];
:log warning “Internet down, showing maintenance page”
;}

&
This is up script

{
/ip dns static disable [/ip dns static find where comment~“MAINTENANCE”];
/ip dns static enable [/ip dns static find where comment~“CORRECTION”];
/ip dns cache flush ;
/ip hotspot profile set [/ip hotspot profile find where html-directory~“flash/maintenancePage”] html-directory=“flash/hotspot”;
/ip hotspot profile set [/ip hotspot profile find where html-directory~“flash/hotspot”] dns-name=“www. Your hotpot fqfn”;
/ip hotspot profile set [/ip hotspot profile find where html-directory~“flash/hotspot”] dns-name=“your site fqdn”;
:log warning “Internet up, showing normal hotspot page”
;}

And be sure to add a static dns entry for your site at priority
As attached screenshot with “comments as written” using regex entry.

Yes agreed some of the above is redundant and unnecessary but i do it anyway to be super safe.

Essentially the static dns gives priority to static entry over dynamic ones so when we add a static entry to fool dns (when internet is down) it effects the hotspot static entry too, making it impossible to use another ip other than hotpot ip to fool clients as when we add a different ip the pages do not redirect.
Adding these entries helps to successfully fake dns to a non working ip while still making sure hotspot ip works as intended.

quoted for keep on forum without the original author can not delete that…

Still im not able to make it work.. When in Maintenance mode my iphone tries to open the page and then an error comes up that “hotspot login cannot open the page because too many redirects occurred” … any ideas? Thanks in advance.
JB