BenMenking / routeros-api

Client API for RouterOS/Mikrotik
338 stars 270 forks source link

disabled/enable NAT #57

Closed abdkaviani closed 3 years ago

abdkaviani commented 3 years ago

Hello I want to change one of NAT (num3) from enable to disabled, This is my code:

$API->write("/ip/firewall/nat/set", false); $API->write("=disabled=yes", false); $API->write("=.id=3");

What is wrong? Thank you

scottchiefbaker commented 3 years ago

I think you want something like this:

$cmd    = "/ip/firewall/nat/set";
$params = ['.id' => 3, 'disabled' => 'yes'];
$data   = $API->comm($cmd, $params);
Chupaka commented 3 years ago

I think, "=.id=3" is wrong. IIRC, API ids start from asterisk :) E.g., *123. So you cannot simply use the number of your rule from print command in Terminal, you need to obtain correct .id first.