Hotspot disconnected default page

Hi all,

I use MikroTik + RouterOS to implement an hospot platform with the radius remote authentication system.
I’m looking for a way to display a dafault page when device is disconnected from the www (so the service isn’t available).

This thing is freaking me out, i tried a lot of different solution without luck because when disconnected RouterOS just doesn’t translate addresses and client see the default browser dns error.

I’m looking for a way to redirect users to an internal mikrotik webpage when device is disconnected or the classic login.html when device is connected to the internet.

Is it possible? Please help me.

(Sorry for bad english)

Thank you in advance.
Lorenzo (the spaghetti eater).

  1. set up hotspot, but replace the login page with some error page, or whatever you want
  2. disable all the hotspot setup
  3. make a netwatch script that pings some external IP, and when ping fails, enables all hotspot settings, so users get redirected to the login page with your message

Ok, i tried your solution but i made some mistake.

If the device is connected to the internet the hotspot-> login page is shown correctly and when i phisically disconnected router from the internet the hotspot → login page is not shown (instead the default browser dns error is shown).

It seems like the hotspot service isn’t called at all when the router is not connected to the internet. Is it a dns problem?

My test was:

  1. Create new hotspot service with hotspot setup and configuring it
  2. Replace the login.html code with an error message
  3. Disconnect the routerboard from the internet
  4. Try to connect the service (like an user should do)
    → Result: I can only see the browser dns default error page

Another test was:
5. Reconnect the routerbord to the internet
6. Try to connect the service (like an user should do)
→ Result: I can see the login.html with my error page correctly

So my problem isn’t the hotspot switch script or system but find a way to show an internal page when the device is diconnected from the internet.

Thank you a lot for the help
Lorenzo (the spaghetti eater)

During tests and solution research i notice that:

When device is disconnected from the internet if user’s browser connect to my device’s ip directly so the hotspot page is correctly shown.

So i think the captive portal system is called only if the dns resolution has success else the dns error default browser page is shown.

Thank you in advance

So i think the captive portal system is called only if the dns resolution has success else the dns error default browser page is shown.

Well, yes. Of course. That’s due to how TCP/IP works. For a client to load a web page in a browser it first has to resolve DNS, otherwise it can’t connect to the destination’s IP address. DNS is just a translation layer for names to IPs, it has nothing to do with IP connections actually carrying HTTP.

So, how can i set my device for translate every requests to my internal ip address (to reach the internal error webpage)?

I’m trying to set a dns static setting with a regular expression to translate any name “.*” in my local ip address. But i can’t get it works.

Thanks for help

/ip dns
set allow-remote-requests=yes
/ip dns static
add address=1.1.1.1 disabled=no name=.* ttl=1m comment="catchall"

Note that it’s .*, and not *. as you had. . is not a valid regular expression. * means zero or more, . means any character. So . means one or more characters, any of them. That works. *. is nonsensical.
Of course you’ll also have to make sure the router is used for DNS resolution:

/ip firewall nat
add chain=dstnat protocol=udp dst-port=53 action=redirect
add chain=dstnat protocol=tcp dst-port=53 action=redirect

And then include something like this in your script to enable/disable that catchall DNS entry as it must only be active when there’s a problem condition:

/ip dns static { disable [find comment="catchall"] };

/ip dns static { enable [find comment="catchall"] };