Possible to get port MAC used in Agent Remote ID field?

We are trying to use Option 82 on a couple routers with devices connected locally. I’d like to turn on Option 82 on the bridge and get the router to forward the port MAC address as the “Remote Agent ID”. It looks like it uses the port name for the Remote Agent ID and we have to have this in a MAC address format for our billing software to work properly.

Trying to be smart, I named the port with the MAC address string. That failed miserably. The Port MAC is: CC:2D:E0:67:38:B9 and when I put that as the name, I get this in the Remote Agent ID: 43:43:3a:32:44:3a:45:30:3a:36:37:3a:33:38:3a:42:39 Nothing in that string makes any sense to me. The MAC of the device attached to that port is not part of that string.

Is there a way to get ROS to use the port hardware MAC as the Remote Agent ID with Option 82 or is there a better way for me to solve this?

What you see in Remote Agent ID is HEX notation of text string “CC:2D:E0:67:38:B9” … 0x43 is “C”, 0x3a is “:” etc. If you wanted Remote Agent ID returned in the same way as MAC (less formatting, which includes “:” signs), you’d have to enter port name as some text garbage, but in ISO 8859-2 code page it would look like “Ě-ŕg8š” (less double-quotes) … look up characters in relevant code page layout.

Note: you can use any 8-bit code page, whichever is more native to you - eg. ISO8859-1 (the text would be “Ì-àg8¹” less double quotes) or windows-1252 (this particular MAC would translate to the same text as ISO 8859-1, there are differences between these two though) or MAC-roman (“Ã-‡g8∏”) …

Since the actual MAC addresses of the ports may contain bytes with values 00 to 1f which are not easy to be entered using any code page, you may also choose to name the ports using unique 6-symbol identifiers from the basic ASCII table if you only need that the radius parameter formally looks like a MAC address and is unique across your network. Just take care that the first symbol’s code is divisible by 4 to match the structure of a MAC address should the server check it, which means digits 0, 4, 8, symbol @ and some other ones, and letters D, H, L, P, T, X (small or capital) are eligible at the first position.

If it is absolutely necessary to use the actual MAC addresses, look at this for inspiration, but bytes with zero value may remain a mission impossible thanks to internal string representation.

Why, oh why must Mikrotik use different syntax for the same thing at different places…

It’s actually way simpler, and zero bytes are no problem either.

Assuming that the MAC address of the interface is A0:B1:C2:D3:E4:F5, just set the name as “\A0\B1\C2\D3\E4\F5” (using a terminal window or ssh, GUI may require a different format). Capital A-F are mandatory, a-f are not accepted. That should be all. When you display it, those bytes which can be displayed as printable characters will be displayed that way but that’s fine.