Community discussions

MUM Europe 2020
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Hotspot login/redirect page without internet

Mon Jun 30, 2014 4:47 pm

There seem to be a ton of questions on this topic and not clear answers to it.
Issue: when the ISP is down users dont realy know that, so when they connect and nothing happens, the login page does not come up. There are seemingly good solutions on notifying the users of the status like http://wiki.mikrotik.com/wiki/Notify_yo ... nnectivity but the issue is that without public internet users are not directed to that login page which would do the rest of the notifying. Most other solutions are suggesting to create DNS which makes no sense because the login page is fully factional if you browse to it manually by IP or hostname, the dns entry is automatically created with hotspot setup.
So anybody has a clear suggestion solutions on why redirection to the hotspot login page needs internet? and how to change it?
There are a ton of aplications that the hotspot can be used without the internet. Any RouterOS brainiacs please.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Hotspot login/redirect page without internet

Mon Jun 30, 2014 7:57 pm

The DNS must be working because if one user has like "www.yahoo.com" as homepage,
the browser before to try to connect to the web sites and show login page, want the DNS solved.
If the DNS is not working, the user never see any type of web page, but simply one reply like "DNS not working" from the browser...

Catch the point?
I'm Italian, not English. Sorry for my imperfect grammar.
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 12:03 am

The DNS must be working because if one user has like "www.yahoo.com" as homepage,
the browser before to try to connect to the web sites and show login page, want the DNS solved.
If the DNS is not working, the user never see any type of web page, but simply one reply like "DNS not working" from the browser...

Catch the point?
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 12:14 am

well as i stated the DNS is not the issue in this case because I don't need to resolve anything else but the hotspot itself and it is being resolved. I can ping by hostname ( from the router and the client) i can browse to it and it has an entry in the DNS automatically created and working fine. The issue is that the client when connected to the hotspot is not being redirected to a login page when there is no internet connectivity. If I do manually - no problem. And in my case the login page is not even a login it is made to login automatically, it just serves as start page for some info that I want users to see. The hotspot is not even intended to connect to the internet so it does not need to resolve any other hosts but itself. And it does it. The issue is when you try to browse for anything it should go to the login or in my case the info page.

Thanks though.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 10:55 am

I think you not understand what I have writed.

1) Client connected to HotSpot must use hotspot DNS;

2) Client must have hotspot as homepage on browser.

Probably the first is true, by DHCP server / DNS redirect inside HotSpot,
but the client MUST ALREADY HAVE as homepage on browser your hotspot address, like when you entry it manually.

3) If you want redirect all your users on "Sorry, no internet" page, you can create any rule on firewall, included force to use routerboard DNS, but if public DNS are not reachable, your message are never displayed if some user try to connect on one site not on DNS cache...

One of us not understand what the other says.
I'm Italian, not English. Sorry for my imperfect grammar.
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 4:43 pm

yes probably we misunderstand each other somewhere, but lets narrow it down. From what you are saying I understand that it is not possible to have all users directed to a "Sorry no internet" page without access to a public DNS.

your 1) point is easily accomplished by DHCP and that how it actually is.
2) cannot be used
3) If there is access to public DNS there is access to internet. In addition, how would this http://wiki.mikrotik.com/wiki/Notify_yo ... nnectivity solution work if what you are saying would be true ?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 4:51 pm

yes probably we misunderstand each other somewhere, but lets narrow it down. From what you are saying I understand that it is not possible to have all users directed to a "Sorry no internet" page without access to a public DNS.

your 1) point is easily accomplished by DHCP and that how it actually is.
2) cannot be used
3) If there is access to public DNS there is access to internet. In addition, how would this http://wiki.mikrotik.com/wiki/Notify_yo ... nnectivity solution work if what you are saying would be true ?
On the wiki is a big mistake: is supposed to work on login page, but is missing how to force login page to show up if DNS fails...

The concept is very simple: IF DNS CAN NOT BE SOLVED, THE HOTSPOT NEVER ARE USED BY BROWSER because if the dns not work, on what IP the browser try to open the web page?...

You must make one script on link down with force DNS to reply everytime for each site request the ip address of hotspot....
/ip dns static
add address=<hotspot-address> name=".*\\..*"
and remove the entry when the link come back
I'm Italian, not English. Sorry for my imperfect grammar.
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 5:40 pm

Thanks, this is big difference in a way that after making this DNS entry when the browser tries to browse anything on first attemtp it gets page not found 404 error and on the second it gets the "Sorry internet not available" So it looks like it can be done, please give me a suggestion on how to get it on the first try to browse.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 5:56 pm

My big hint is:
/ip dns static
add address=<address-where-page-not-internet-available-are> name=".*\\..*"
;)

it's hard help further without knowing all your network...
I'm Italian, not English. Sorry for my imperfect grammar.
 
reinerotto
Member
Member
Posts: 440
Joined: Thu Dec 04, 2008 2:35 am

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 10:07 pm

the browser tries to browse anything on first attemtp it gets page not found 404 error and on the second it gets the "Sorry internet not available" So it looks like it can be done, please give me a suggestion on how to get it on the first try to browse.
Do not believe, this can be done reliably: The browser (or clients PC) usually has a private DNS-cache. When connection to internet goes down, browser does not know about it. With next request, browser might use a cached DNS entry. Only when this fails, browser tries to do new DNS, getting your no-connect-page.
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 10:25 pm

no I think it can and rextended pointes me onto a good route, It works to the points where I am testing it and so far the problem is that the commands in srcipts works only sometimes and sometimes do not. Thanks in any case, and its hard to believe that there is something that Mikrotik cannot do :)
 
reinerotto
Member
Member
Posts: 440
Joined: Thu Dec 04, 2008 2:35 am

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 11:12 pm

that there is something that Mikrotik cannot do
Has nothing to do with MT. In case, there is no DNS entry in browsers or clients PC DNS-cache, the proposed solution will work, as there has to be a DNS request, immediately going to your no-connection-page. In case, user just navigates to another page in same domain, it will only work on second attempt. Or later. Thats, why I said, it can not work reliably in all cases on first attempt. So your wish, to always work on first attempt, can not be fulfilled in all cases.
 
vardas
just joined
Topic Author
Posts: 7
Joined: Mon Jun 30, 2014 4:19 pm

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 11:22 pm

Yes you are right. I got the scripts to work to change the DNS and when the ISP goes down the redirect happens from the Http://original_host/original.url to Http://mikrotik_hotspot/original.url and the mikrotik dispalys the "sorry internet is down" page but the images are not there. So My guess is that a more complex solution is needed to capture and redirect with layer7 on the firewall. And I am still pretty sure it can be done.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Hotspot login/redirect page without internet

Tue Jul 01, 2014 11:59 pm

The images must be put on hotspot html directory to be showed, like the default mikrotik logo on default hotspot pages.

The problem is not http on port 80, but https on port 443, you can not redirect https page, because if for example you request https://www.google.com the hotspot can not impersonate www.google.com and you get only certificate errors....
I'm Italian, not English. Sorry for my imperfect grammar.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2950
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: Hotspot login/redirect page without internet

Wed Jul 02, 2014 12:02 am

...So My guess is that a more complex solution is needed to capture and redirect with layer7 on the firewall...
is less complex than you think...

on internet down, simply redirect all traffic incoming from (hotspot) users tcp except ports 53, 443 and 8291 to hotspot port 80...
I'm Italian, not English. Sorry for my imperfect grammar.
 
electravis
Member Candidate
Member Candidate
Posts: 257
Joined: Tue Jan 26, 2010 12:06 am

Re: Hotspot login/redirect page without internet

Wed Jun 10, 2015 11:08 pm

The one thing I found that was missing was adding a ttl for the static DNS. If you do not add one it will set it to 1 day which when your hotspot comes back online will mess you up.
 
jamesl
just joined
Posts: 1
Joined: Wed Dec 16, 2015 3:30 pm

Re: Hotspot login/redirect page without internet

Wed Dec 16, 2015 3:41 pm

electravis, vardas, if you're still watching this thread, did you eventually find solutions that worked well and reliably for most clients, including Android?

I'm a mikrotik newb, and need to do basically what's detailed in this thread, but don't want to start if it's not actually possible to do reliably ;)

J
 
electravis
Member Candidate
Member Candidate
Posts: 257
Joined: Tue Jan 26, 2010 12:06 am

Re: Hotspot login/redirect page without internet

Wed Dec 23, 2015 12:21 am

Ok so what we did is if there is no internet the user gets redirected to a std html page dished out by the tik. Seems to work for all devices we have tested.

First we have a static DNS entry that is disabled
0 XR .*\..* 10.200.20.1 10s


Next we have a a netwatch rule that will either disable it if internet and disable if not

0 X host=8.8.8.8 timeout=3s interval=10s since=nov/16/2015 03:46:30
status=unknown up-script=/ip dns static disable numbers=0
down-script=/ip dns static enable numbers=0



Next you need two folders in your files your hotspot when you are online and hotspot when you are offline.

Finally one more netwatchrule rule
host=192.168.9.250 timeout=2s interval=10s since=dec/17/2015 08:50:10
status=up up-script=ip hotspot profile set Support html-
directory=hotspot-support-online
down-script=ip hotspot profile set Support html-directory=hotspot-
support-offline


Hope that helps
 
ilja
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Feb 22, 2018 1:15 pm

Re: Hotspot login/redirect page without internet

Mon Mar 12, 2018 4:25 pm

Has anyone succeeded in making it work? :/
 
Muqatil
Trainer
Trainer
Posts: 574
Joined: Mon Mar 03, 2008 1:03 pm
Location: London - UK
Contact:

Re: Hotspot login/redirect page without internet

Mon Mar 12, 2018 7:13 pm

Create a directory called maintenancePage and put there your html with the maintenance page files. No external references, a simple html page with few images would work.
Add fake DNS resolution (depending on ROS version, one of them will fail)
/ip dns static add address=1.2.3.4 comment=MAINTENANCE disabled=yes name=".*" ttl=10s
/ip dns static add address=1.2.3.4 comment=MAINTENANCE disabled=yes regexp=".*" ttl=10s
Add a Netwatch to enable these entries, change the directory of the hotspot and kick everyone out to force them to reauth
/tool netwatch
add down-script="{\\\r\
    \n/ip dns static enable [/ip dns static find where comment~\"MAINTENANCE\"];\\\r\
    \n/ip hotspot profile set [/ip hotspot profile find where html-directory~\"NORMALDIRECTORY\"] html-directory=\"maintenancePage\";\\\r\
    \n/ip hotspot active remove [/ip hotspot active find];\\\r\
    \n/radius disable [/radius find];\\\r\
    \n}" host=REMOTEHOSTTOBEPINGED timeout=2s up-script="{\\\r\
    \n/ip dns static disable [/ip dns static find where comment~\"MAINTENANCE\"];\\\r\
    \n/ip hotspot profile set [/ip hotspot profile find where html-directory~\"maintenancePage\"] html-directory=\"NORMALDIRECTORY\";\\\r\
    \n/radius enable [/radius find];\\\r\
    \n}"
If you have custom configs on your device, adjust the script accordingly
Renato Bernardi

skype: medtech5
 
ilja
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Feb 22, 2018 1:15 pm

Re: Hotspot login/redirect page without internet

Tue Mar 13, 2018 8:27 am

Create a directory called maintenancePage and put there your html with the maintenance page files. No external references, a simple html page with few images would work.
Add fake DNS resolution (depending on ROS version, one of them will fail)
/ip dns static add address=1.2.3.4 comment=MAINTENANCE disabled=yes name=".*" ttl=10s
/ip dns static add address=1.2.3.4 comment=MAINTENANCE disabled=yes regexp=".*" ttl=10s
Add a Netwatch to enable these entries, change the directory of the hotspot and kick everyone out to force them to reauth
/tool netwatch
add down-script="{\\\r\
    \n/ip dns static enable [/ip dns static find where comment~\"MAINTENANCE\"];\\\r\
    \n/ip hotspot profile set [/ip hotspot profile find where html-directory~\"NORMALDIRECTORY\"] html-directory=\"maintenancePage\";\\\r\
    \n/ip hotspot active remove [/ip hotspot active find];\\\r\
    \n/radius disable [/radius find];\\\r\
    \n}" host=REMOTEHOSTTOBEPINGED timeout=2s up-script="{\\\r\
    \n/ip dns static disable [/ip dns static find where comment~\"MAINTENANCE\"];\\\r\
    \n/ip hotspot profile set [/ip hotspot profile find where html-directory~\"maintenancePage\"] html-directory=\"NORMALDIRECTORY\";\\\r\
    \n/radius enable [/radius find];\\\r\
    \n}"
If you have custom configs on your device, adjust the script accordingly
Thank you, Muqatil for your answer.
I am trying to implement your solution now, but it sees that down/up scripts are not working.
I have two folders: "hotspot_office" - when internet is working and "hotspot_test" when ISP is down. However the html_directory as well as dns are not changed when ISP goes down.
Please see my screenshoots:
Netwatch host:
host.png
When ISP is down:
down.png
ISP up:
up.png
You do not have the required permissions to view the files attached to this post.
 
Muqatil
Trainer
Trainer
Posts: 574
Joined: Mon Mar 03, 2008 1:03 pm
Location: London - UK
Contact:

Re: Hotspot login/redirect page without internet

Tue Mar 13, 2018 11:41 am

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];}
Renato Bernardi

skype: medtech5
 
ilja
Frequent Visitor
Frequent Visitor
Posts: 55
Joined: Thu Feb 22, 2018 1:15 pm

Re: Hotspot login/redirect page without internet

Tue Mar 13, 2018 4:06 pm

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!
 
Muqatil
Trainer
Trainer
Posts: 574
Joined: Mon Mar 03, 2008 1:03 pm
Location: London - UK
Contact:

Re: Hotspot login/redirect page without internet

Tue Mar 13, 2018 7:27 pm

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.
Renato Bernardi

skype: medtech5
 
hida
just joined
Posts: 2
Joined: Mon May 21, 2018 4:48 pm

Re: Hotspot login/redirect page without internet

Mon May 21, 2018 7:28 pm

Ya, it's working... great idea.
thanks for Muqatil.
 
dbaricawa
just joined
Posts: 5
Joined: Wed Sep 12, 2018 10:25 am

Re: Hotspot login/redirect page without internet

Thu Sep 13, 2018 5:50 am

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
You do not have the required permissions to view the files attached to this post.
 
dbaricawa
just joined
Posts: 5
Joined: Wed Sep 12, 2018 10:25 am

Re: Hotspot login/redirect page without internet

Thu Sep 13, 2018 10:49 am

Hello sir muqatil

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

here my config.
problem.JPG
/interface wireless
set [ find default-name=wlan1 ] disabled=no mode=ap-bridge ssid=MikroTik
/interface wireless security-profiles
set [ find default=yes ] supplicant-identity=MikroTik
add authentication-types=wpa-psk,wpa2-psk eap-methods="" \
management-protection=allowed mode=dynamic-keys name=profile1 \
supplicant-identity="" wpa-pre-shared-key=sphynx17sag \
wpa2-pre-shared-key=sphynx17sag
/interface wireless
set [ find default-name=wlan2 ] band=5ghz-a/n/ac disabled=no mode=\
station-bridge security-profile=profile1 ssid=HYPERNET
/ip hotspot profile
set [ find default=yes ] html-directory=flash/NORMALDIRECTORY
add dns-name=jusme.hotspot.com hotspot-address=100.100.1.1 html-directory=\
flash/NORMALDIRECTORY login-by=http-chap,https name=hsprof1
/ip pool
add name=hs-pool-1 ranges=100.100.1.2-100.100.1.254
/ip dhcp-server
add address-pool=hs-pool-1 disabled=no interface=wlan1 lease-time=1h name=\
dhcp1
/ip hotspot
add address-pool=hs-pool-1 disabled=no interface=wlan1 name=hotspot1 profile=\
hsprof1
/tool user-manager customer
set admin access=\
own-routers,own-users,own-profiles,own-limits,config-payment-gw
/ip address
add address=100.100.1.1/24 interface=wlan1 network=100.100.1.0
add address=172.16.0.32/24 interface=wlan2 network=172.16.0.0
/ip dhcp-client
add dhcp-options=hostname,clientid interface=wlan2
/ip dhcp-server network
add address=100.100.1.0/24 comment="hotspot network" gateway=100.100.1.1
/ip dns
set allow-remote-requests=yes servers=8.8.8.8
/ip dns static
add address=1.2.3.4 comment=MAINTENANCE disabled=yes regexp=.* ttl=5m
add address=100.100.1.1 name=jusme.hotspot.com ttl=5s
/ip firewall filter
add action=passthrough chain=unused-hs-chain comment=\
"place hotspot rules here" disabled=yes
/ip firewall nat
add action=passthrough chain=unused-hs-chain comment=\
"place hotspot rules here" disabled=yes
add action=masquerade chain=srcnat out-interface=wlan2
add action=masquerade chain=srcnat comment="masquerade hotspot network" \
src-address=100.100.1.0/24
add action=redirect chain=dstnat dst-port=53 protocol=udp to-ports=53
add action=redirect chain=dstnat dst-port=53 protocol=tcp to-ports=53
/ip hotspot user
add name=admin password=admin
/ip route
add check-gateway=ping distance=1 gateway=172.16.0.1
/ip service
set www-ssl certificate=Hotspot
/radius
add address=1.2.3.4 secret=12345 service=hotspot
/system clock
set time-zone-name=Asia/Manila
/system routerboard settings
set silent-boot=no
/tool netwatch
add down-script="{\\\r\
\n/ip dns static enable [/ip dns static find where comment~\"MAINTENANCE\"\
];\\\r\
\n/ip hotspot profile set [/ip hotspot profile find where html-directory~\
\"NORMALDIRECTORY\"] html-directory=\"maintenancePage\";\\\r\
\n/ip hotspot active remove [/ip hotspot active find];\\\r\
\n/radius disable [/radius find];}" host=8.8.8.8 interval=10s timeout=2s \
up-script="{\\\r\
\n/ip dns static disable [/ip dns static find where comment~\"MAINTENANCE\
\"];\\\r\
\n/ip hotspot profile set [/ip hotspot profile find where html-directory~\
\"maintenancePage\"] html-directory=\"NORMALDIRECTORY\";\\\r\
\n/radius enable [/radius find];}"
/tool user-manager database
set db-path=flash/user-manager
You do not have the required permissions to view the files attached to this post.
 
dbaricawa
just joined
Posts: 5
Joined: Wed Sep 12, 2018 10:25 am

Re: Hotspot login/redirect page without internet

Thu Sep 13, 2018 1:31 pm

IT really WORK.

thanks a lot, sir muqatil
 
josueshay
just joined
Posts: 1
Joined: Fri Jan 24, 2020 6:31 pm

Re: Hotspot login/redirect page without internet

Fri Jan 24, 2020 7:16 pm

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
You do not have the required permissions to view the files attached to this post.
 
User avatar
CyB3RMX
Member Candidate
Member Candidate
Posts: 137
Joined: Thu May 26, 2011 7:08 am

Re: Hotspot login/redirect page without internet

Sat Jan 25, 2020 12:20 am

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.
Have a great day!
Certified: MTCNA - MTCWE - MTCRE

Who is online

Users browsing this forum: Sob and 80 guests