Hello guys , trying all night to do some coding with no luck. I am making IP/MAC control for users on Mikrotik, so fo every user i create a rule in mangle chain with their IP / MAC values:
chain=prerouting action=mark-packet new-packet-mark=active passthrough=yes src-address=192.168.5.2
src-mac-address=11:11:11:11:11:12
I make it with PHP using routeros_api.class.php - which I found in the wiki - my code is:
$API->write('/ip/firewall/mangle/add',false);
$API->write('=chain=prerouting',false);
$API->write('=src-address='.$user_ip,false);
$API->write('=src-mac-address='.$user_mac,false);
$API->write('=action=mark-packet',false);
$API->write('=new-packet-mark=active',false);
$API->write('=comment='.$user_name,false);
$API->write('=disabled=false');
$res2=$API->read(true);
This creates my rule - But - for some users I want to change the MAC address later - for example when they buy new PC
I get $row_id first with other function - And with this code I can change the MAC
$API->write('/ip/firewall/mangle/set',false);
$API->write('=.id='.$row_id,false);
$API->write('=src-mac-address='.$user_mac);
$res=$API->read(true);
So far so good now my problem is when I want to remove src-mac-address restriction for some users - I tried to do this:
$API->write('/ip/firewall/mangle/set',false);
$API->write('=.id='.$row_id,false);
$API->write('=src-mac-address=');
$res=$API->read(true);
It does not work - I also tried this row and it does not work either:
$API->write('=src-mac-address=""');
So how to edit this value src-mac-address - to go default - like it is gray in Winbox ?
Te explain this again with CLI - my row is:
chain=prerouting action=mark-packet new-packet-mark=active passthrough=yes src-address=192.168.5.2
src-mac-address=11:11:11:11:11:12
And I want to make it this:
chain=prerouting action=mark-packet new-packet-mark=active passthrough=yes src-address=192.168.5.2
Any Ideas ?