Centralised Router Configuration Routeros Api and PHP: Using
Centralised Router Configuration Routeros Api and PHP: Using
Centralised Router Configuration Routeros Api and PHP: Using
using
RouterOS API and PHP
about DuxTel:
•
ISP and Public Access Specialist
•
Data Network Hardware and Software solutions
•
MikroTik Distributor in Australia and Pacific
•
Predominantly B2B
why API?
API = Application Programming Interface:
A mechanism to automate configuration,
management and monitoring tasks.
Examples:
Network of Freenet HotSpot devices based
on advertising campaigns. API can be used
to develop a means of automatically rolling
out a walled garden list to all or selected
hotspots, as well as to set campaign-
specific info such as SSID name.
internet
putting it together…
Step1:prepare the router
putting it together…
Step2:prepare the web site
•
install web server software: apache, IIS, lighttpd, etc
•
download & install php (http://php.net)
•
get the PHP API* class from
http://wiki.mikrotik.com/wiki/API_PHP_class
API structure…
Official Docs - http://wiki.mikrotik.com/wiki/Manual:API
Commands
Filters
Attributes
API structure…
Official Docs - http://wiki.mikrotik.com/wiki/Manual:API
Commands
approximately equivalent to shell, e.g:
/interface/vlan/remove
Filters
/ip/route/add
use ‘getall’ instead of ‘print’, e.g:
Attributes
/ip/address/getall
/ppp/secret/getall
/hotspot/active/getall
API structure…
Official Docs - http://wiki.mikrotik.com/wiki/Manual:API
Commands
/interface/getall
?name=ether3
Filters
Attributes
API structure…
Official Docs - http://wiki.mikrotik.com/wiki/Manual:API
Commands
Filters
/ip/address/add
=address=192.168.1.1/24
=interface=ether3
Attributes
sample application…
step1: read the wireless interfaces and display
•
API->connect( router_address, uname, passwd )
•
API->write( command, process=true )
•
API->read( parse=true )
•
Always start with API->connect()
•
There must be 1 and only 1 API->read() for each
API->write()
sample application…
step2: extract the interface ID, write a change
sample application…
step2: extract the interface ID, write a change
sample application…
step3: generalise it
sample application…
step3: generalise it
sample application…
step4: AJAX abstraction
do it yourself…
questions…?