please help me i cant reset mac address with api
my code not working
$a=$API->comm("/interface/ethernet/print");
$n=0;
while($n<count($a)){
$re=$a[$n];
$API->write("interface/ethernet/set",false);
$API->write("=.id=".$re['.id'],false);
$API->write("=mac-address=".$re['orig-mac-address']);
$n++;
}
Where moderators and experts ?
I can tell you one of them at least is cringing…
If you’re not too attached to that API client, with the one from my signature, you can do it with
$util = new RouterOS\Util($client = new RouterOS\Client('192.168.88.1', 'admin', 'password'));
$resetRequest = new RouterOS\Request('/interface ethernet reset-mac-address');
$resetRequest->setArgument('numbers', $util->setMenu('/interface ethernet')->find());
$client->sendSync($resetRequest);
Basically, this is the equivalent of the terminal’s “/interface ethernet reset-mac-address [find]”.
(and you just gave me an idea how I could simplify it even further in the near future…)