Skip to content

Repository files navigation

Project RouterOS

 

Project RouterOS

Github top language Github language count Repository size License

About   |   Features   |   Technologies   |   Requirements   |   Starting   |   License   |   Author


🎯 About

The Project RouterOS is a PHP-based API wrapper to manage MikroTik devices using RouterOS. This project includes various functions to manage Hotspot, PPPoE, Firewall, DNS, and more. The RouterOSConnection.php file provides an API for connecting to MikroTik devices and executing various commands like managing Hotspot, PPPoE users, and much more. The RouterOSAPI.php file further extends these functionalities with additional tools and system commands.

✨ Features

The following key features are included in this project:

From RouterOSConnection.php:

  • PPPoE Management: Retrieve, add, update, and delete PPPoE users, servers, and profiles;\
  • Hotspot Management: Manage Hotspot users, servers, and profiles;\
  • Firewall Management: Retrieve and manage firewall rules;\
  • DNS Management: Retrieve DNS cache and settings;\
  • Queue Management: Retrieve and add queue configurations;\
  • System Management: Retrieve system resources, reboot the router, and manage system scripts;\
  • Log Management: Retrieve system logs;\
  • Custom Command Execution: Execute custom RouterOS commands.

From RouterOSAPI.php:

  • Connection Management: Easily connect to MikroTik RouterOS using IP, username, and password.
  • Command Execution: Execute RouterOS commands and retrieve results in a structured format.
  • Data Parsing: Automatically parse responses from RouterOS API into associative arrays for easy manipulation.
  • Error Handling: Comprehensive error handling to capture and respond to connection issues or invalid commands.
  • Extensibility: The library is designed to be extended and customized according to your specific needs.

🚀 Technologies

The following technologies are used in this project:

✅ Requirements

Before starting 🏁, you need to have Git and Composer installed.

🏁 Starting

Installation:

# Clone the project
$ git clone https://github.com/comitIdn/project-routeros

# Access the project directory
$ cd project-routeros

# Install dependencies
$ composer install

Usage:

Once installed, you can use the classes provided in RouterOSConnection.php and RouterOSAPI.php to interact with MikroTik devices.

Example:

Here’s an example of how to use RouterOSConnection.php to interact with MikroTik:

require 'vendor/autoload.php';
use App\RouterOSConnection;

// Initialize the connection
$routerOS = new RouterOSConnection('host', 'username', 'password');

// Get all PPPoE users
$pppoeUsers = $routerOS->getPppoeUsers();
print_r($pppoeUsers);

// Add a new PPPoE user
$newPppoeUser = $routerOS->addPppoeUser('username1', 'password123', 'pppoe', 'default');
print_r($newPppoeUser);

// Reboot the router
$reboot = $routerOS->rebootRouter();
print_r($reboot);

Available Methods:

From RouterOSConnection.php:

  1. PPPoE Management:
getPppoeUsers(); // Retrieve all PPPoE users
getPppoeUserDetails($name); // Get details of a specific PPPoE user by name
addPppoeUser($name, $password, $service, $profile, $comment); // Add a new PPPoE user
setPppoeUser($name, $password, $profile, $comment); // Update PPPoE user details
removePppoeUser($name); // Remove a PPPoE user
getActivePppoeUsers(); // Get all active PPPoE users
removeActivePppoeUser($id); // Remove an active PPPoE user by session ID
  1. Hotspot Management:
getHotspotUsers(); // Retrieve all Hotspot users
addHotspotUser($name, $password, $profile, $limitUptime, $comment); // Add a new Hotspot user
setHotspotUser($name, $password, $limitUptime, $comment, $profile); // Update Hotspot user details
removeHotspotUser($name); // Remove a Hotspot user
getActiveHotspotUsers(); // Get all active Hotspot users
removeActiveHotspotUser($id); // Remove an active Hotspot user by session ID
  1. Firewall Management:
getFirewallFilterRules(); // Get all firewall filter rules
getFirewallNatRules(); // Get all firewall NAT rules
getFirewallMangleRules(); // Get all firewall mangle rules
getFirewallRawRules(); // Get all firewall raw rules
  1. DNS Management:
getDnsCache(); // Get all DNS cache entries
getDnsSettings(); // Get DNS settings
  1. System Management:
getSystemResources(); // Get system resources (CPU, memory, uptime, etc.)
rebootRouter(); // Reboot the router
  1. Queue Management:
getQueues(); // Get all queues
addQueue($name, $target, $maxLimit); // Add a queue
  1. Tools:
ping($address); // Ping a specific IP address
getNetwatch(); // Get active Netwatch entries
  1. Log Management:
getLogs(); // Retrieve system logs
  1. Custom Command Execution:
customCommand($command); // Execute custom RouterOS commands

From RouterOSAPI.php:

  1. System Script Management:
addSystemScript($name, $source); // Add a new system script
removeSystemScript($name); // Remove a system script
getSystemScripts(); // Get all system scripts
getSystemScriptByName($name); // Get specific script details by name
  1. Scheduler Management:
addScheduler($name, $onEvent, $startDate, $startTime, $interval); // Add a new scheduler
removeScheduler($name); // Remove a scheduler
  1. Firewall Management (Extended):
getFirewallFilterRules(); // Get all firewall filter rules
getFirewallNatRules(); // Get all firewall NAT rules
getFirewallMangleRules(); // Get all firewall mangle rules
getFirewallRawRules(); // Get all firewall raw rules
  1. Tools (Extended):
ping($address); // Ping a specific IP address
getNetwatch(); // Get active Netwatch entries

📝 License This project is licensed under the MIT License. For more details, see the LICENSE file.

Made with ❤️ by Bang AL

Back to top# project-routeros

project-routeros

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages