Community discussions

MikroTik App
 
alfa5xx
just joined
Topic Author
Posts: 9
Joined: Fri Mar 30, 2012 5:36 pm

i need a scripts automatic change ip pool 1 to ip pool??

Tue Feb 26, 2013 11:07 am

hi..guys...

i use of mik 5.20.. and create user in userman of mikrotik...

i create a ip pool1 : 192.168.20.1-192.168.20.254

after i create ip pool 2 192.168.30.1-192.168.30.254

..i give to users a ip of my ip pool 1

expamle : i give ip of 192.168.20.21 to username alex in userman of mikrotik

i need to ascript that when users used of his account.. and user expired.. by scripts..
in winbox.. to this user dedcate a ip range of ip pool 2 in userman..

my means is .. change ip 192.168.20.21 of username alex ..to 192.168.30.21 of ip pool 2(192.168.30.1-192.168.30-254)

can i work it by script ???
 
User avatar
dotnet
Frequent Visitor
Frequent Visitor
Posts: 53
Joined: Tue Feb 26, 2013 11:41 am
Location: Chittagong, Bangladesh.

Re: i need a scripts automatic change ip pool 1 to ip pool??

Thu Feb 28, 2013 9:19 am

I think Mikrotik has not proper automatic script for pppoe or hotspot expired user.
May be following these rules for your expired user.

Adding IP pool for Expired / Non Payment Users
/ip pool
add name=Expired-Pool ranges=192.168.30.1-192.168.30.254

Adding Profile for Expired / Non Payment Users
/ppp profile
add change-tcp-mss=default dns-server=192.168.20.1 local-address=192.168.20.1 name=pppoe-expired only-one=default rate-limit=128k/128k remote-address= Expired-Pool use-compression=default use-encryption=default use-ipv6=yes use-mpls=default use-vj-compression=default

Enabling Mikrotik Web.Proxy for Expired / Non Payment Users
Now enable Web proxy, so that expired pool users can be redirected to local proxy where they will be denied and redirected to non payment page on any local web server.
/ip proxy
set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=no enabled=yes max-cache-size=none max-client-connections=1000 max-fresh-time=3d max-server-connections=1000 parent-proxy=0.0.0.0 parent-proxy-port=0 port=3128 serialize-connections=no src-address=0.0.0.0

Redirecting Expired User Requests from web.proxy to any local web server page
Now creating rule in web.proxy to block non payment / expired ip pool access and redirect to local web server page.
/ip proxy access
add action=deny disabled=no dst-port=”" redirect-to=192.168.0.2/nonpayment/nonpayment.html src-address=192.168.30.0/24

192.168.0.2 is a local web server where non payment page is uploaded.

You must create any normal html page (which have the non payment message) and upload it to any web server of your choice, Either It can be local (Preferred) or remote. If its local you won’t have to create any further rules , otherwise if its on remote server like internet, you have to allow user to access that specific particular site folder and place them on top.
Adding NAT Rule to redirect Expired / Non Payment Users to local web proxy
Now add NAT rule so that only users with expired ip pool should be redirected to local web proxy where he will be redirected to any local web server page.
/ip firewall nat
add action=redirect chain=dstnat disabled=no dst-port=80 protocol=tcp src-address=192.168.30.0/24 to-ports=3128

Restrict Access for Expired Users so they cannot use any other internet service
Now add filter rule to restrict expired ip pool users so they cannot access other internet services.
/ip firewall filter
add action=reject chain=forward disabled=no dst-port=!80,8080,3128 protocol=tcp reject-with=icmp-network-unreachable src-address=192.168.30.1-192.168.30.254

Now when you want to block any users for non payment, just change his profile to pppoe-expired profile.

Remember: Rules placement is very important in this method. if you misplace rules, you will not get desired results.


best regards
 
medozeus
just joined
Posts: 1
Joined: Thu Apr 02, 2015 3:31 pm

Re: i need a scripts automatic change ip pool 1 to ip pool??

Thu Apr 02, 2015 3:34 pm

I think Mikrotik has not proper automatic script for pppoe or hotspot expired user.
May be following these rules for your expired user.

Adding IP pool for Expired / Non Payment Users
/ip pool
add name=Expired-Pool ranges=192.168.30.1-192.168.30.254

Adding Profile for Expired / Non Payment Users
/ppp profile
add change-tcp-mss=default dns-server=192.168.20.1 local-address=192.168.20.1 name=pppoe-expired only-one=default rate-limit=128k/128k remote-address= Expired-Pool use-compression=default use-encryption=default use-ipv6=yes use-mpls=default use-vj-compression=default

Enabling Mikrotik Web.Proxy for Expired / Non Payment Users
Now enable Web proxy, so that expired pool users can be redirected to local proxy where they will be denied and redirected to non payment page on any local web server.
/ip proxy
set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=no enabled=yes max-cache-size=none max-client-connections=1000 max-fresh-time=3d max-server-connections=1000 parent-proxy=0.0.0.0 parent-proxy-port=0 port=3128 serialize-connections=no src-address=0.0.0.0

Redirecting Expired User Requests from web.proxy to any local web server page
Now creating rule in web.proxy to block non payment / expired ip pool access and redirect to local web server page.
/ip proxy access
add action=deny disabled=no dst-port=”" redirect-to=192.168.0.2/nonpayment/nonpayment.html src-address=192.168.30.0/24

192.168.0.2 is a local web server where non payment page is uploaded.

You must create any normal html page (which have the non payment message) and upload it to any web server of your choice, Either It can be local (Preferred) or remote. If its local you won’t have to create any further rules , otherwise if its on remote server like internet, you have to allow user to access that specific particular site folder and place them on top.
Adding NAT Rule to redirect Expired / Non Payment Users to local web proxy
Now add NAT rule so that only users with expired ip pool should be redirected to local web proxy where he will be redirected to any local web server page.
/ip firewall nat
add action=redirect chain=dstnat disabled=no dst-port=80 protocol=tcp src-address=192.168.30.0/24 to-ports=3128

Restrict Access for Expired Users so they cannot use any other internet service
Now add filter rule to restrict expired ip pool users so they cannot access other internet services.
/ip firewall filter
add action=reject chain=forward disabled=no dst-port=!80,8080,3128 protocol=tcp reject-with=icmp-network-unreachable src-address=192.168.30.1-192.168.30.254

Now when you want to block any users for non payment, just change his profile to pppoe-expired profile.

Remember: Rules placement is very important in this method. if you misplace rules, you will not get desired results.


best regards


....................................................................................................................................

i know this but please tell me how can i change user from some profile to expire profile when date is finished

actually i turn off the mikrotik and turn it on to change users expire from some profile tp expire profile

Who is online

Users browsing this forum: No registered users and 5 guests