-
Notifications
You must be signed in to change notification settings - Fork 3
v1.2.0
ZILLEALI edited this page May 20, 2026
·
1 revision
Released: 2026-05-19
Tag: v1.2.0
Install: composer require zilleali/mikrotik-laravel:^1.2.0
v1.2.0 adds 10 new ISP-focused managers covering IP management, network monitoring, automation, and real-time session tracking. Built specifically for ISP billing and NOC dashboard integration.
// All assigned IPs
$addresses = MikroTik::ipAddress()->getAddresses();
// Filter by interface
$ether1 = MikroTik::ipAddress()->getAddressesByInterface('ether1');
// Single address
$address = MikroTik::ipAddress()->getAddress('192.168.1.1/24');
// Add IP to interface
MikroTik::ipAddress()->addAddress([
'address' => '192.168.1.1/24',
'interface' => 'ether1',
'comment' => 'LAN gateway',
]);
// Update
MikroTik::ipAddress()->updateAddress('192.168.1.1/24', [
'comment' => 'Updated comment',
]);
// Remove
MikroTik::ipAddress()->removeAddress('192.168.1.1/24');
// Enable / disable
MikroTik::ipAddress()->enableAddress('192.168.1.1/24');
MikroTik::ipAddress()->disableAddress('192.168.1.1/24');
// Check
$assigned = MikroTik::ipAddress()->isAddressAssigned('192.168.1.1/24');
$count = MikroTik::ipAddress()->getAddressCount();// Full ARP table
$table = MikroTik::arp()->getArpTable();
// Lookup by IP
$entry = MikroTik::arp()->getArpByIp('192.168.1.10');
$mac = MikroTik::arp()->getMacByIp('192.168.1.10');
// Lookup by MAC
$entry = MikroTik::arp()->getArpByMac('AA:BB:CC:DD:EE:FF');
$ip = MikroTik::arp()->getIpByMac('AA:BB:CC:DD:EE:FF');
// Filter by interface
$entries = MikroTik::arp()->getArpByInterface('ether1');
// Static entries only
$static = MikroTik::arp()->getStaticArpEntries();
// Add static ARP binding
MikroTik::arp()->addStaticArp(
'192.168.1.100',
'AA:BB:CC:DD:EE:FF',
'ether1',
'Customer static binding'
);
// Remove entry
MikroTik::arp()->removeArp('192.168.1.100');
// Flush cache
MikroTik::arp()->flushArpCache();// Settings
$settings = MikroTik::dns()->getSettings();
// Set upstream servers
MikroTik::dns()->setServers(['8.8.8.8', '1.1.1.1']);
// Remote requests (DNS server for clients)
MikroTik::dns()->enableRemoteRequests();
MikroTik::dns()->disableRemoteRequests();
$allowed = MikroTik::dns()->isRemoteRequestsAllowed();
// Cache
$cache = MikroTik::dns()->getCacheEntries();
MikroTik::dns()->flushCache();
// Static entries
$entries = MikroTik::dns()->getStaticEntries();
$entry = MikroTik::dns()->getStaticEntry('router.local');
MikroTik::dns()->addStaticEntry(
'nexalink.local',
'192.168.1.100',
ttl: 3600,
comment: 'NexaLink server'
);
MikroTik::dns()->updateStaticEntry('nexalink.local', ['address' => '192.168.1.101']);
MikroTik::dns()->removeStaticEntry('nexalink.local');
// Domain blocking (ISP content filtering)
MikroTik::dns()->blockDomain('ads.example.com', 'blocked by policy');
MikroTik::dns()->unblockDomain('ads.example.com');// All routes
$routes = MikroTik::routes()->getRoutes();
// Active routes only
$active = MikroTik::routes()->getActiveRoutes();
// Default gateway
$default = MikroTik::routes()->getDefaultRoute();
// By destination
$route = MikroTik::routes()->getRouteByDestination('192.168.2.0/24');
// By gateway
$routes = MikroTik::routes()->getRoutesByGateway('192.168.1.1');
// Add static route
MikroTik::routes()->addRoute(
'10.0.0.0/8',
'192.168.1.1',
distance: 1,
comment: 'Branch office network'
);
// Update route
MikroTik::routes()->updateRoute('10.0.0.0/8', ['distance' => 5]);
// Remove route
MikroTik::routes()->removeRoute('10.0.0.0/8');
// Failover testing
MikroTik::routes()->disableRoute('0.0.0.0/0');
MikroTik::routes()->enableRoute('0.0.0.0/0');// Settings
$settings = MikroTik::ntp()->getClientSettings();
// Enable/disable
MikroTik::ntp()->enable();
MikroTik::ntp()->disable();
$enabled = MikroTik::ntp()->isEnabled();
// Set servers by IP
MikroTik::ntp()->setServers('216.239.35.0', '216.239.35.4');
// Set servers by DNS
MikroTik::ntp()->setServersByDns('time.google.com', 'time.cloudflare.com');
// Sync status
$synced = MikroTik::ntp()->isSynced();
$status = MikroTik::ntp()->getSyncStatus();
// System clock
$clock = MikroTik::ntp()->getSystemClock();
$time = MikroTik::ntp()->getCurrentTime(); // '14:30:00'
$date = MikroTik::ntp()->getCurrentDate(); // 'may/19/2026'
$timezone = MikroTik::ntp()->getTimezone(); // 'Asia/Karachi'
// Set timezone
MikroTik::ntp()->setTimezone('Asia/Karachi');// Scripts
$scripts = MikroTik::scripts()->getScripts();
$script = MikroTik::scripts()->getScript('flush-dns');
$count = MikroTik::scripts()->getScriptCount();
// Add script
MikroTik::scripts()->addScript(
'flush-dns',
'/ip dns flush',
policy: 'read,write',
comment: 'Flush DNS cache'
);
// Update script
MikroTik::scripts()->updateScript('flush-dns', [
'source' => '/ip dns flush\r\n:log info "DNS flushed"',
]);
// Run script
MikroTik::scripts()->runScript('flush-dns');
// Remove script
MikroTik::scripts()->removeScript('flush-dns');
// Schedulers
$schedulers = MikroTik::scripts()->getSchedulers();
$scheduler = MikroTik::scripts()->getScheduler('daily-backup');
MikroTik::scripts()->addScheduler(
name: 'daily-backup',
onEvent: 'backup-config',
interval: '1d',
startTime: '02:00:00',
comment: 'Run backup at 2am daily'
);
MikroTik::scripts()->updateScheduler('daily-backup', ['interval' => '12h']);
MikroTik::scripts()->removeScheduler('daily-backup');// One-call ISP syslog setup
MikroTik::syslog()->setupRemoteSyslog(
name: 'nexalink-log',
remoteIp: '192.168.1.100',
remotePort: 514,
topics: ['pppoe', 'hotspot', 'firewall', 'error', 'warning']
);
// Targets
$targets = MikroTik::syslog()->getTargets();
$target = MikroTik::syslog()->getTarget('nexalink-log');
$remote = MikroTik::syslog()->getRemoteTargets();
$hasRemote = MikroTik::syslog()->hasRemoteLogging();
// Add remote target manually
MikroTik::syslog()->addRemoteTarget(
name: 'nexalink-log',
remoteIp: '192.168.1.100',
remotePort: 514,
comment: 'NexaLink central logging'
);
MikroTik::syslog()->updateTarget('nexalink-log', ['remote-port' => '515']);
MikroTik::syslog()->removeTarget('nexalink-log');
// Rules
$rules = MikroTik::syslog()->getRules();
// Add rule
MikroTik::syslog()->addRule('pppoe,hotspot', 'nexalink-log');
MikroTik::syslog()->removeRule('pppoe,hotspot', 'nexalink-log');Common ISP topics:
| Topic | Description |
|---|---|
pppoe |
PPPoE session events |
hotspot |
Hotspot login/logout |
firewall |
Firewall drops |
dhcp |
DHCP lease events |
system |
System events |
error |
Errors only |
warning |
Warnings only |
info |
General info |
// All active sessions (PPPoE + Hotspot combined)
$sessions = MikroTik::sessionMonitor()->getAllActiveSessions();
// Each session has 'type' => 'pppoe' or 'hotspot'
// Counts
$total = MikroTik::sessionMonitor()->getTotalSessionCount();
$pppoe = MikroTik::sessionMonitor()->getPppoeSessionCount();
$hotspot = MikroTik::sessionMonitor()->getHotspotSessionCount();
// User lookup
$online = MikroTik::sessionMonitor()->isUserOnline('ali-home');
$session = MikroTik::sessionMonitor()->getUserSession('ali-home');
// [
// 'name' => 'ali-home',
// 'address' => '10.0.0.1',
// 'uptime' => '2h14m',
// 'type' => 'pppoe',
// ]
// Filter by uptime (minutes)
$stale = MikroTik::sessionMonitor()->getSessionsLongerThan(60);
// Filter by IP
$sessions = MikroTik::sessionMonitor()->getSessionsByIp('10.0.0.1');
// NOC dashboard summary
$summary = MikroTik::sessionMonitor()->getSummary();
// ['pppoe' => 142, 'hotspot' => 38, 'total' => 180]Uptime format supported: '45m' → 45 minutes '2h14m' → 134 minutes '1d6h30m' → 1830 minutes '3w2d' → 23040 minutes
// Per-user bandwidth (current session)
$usage = MikroTik::usageTracker()->getPppoeUserUsage('ali-home');
// [
// 'name' => 'ali-home',
// 'tx-byte' => '104857600',
// 'rx-byte' => '524288000',
// 'tx-mb' => 100.0,
// 'rx-mb' => 500.0,
// 'total-mb' => 600.0,
// 'tx-gb' => 0.1,
// 'rx-gb' => 0.49,
// 'total-gb' => 0.59,
// 'total-bytes' => 629145600,
// ]
// All users
$all = MikroTik::usageTracker()->getAllPppoeUsage();
// Top consumers
$top10 = MikroTik::usageTracker()->getTopUsers(10);
$top3 = MikroTik::usageTracker()->getTopUsers(3);
// Network totals
$total = MikroTik::usageTracker()->getTotalNetworkUsage();
// [
// 'tx-bytes' => 5452595200,
// 'rx-bytes' => 19327352832,
// 'tx-mb' => 5200.0,
// 'rx-mb' => 18432.0,
// 'total-mb' => 23632.0,
// 'tx-gb' => 5.08,
// 'rx-gb' => 18.0,
// 'total-gb' => 23.08,
// ]
// Interface traffic
$traffic = MikroTik::usageTracker()->getInterfaceTraffic('ether1');
$all = MikroTik::usageTracker()->getAllInterfaceTraffic();
// Conversion helpers
$mb = MikroTik::usageTracker()->bytesToMb(1048576); // 1.0
$gb = MikroTik::usageTracker()->bytesToGb(1073741824); // 1.0Note: RouterOS session counters reset on reconnect. For persistent usage tracking, store snapshots in Laravel DB.
use ZillEAli\MikrotikLaravel\Support\RateLimiter;
$limiter = new RateLimiter(
maxCallsPerSecond: 5,
maxCallsPerMinute: 60
);
// Check before call
if ($limiter->isThrottled()) {
usleep($limiter->getWaitMicroseconds());
}
$limiter->recordCall();
MikroTik::pppoe()->getActiveSessions();
// Auto-throttle (check + wait + record in one call)
$limiter->throttle();
MikroTik::system()->getCpuLoad();
// Stats
$stats = $limiter->getStats();
// [
// 'total_calls' => 45,
// 'calls_this_second' => 3,
// 'calls_this_minute' => 45,
// 'max_per_second' => 5,
// 'max_per_minute' => 60,
// 'remaining_second' => 2,
// 'remaining_minute' => 15,
// ]
// Remaining
$perSec = $limiter->getRemainingPerSecond();
$perMin = $limiter->getRemainingPerMinute();
// Reset counters
$limiter->reset();
// Settings
$maxSec = $limiter->getMaxCallsPerSecond(); // 5
$maxMin = $limiter->getMaxCallsPerMinute(); // 60- 22 service managers total
- 350 tests passing
- 546 assertions
- CI: PHP 8.2/8.3 × Laravel 11/12
📝 Found an error or missing info?
Edit this page or open an issue to suggest improvements.