PHP Classes
elePHPant
Icontem

Mikrotik: Manipulate data of Mikrotik servers

Recommend this page to a friend!
  Info   View files Example   View files View files (19)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-10-10 (21 hours ago) RSS 2.0 feedNot yet rated by the usersTotal: 147 This week: 15All time: 8,619 This week: 36Up
Version License PHP version Categories
mikrotik 1.0.2Custom (specified...5Networking, PHP 5, Databases, Hardware
Description Author

This package can manipulate data of Mikrotik servers.

It can obtain data about Mikrotik servers and store it in a local database using PDO.

The package supports the following types of servers:

- Address List
- Bridge
- ether
- Graph
- IP-ARP
- NAS
- PING
- Queue List
- Sec Profile
- WLAN

Innovation Award
PHP Programming Innovation award nominee
May 2018
Number 5
Mikrotik is a brand of a company that produces hardware like network routers and servers.

This type of hardware can be controlled remotely via Internet connections.

This package provides means to communicate Mikrotik hardware from PHP, so it can be used to implement Web applications that can control the hardware from any where in the world where users have an Internet connection.

Manuel Lemos
  Performance   Level  
Name: Fernando <contact>
Classes: 3 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 3x

Winner: 1x

Details

Documentação

Este repositório deve cobrir mas não limita-se a: Addres List, Bridge, Ether, Graph, IP-ARP, NAS, PING, Queue List, Sec Profile, WLAN,.. Este Repositório é parte do sistema Synet para provedores de internet.

Tratamento de erros e exceções do Mikrotik

basicamente o que sera necessario obter da api em caso de erros seriam os
campos marcados em * e tratar baseado na tabela `MIKROTIK ERROR CATEGORY`

*>>> !trap

`*>>> =category=1`
`*>>> =message=input does not match any value of interface`

*
MIKROTIK ERROR CATEGORY 
*
0 - missing item or command
1 - argument value failure
2 - execution of command interrupted
3 - scripting related failure
4 - general failure
5 - API related failure
6 - TTY related failure
7 - value generated with :return command
*

Interfaces

Todos os scripts contidos nesse pacote devem executar operações no servidor 
Mikrotik usando o metodo API. Nesse pacote vou disponibilizar apenas a interface 
para administração de NAS, no entanto essa interação pode ser feita atraves de uma 
requisição do tipo GET ou POST dependendo do script.

Autenticação com o servidor

Os dados de autenticação devem ser passados diretamente no script ou chamado 
via consulta no banco de dados. 

Banco de Dados

`Create User, Grant Privilegies for that user, Create Database, Grant Privilegies for that database.`
`CREATE USER 'synet'@'localhost' IDENTIFIED VIA mysql_native_password USING '*';`
`GRANT ALL PRIVILEGES ON . TO 'synet'@'localhost' REQUIRE NONE WITH GRANT OPTION 
	MAX_QUERIES_PER_HOUR 0  MAX_CONNECTIONS_PER_HOUR 0  MAX_UPDATES_PER_HOUR 0  MAX_USER_CONNECTIONS 0;`
`CREATE DATABASE IF NOT EXISTS `synet`;`
`GRANT ALL PRIVILEGES ON `synet`.* TO 'synet'@'localhost';`
`GRANT ALL PRIVILEGES ON `synet\_%`.* TO 'synet'@'localhost';`

Importar arquivo `schema.sql` para o banco usando o comando:
`mysql -h <ip> -u <user> -p<passwd> <database> < /path/schema.sql`

Dados para teste

Cada script possui seu proprio array com dados, no momento os testes estão sendo 
feitos apenas com arrays para efeito de demonstração.

Servidor Mikrotik para teste

Para poder testar o script eu sugiro ter o seu proprio servidor mikrotik.
Caso não possua um servidor para testes, acompanhe a tread no site do mikrotik 
(https://forum.mikrotik.com/viewtopic.php?f=2&t=104266&sid=67bcf476eae0590d962662349e343a05&start=400), 
alguem disponibilizou um servidor de testes porem não estou certo que esteja online ainda.

Development Roadmap (TODO LIST)

  • [ ] Gerenciar grupos de usuarios do mikrotik.
  • [ ] Gerenciar usuarios do mikrotik.
  • [ ] Gerenciar os serviço do sistema (IP>Services).
  • [ ] Cadastro de servidor Hotspot.
  • [ ] Cadastro de servidor PPPoE.
  • [ ] Automação Geral do servidor mikrotik.
  • [ ] Visualização geral do servidor.
  • [ ] Visualização geral do servidor NAS (repetidoras).
  • [x] Edição de Ether Interfaces.
  • [x] Set Mikrotik Security Profiles.
  • [x] Mikrotik Queue List.
  • [x] Mikrotik Bridge Set.
  • [x] Mikrotik Bridge Ports Set.

Referencias

http://wiki.mikrotik.com/wiki/API_PHP_class#Class
https://forum.mikrotik.com/viewtopic.php?f=2&t=104266&sid=67bcf476eae0590d962662349e343a05&start=400
  Files folder image Files  
File Role Description
Files folder imageclass (2 files)
Plain text file config.php Example Example script
Plain text file LICENSE Lic. License text
Plain text file mikrotik_address_list.php Example Example script
Plain text file mikrotik_bridge_ports_set.php Test Added Mikrotik Bridge Ports Set
Plain text file mikrotik_bridge_set.php Test Added Mikrotik Bridge Set
Plain text file mikrotik_ether_edit.php Example Example script
Plain text file mikrotik_graphing_list.php Example Example script
Plain text file mikrotik_ip-arp.php Example Example script
HTML file mikrotik_nas_admin.html Doc. Documentation
Plain text file mikrotik_nas_admin.php Example Example script
Plain text file mikrotik_nas_admin_action.php Example Example script
Plain text file mikrotik_ping.php Example Example script
Plain text file mikrotik_queue_list.php Example Example script
Plain text file mikrotik_secprofile_set.php Example Example script
Plain text file mikrotik_wlan_edit.php Example Example script
Plain text file README.md Doc. Documentation
Plain text file schema.sql Data Auxiliary data

  Files folder image Files  /  class  
File Role Description
  Plain text file medoo.class.php Class Class source
  Plain text file RouterosAPI.class.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:147
This week:15
All time:8,619
This week:36Up