Get device IP in API like in winbox

Hello

I want to get list of IP like in winbox when I click … button get list of all connected devices with attributes and I can select. How can I achieve this with API?

Thank you

You mean get a list of all MikroTik devices that have the API enabled?

I think the way Winbox does is to simply send a packet on the broadcast address for port “8291”, and then anyone who answers is assumed to be a MikroTik device. You need to basically do the same, but for port “8728”.

How exactly do you get the local IPs and subnets of the machine your app is running on depends on your language of choice, and the actual OS functions available in that environment.

You mean get a list of all MikroTik devices that have the API enabled?

Yes

I think the way Winbox does is to simply send a packet on the broadcast address for port “8291”, and then anyone who answers is assumed to be a MikroTik device. You need to basically do the same, but for port “8728”.

Thank you

But how can I get version, identity, board name and mac

The MAC you should be able to get by making an ARP request to the network, again using system functions.

AFAIK, you can’t get version, identity and board name without logging into the router. The API protocol doesn’t let you in on those (though yes, the Winbox protocol does).

Winbox detects devices using MNDP:
http://wiki.mikrotik.com/wiki/Manual:IP/Neighbor_discovery
If neighbor discovery is disabled RB device doesn’t appear on Winbox’s list (‘…’ button).
Use MNDP packet device source IP address and check port 8727 at this address.

HTH,

Interesting… Do you know if there is a spec for this protocol somewhere? Ideally, even a sample client in whatever language?

Do you know if there is a spec for this protocol somewhere?

Ask MT support.

MNDP is similar to CDP and Wireshark shows that MNDP packet consists of few TLV (Type/Lenght/Value) triplets.
IMHO it should be quite easy to parse it.

HTH,

Use MNDP packet device source IP address and check port 8727 at this address.

Can I get some example somewhere?

MNDP packets are UDP packets with source and destination port equal to 5678.
If your application received that packet, simply check it’s source IP address.
Next check this IP address for open API port (8728).

HTH,

MNDP packets are UDP packets with source and destination port equal to 5678.
If your application received that packet, simply check it’s source IP address.
Next check this IP address for open API port (8728).

HTH,

Thank you!

Thank you, your post helped me. :smiley:

could you please post what did you exactly do… would be helpful.