Exact command for command execution in Mikrotik through the API in PHP?

0

The idea is this, I have a website so that users can restart their Internet connection, but I want the command to restart the DHCP interface, which is "/ ip dhcp-client release 0" can be sent to the Mikrotik using the API, the idea of the web is that when the button is given to restart the connection, execute the file release.php which contains this code for the restart of it but it does not work for me:

<?php
require('../routeros_api.class.php');
$API = new RouterosAPI();
$API->debug = true;
if ($API->connect('111.111.111.111', 'LOGIN', 'PASSWORD')) {
  $API->comm("/ip/dhcp-client/release/0"
  $API->disconnect();
}
?>

The problem is that I'm sure that this line is what I'm not putting well:

   $API->comm("/ip/dhcp-client/release/0")

If you could help me, the idea is to send the command to the mikrotik so that remotely and without the users to access the team in Release to their connection and giving it that reboots, greetings

    
asked by Pedro Rafael Santiesteban 01.12.2017 в 02:35
source

2 answers

0
<?php

require('../routeros_api.class.php');

$API = new RouterosAPI();

$API->debug = true;

if ($API->connect('ip_del_MT', 'LOGIN', 'PASS')) {

   $API->write('/ip/dhcp-client/release/0');

   $API->disconnect();

}

?>

It works for me so I have an MT with RouterOS v6.40.4

    
answered by 19.02.2018 в 07:23
0
$API->write('/ip/dhcp-client/release',false);
$API->write("=.id=0",true);

This is the solution that I use and it works for me. You must change where it says 0 by the id of the interface that you want to make the release.

Greetings

    
answered by 24.06.2018 в 21:37