Dear Concern,
We use simple queue to control our bandwidth and unpaid user. Bellow is code for user to redirect them a single website when the are unpaid:
Unpaid user: 103.19.13.3
Redirect to: 103.19.13.215
<?php
/* Example for adding a VPN user */
require('../routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('192.168.1.1', 'router-user', 'router-pass')) {
$API->comm("/ip/firewall/nat/add\n=chain=dstnat\n=src-address=103.19.13.3\n=protocol=tcp\n=action=dst-nat\n=comment=client_id201\n=to-addresses=103.19.13.215\n=to-ports=80");
}
?>
and when they pay their bill we run a cron job to remove this NAT.
Bellow is the code:
<?php
/* Example for adding a VPN user */
require('../routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('192.168.1.1', 'router-user', 'router-pass')) {
//Remove NAT
$API->write('/ip/firewall/nat/print', false);
$API->write('?comment=client_id201', false);
$API->write('=.proplist=.id');
$ARRAYS = $API->read();
$API->write('/ip/firewall/nat/remove', false);
$API->write('=.id=' . $ARRAYS[0]['.id']);
$READ = $API->read();
}
?>
Can anyone help to add some new feature? Bellow is the list we want to do:
- We need a code to redirect all website to a particular site except three.
Example bellow:
All site will be redirect to unpaid site.
www.anysite.com ->> www.mysite-primary.com/unpaid.php
www.othersite.com ->> www.mysite-primary.com/unpaid.php
www.allsite.com ->> www.mysite-primary.com/unpaid.php
but still user will be able to visit whitelisted site:
www.mysite-2.com ->> www.mysite-2.com
www.mysite-3.com ->> www.mysite-3.com
can anyone help?