20.10.2020, 06:57
Use attached code to create a user library named mikrotik.
Make sure that your router is running at least v6.43.
It is recommended to create a separate user for api access, possibly with limited read-only access if you don't need to change anything on the router remotely.
Example:
Make sure that your router is running at least v6.43.
It is recommended to create a separate user for api access, possibly with limited read-only access if you don't need to change anything on the router remotely.
Example:
Code:
mt, err = require('user.mikrotik').new('192.168.1.1')
if mt then
res, err = mt:login('api', '123456') -- user api, pass 123456
if res then
-- get wireless registration table
res, err = mt:readlist('/interface/wireless/registration-table/print')
log(res)
else
log('login failed', tostring(err))
end
mt:close()
else
log('connect failed', tostring(err))
end