Page 1 of 1

Script to redirect a page with a timer

Posted: Tue Apr 03, 2012 11:03 pm
by thiagomedeiros
Hi i'm a novice with Mikrotik. Before this i used BrazilFW.

Now i have a RB750UP 5.14 version, and i have some clients that i share my connection with them.
But, you know, some clients takes some time to pay and i need to show a warning page to this clients.

I imagined a script that redirect all pages that run in port 80 to this warning ip for a couple of time, like 30 seconds and then disable this script.

Imagined something like this:

if client-ip and client-port-dest == 80 goto 108.174.50.18 set timer to 30seconds and then disable this rule

I need the help of community to translate this code in MK script.
In this case i'll schedule this rule to run every 8 hours in the days 15 to 20, every moth.
I don't want to use hotspot.
My connection is pppoe and i share with nat (masquerade).

Re: Script to redirect a page with a timer

Posted: Wed Apr 04, 2012 8:41 pm
by c0d3rSh3ll
add this rules

/ip firewall nat
add action=dst-nat chain=dstnat comment=redirect disabled=no dst-port=80 protocol=tcp src-address-list=bloqueo to-addresses=108.174.50.18 to-ports=80

add your clients to show a warning page to this address-list

/ip firewall address-list
add address=0.0.0.0 disabled=no list=bloqueo

and then scheduler to run this script

ip fire nat enable [/ip firewall nat find comment=redirect]; delay delay-time=30 ; ip fire nat disable [/ip firewall nat find comment=redirect]


sorry by my english

Re: Script to redirect a page with a timer

Posted: Thu Apr 19, 2012 12:29 am
by thiagomedeiros
Thanks, i'll try next week. I'm travelling now.

Re: Script to redirect a page with a timer

Posted: Tue May 22, 2012 9:12 pm
by thiagomedeiros
It works very well, thank you!

Re: Script to redirect a page with a timer

Posted: Wed May 23, 2012 5:42 pm
by thiagomedeiros
Spanish:
¿Hay una manera de hacer el desbloqueo se realiza sólo cuando el usuario accede a una página, de lo contrario permanecer encerrado hasta que se realice esta acción?

En BrazilFW bloqueo estuvo activo hasta el usuario hace clic en Continuar (en la alerta a la página redireccionada). Por ejemplo, hoy activado el bloqueo y el usuario utiliza Internet sólo de mañana, en cuyo caso el bloqueo está activado hasta que haga clic en la página de advertencia para desbloquear.

MK me estoy convirtiendo en un bloqueo en un tiempo de 1 hora. El problema: El bloqueo se enciende durante 2 minutos (el tiempo que he elegido) y luego 2 minutos después de que el bloqueo está desactivado. Esto es, si el usuario ha accedido a entre el 8, 9, 10 en punto, entró en la cuadra y vi la página, pero si se utiliza el Internet las 8:30 o 11:45 no puede ver.


English:
Is there a way to make the unlocking is done only when the user accesses a page, otherwise stay locked up until he perform this action?

In BrazilFW lock was active until the user clicks on Continue (on page redirected warning). For example, today activated the lock and the user uses the internet only tomorrow, in which case the lock is on until it clicks on the page warning to unlock.

MK I'm turning in a lock in a time of 1 hour. The problem: The lock is turned on for 2 minutes (the time I chose) and then 2 minutes after that the lock is disabled. That is if the User has accessed between 8, 9, 10 o'clock, he entered the block and saw the page, but if he used the Internet 8:30 or 11:45 he can not see.