Community discussions

MikroTik App
 
User avatar
efdsys
just joined
Topic Author
Posts: 5
Joined: Fri Nov 13, 2020 7:06 pm

Get MAC address  [SOLVED]

Sun Nov 22, 2020 10:45 pm

Beginner question: How do I retrieve the current mac address of ether1 into a string variable?

The MAC address I need is the RouterBoard MAC, not the attached device.
 
User avatar
efdsys
just joined
Topic Author
Posts: 5
Joined: Fri Nov 13, 2020 7:06 pm

Re: Get MAC address / Internal server error

Mon Nov 23, 2020 4:14 pm

Ok, I think I figured it out

:global mac [/interface ethernet get 0 orig-mac-address]
:put $mac

New problem. The terminal freezes on me repeatedly with "Internal Server Error".
Any idea why this would occur?
 
jonah1810
newbie
Posts: 29
Joined: Tue Jul 30, 2019 10:19 pm

Re: Get MAC address

Mon Nov 23, 2020 8:16 pm

I've never seen the error, but you should use

get [find where name="ether1"]

instead of using

get 0

Sent from my SM-G955W using Tapatalk

 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1873
Joined: Sat Dec 24, 2016 11:17 am
Location: jo.overland at gmail.com

Re: Get MAC address

Mon Nov 23, 2020 8:38 pm

As Jonah writes, never ever use the ID of any object directly, it will change from time to time.
Only use global variable if you need variables to work in other scripts or you like to save it outside the script for later use.

So:
{
:local mac [/interface ethernet get [find where name="ether1"] orig-mac-address]
:put $mac
}
 
Why do not use Splunk to monitor your MikroTik Router(s)? Look at this page in how to set it up.

MikroTik->Splunk
 
 
User avatar
efdsys
just joined
Topic Author
Posts: 5
Joined: Fri Nov 13, 2020 7:06 pm

Re: Get MAC address

Tue Nov 24, 2020 4:09 pm

Thanks for the help/replies and info.

FYI, the last issue described above was due to DHCP lease time being set to 10 seconds, not 10 minutes.

Who is online

Users browsing this forum: No registered users and 31 guests