3

I need help in building a project. Let me first describe my project -

I want to build a Web application (using php / php framework(laravel) , html, css, javaScript, bootstrarp ) that will help ISP owner to manage their router (most of them use Mikrotik router).

Reason to build this App:

Most ISP provider here use Mikrotik router to manage their internet business. But managing the router using Winbox ( a desktop based windows software that is build to manage Mikrotik router) seems complex to them. Just for creating new ip to assign a new user, blocking a user if he/she do not pay bills and managing bandwidth they need to operate winbox every time which they find difficult. My approach is to build a web application that will ease their work.

The features I want to provide are-

  1. Creating new IP address and addressing them to user (internet user / end user)
  2. Manage bandwidth of an IP address
  3. Block / Lock any particular IP address automatically (in this case any particular user) who have not paid their monthly bill on certain date of a month
  4. Re-enabling blocked IP address on paying their dues automatically
  5. Showing daily graph of bandwidth received and used

  6. Recording client history (client IP address, Monthly rent, Name, Address etc.)

  7. Recording payment history of client
  8. Auto bill calculation / due calculation
  9. Auto sort out of due users of months

I am able to do 6 - 9 features as described but I have no idea how to implement 1 - 5 features !

Problem That I am facing :

a. I don't know how to connect to a MikrotiK router via web application b. If some how i can access to the MikrotiK router using router IP address , I don't know how to create new IP address on that router database c. how to manage bandwidth via web application d. how to block / lock ip address !

Points I get myself :

I think using management vlan (router Ip address) i can access to that router form command promt using ssh/telnet. After that what would be the command to create, lock/block, manage bandwidth of an IP address ? IF all this things can be done using command prompt, how can I make it for my web application ?

Can anyone please help me with this, referring any link?? I googled but only thing I find is Mikrotik router management manual !

Erfan Ahmed
  • 1,536
  • 4
  • 19
  • 34
  • 2
    Your question is too broad for Stack Overflow and I'm afraid for anyother site in the SE network. Asking us for a link (off-site resource) is also off-topic. You might try in chat or another forum like Quora that are better suited for these kind of topics. – rene Dec 22 '15 at 08:53
  • 1
    Do you have some experience with WinBox? If not, that's a good place to start. If you can figure out how to accomplish the functions you need in WinBox, most of the windows and dialogs in WinBox translate directly to console commands. The console/CLI commands are accessible with SSH as you proposed, and in principle, your web app could generate these commands and parse responses. There is a "Manual" link right in WinBox that will get you to the online documentation. – Fred Schleifer Dec 22 '15 at 09:12
  • 1
    Use the RouterOS API as it's the fastest, I've got a client that will automatically login to a Mikrotik and do all sorts of stuff from a raspberry pi. I just plug it into any network using a mikrotik router and it runs. I also used ssh and telnet but they're both too slow, so I only use them if i need to but it's automated so i just sit and wait for it to finish. SSH is the slowest. The speed issues could be the script but I was able to use the API and like it. Take a look at cacti or zabbix with traffic flow in RouterOS for the bandwidth data. – Steve Hernandez Jan 30 '16 at 11:19
  • Nice & details Question, which i also need – Faridul Khan May 08 '18 at 06:21
  • @FaridulKhan I've just updated my twitter link in my profile. If you are interested in this topic we may discuss. – Erfan Ahmed May 08 '18 at 07:32

3 Answers3

2

I did part of what you are asking for a customer weeks ago. Your question is to broad, very extensive, it will take months to accomplishes the job.

Start your project with the basic that you can find at http://wiki.mikrotik.com/wiki/API_PHP_class, then you can grow your application and post specific questions about your problems in places like stackoverflow or reddit.

Follow a sample to connect to the API, then execute commands and then disconnect.

$API = new RouterosAPI();
$API->debug = true; // turn debug on to learn more about your api
if ($API->connect($server , $username , $passwd, $port)) {

    // wireless registration table
    $API->write('/interface/wireless/registration-table/print',false);
    $API->write('=stats=');
    // print output here

} else {

    // connection fails
}
$API->disconnect();

Ref.:

devasia2112
  • 5,844
  • 6
  • 36
  • 56
1

You should either use APIs or a remote command protocols like ssh/telnet(PHP-SSH2).
This is a PHP API project you could use: https://github.com/BenMenking/routeros-api
After connecting you can commit commands just like you do on mikrotik console.

Mikrotik commands wiki

Arash
  • 400
  • 4
  • 11
1

In my opinion you better use Radius server with database on MySQL. Mikrotik works perfect with Radius. In application implement interface with the database and all interaction with Mikrotik leaves to Radius. Read about FreeRadius for example:

https://www.howtoforge.com/authentication-authorization-and-accounting-with-freeradius-and-mysql-backend-and-webbased-management-with-daloradius