0% found this document useful (0 votes)
68 views19 pages

Centralised Router Configuration Routeros Api and PHP: Using

This document discusses using the RouterOS API and PHP to centrally configure MikroTik routers. It provides an overview of the speaker and his company, explains why using an API is beneficial for automation, and demonstrates how to connect a PHP application to the RouterOS API to retrieve information and make configuration changes. Code samples are provided to illustrate reading wireless interfaces and extracting interface IDs to dynamically write configurations.

Uploaded by

Harun Korindo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views19 pages

Centralised Router Configuration Routeros Api and PHP: Using

This document discusses using the RouterOS API and PHP to centrally configure MikroTik routers. It provides an overview of the speaker and his company, explains why using an API is beneficial for automation, and demonstrates how to connect a PHP application to the RouterOS API to retrieve information and make configuration changes. Code samples are provided to illustrate reading wireless interfaces and extracting interface IDs to dynamically write configurations.

Uploaded by

Harun Korindo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Centralised Router Configuration

using
RouterOS API and PHP

Mike Everest, DuxTel Pty Ltd


about us…

about Mike Everest:



IT and Data Networking since 1986

Background in ISP since 1995

MikroTik Enthusiast since 2004

Formed DuxTel in 2007

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.

Serviced Office network resource. API can


be used to develop an automated means to
enable/disable Aps and VirtualAPs, set and
modify WPA encryption, enable/disable
public access and/or authentication.
a live example…
how it works…

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

filter results of getall, e.g:

/interface/getall
?name=ether3

Filters

Attributes
API structure…
Official Docs - http://wiki.mikrotik.com/wiki/Manual:API

Commands

Filters

define specific parameters, e.g:

/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…?

Mike Everest, DuxTel Pty Ltd


www.duxtel.com.au
shop.duxtel.com.au
[email protected]

You might also like