First, forgive me for the (bad) English, because I am Brazilian and I’m using google translator.
I’m trying to do using the API editing entries in my ARP table, but I can not do. For example, to add new entries ARP I use the following code:
if ($API->connect(‘$mkipaddress’, ‘$mksisusername’, ‘$mksispassword’)) {
$API->comm(‘/ip/arp/add’, array(
“address” => $mk_cliip,
“interface” => “interna”,
“mac-address” => “00:00:00:00:00:00”,
“comment” => $mk_cliARP,
));
$API->disconnect();
}
$mk_cliARP → This variable contains the ID of my client on the SQL database and your first name, so: [91]-John. Source: $mk_cliARP = “[”.$cli_id."] - ".$cli_name
My questions are:
How do I retrieve the ID of the client when I include myself in the ARP using the code above?
Example: = * id = 2 =
Can anyone help me to change my code to change any ARP entry using the variable as a reference ($mk_cliARP).
In other words, need to change the client’s MAC [91] - John … how do I get the ARP table and change?
thank you very much
Before executing a set command, you execute a print command with an appropriate query. If you know the full comment of the entry you’re about to edit, it’s as easy as
?comment=[91] - John
Just extract the ID from the response, and pass that to the set command.
boen_robot:
Before executing a set command, you execute a print command with an appropriate query. If you know the full comment of the entry you’re about to edit, it’s as easy as
?comment=[91] - John
Just extract the ID from the response, and pass that to the set command.
Sure, man…
I´ll Try… Thanks for reply
I tried the following way (only way I know):
[color=#000080] $API->write('/ip/arp/print');
$API->write('?comment=MeuPcTrampo');
$res = $API->read(true);
echo $res[0]['ID'];[/color]
Not getting any results, I tried with Debug = True, the result was:
Connection attempt #1 to 192.168.55.1:8728… <<< [6] /login >>> [5/5] bytes read. >>> [5, 39]!done >>> [37/37] bytes read. >>> [37, 1]=ret=f0674554f986aac1361d9af369f45ab7 <<< [6] /login <<< [9] =name=sge <<< [44] =response=009cc827d2131d4e108cc8937295a88d7e >>> [5/5] bytes read. >>> [5, 1]!done Connected… <<< [13] /ip/arp/print <<< [20] ?comment=MeuPcTrampo >>> [5/5] bytes read. >>> [5, 700]!trap >>> [31/31] bytes read. >>> [31, 668]=message=no such command prefix >>> [5/5] bytes read. >>> [5, 661]!done >>> [3/3] bytes read. >>> [3, 656]!re >>> [7/7] bytes read. >>> [7, 648]=.id=*4 >>> [21/21] bytes read. >>> [21, 626]=address=192.168.55.5 >>> [30/30] bytes read. >>> [30, 595]=mac-address=70:71:BC:D5:48:7C >>> [18/18] bytes read. >>> [18, 576]=interface=interna >>> [14/14] bytes read. >>> [14, 561]=invalid=false >>> [11/11] bytes read. >>> [11, 549]=DHCP=false >>> [14/14] bytes read. >>> [14, 534]=dynamic=false >>> [15/15] bytes read. >>> [15, 518]=disabled=false >>> [20/20] bytes read. >>> [20, 497]=comment=MeuPcTrampo >>> [3/3] bytes read. >>> [3, 492]!re >>> [7/7] bytes read. >>> [7, 484]=.id=*6 >>> [22/22] bytes read. >>> [22, 461]=address=192.168.55.22 >>> [30/30] bytes read. >>> [30, 430]=mac-address=00:14:2A:F8:02:FD >>> [18/18] bytes read. >>> [18, 411]=interface=interna >>> [14/14] bytes read. >>> [14, 396]=invalid=false >>> [11/11] bytes read. >>> [11, 384]=DHCP=false >>> [14/14] bytes read. >>> [14, 369]=dynamic=false >>> [15/15] bytes read. >>> [15, 353]=disabled=false >>> [15/15] bytes read. >>> [15, 337]=comment=meu pc >>> [3/3] bytes read. >>> [3, 332]!re >>> [8/8] bytes read. >>> [8, 323]=.id=*10 >>> [23/23] bytes read. >>> [23, 299]=address=173.16.252.194 >>> [30/30] bytes read. >>> [30, 268]=mac-address=00:00:00:00:00:00 >>> [18/18] bytes read. >>> [18, 249]=interface=interna >>> [14/14] bytes read. >>> [14, 234]=invalid=false >>> [11/11] bytes read. >>> [11, 222]=DHCP=false >>> [14/14] bytes read. >>> [14, 207]=dynamic=false >>> [15/15] bytes read. >>> [15, 191]=disabled=false >>> [36/36] bytes read. >>> [36, 154]=comment=93 - Mikrotik Cliente teste >>> [3/3] bytes read. >>> [3, 149]!re >>> [8/8] bytes read. >>> [8, 140]=.id=*11 >>> [23/23] bytes read. >>> [23, 116]=address=172.16.252.254 >>> [30/30] bytes read. >>> [30, 85]=mac-address=00:1B:21:7F:10:5D >>> [19/19] bytes read. >>> [19, 65]=interface=esternet >>> [14/14] bytes read. >>> [14, 50]=invalid=false >>> [11/11] bytes read. >>> [11, 38]=DHCP=false >>> [13/13] bytes read. >>> [13, 24]=dynamic=true >>> [15/15] bytes read. >>> [15, 8]=disabled=false >>> [5/5] bytes read. >>> [5, 1]!done Disconnected…
With debug = false, I got no response. If there is abuse, you could help me formulate this query??
You forgot to add false at the command, i.e.
$API->write('/ip/arp/print', false);
$API->write('?comment=MeuPcTrampo');
Even adding the “false” to the command, still unanswered…
The ID property is dotted and lowercased, i.e.
echo $res[0]['.id'];
(for some reason, I didn’t noticed that the first time around…)
boen_robot:
The ID property is dotted and lowercased, i.e.
echo $res[0]['.id'];
(for some reason, I didn’t noticed that the first time around…)
Friend, I believe I could do …
Follow the instruction:
$API->write('/ip/arp/print', false);
$API->write('?address=192.168.55.5');
$res = $API->read($res);
using the statement: print_r ($ res);
Array ( [0] => !re [1] => =.id=*4 [2] => =address=192.168.55.5 [3] => =mac-address=70:71:BC:D5:48:7C [4] => =interface=interna [5] => =invalid=false [6] => =DHCP=false [7] => =dynamic=false [8] => =disabled=false [9] => =comment=MeuPcTrampo [10] => !done )
Using echo $res[1];
=.id=*4
Thank you for your attention to the newcomer here and I hope the post will be useful to other learners.
Brazilian hugs.