Community discussions

MikroTik App
 
jamecollins
just joined
Topic Author
Posts: 18
Joined: Tue Apr 11, 2017 1:00 pm

Get Mac Address first interface

Tue Apr 11, 2017 1:05 pm

Dear all,
I'm new with RouterOS script and I have some problem need help. How can I get mac-address the first interface on my router.
Image
Thanks for your support
 
sid5632
Long time Member
Long time Member
Posts: 553
Joined: Fri Feb 17, 2017 6:05 pm

Re: Get Mac Address first interface

Tue Apr 11, 2017 9:18 pm

:put [/interface ethernet get [/interface ethernet find default-name=ether1] mac-address ]
 
jamecollins
just joined
Topic Author
Posts: 18
Joined: Tue Apr 11, 2017 1:00 pm

Re: Get Mac Address first interface

Wed Apr 12, 2017 4:16 am

:put [/interface ethernet get [/interface ethernet find default-name=ether1] mac-address ]
Very nice. Thanks for your support
 
DavidGB
newbie
Posts: 45
Joined: Fri Sep 14, 2018 9:22 pm

Re: Get Mac Address first interface

Fri Sep 14, 2018 9:31 pm

Hi,

I need help with my code. I get mac adress from microtik wifi client to do some actions but I need to know mac adress from my ISP router. I have conected this router to ether1 and I´ve tried your code but doesn´t work. Can you help me?

My code is the following:

{
:local iPhone [/int wire reg find mac-address="38:71:DE:E4:F8:FB"];

:if ($iPhone!="") do={
/tool fetch url="http://<MyServerIP>/scada-remote" http-data="m=json&r=grp&fn=write&alias=33/1/45&value=1" http-method=post;
} else={
/tool fetch url="http://<MyServerIP>/scada-remote" http-data="m=json&r=grp&fn=write&alias=33/1/45&value=0" http-method=post;
}
}

I'm trying to add your code to search both routers but it does not work

Can anyone help me?

Thanks
 
DavidGB
newbie
Posts: 45
Joined: Fri Sep 14, 2018 9:22 pm

Re: Get Mac Address first interface

Fri Sep 14, 2018 9:36 pm

Hi,

I need help with my code...

I get the MAC from the Wifi devices of the Microtic but I need the ones from the ISP router. I'm trying with your code but it does not work for me. Somebody could help me?

This is my code:

{
:local iPhone [/int wire reg find mac-address="38:71:DE:E4:F8:FB"];

:if ($iPhone!="") do={
/tool fetch url="http://<IP>/scada-remote" http-data="m=json&r=grp&fn=write&alias=33/1/45&value=1" http-method=post;
} else={
/tool fetch url="http://remote:AAaa1111@192.168.1.205:4080/scada-remote" http-data="m=json&r=grp&fn=write&alias=33/1/45&value=0" http-method=post;
}
}
 
User avatar
rushlife
Member Candidate
Member Candidate
Posts: 244
Joined: Thu Nov 05, 2015 12:30 pm

Re: Get Mac Address first interface

Thu Feb 18, 2021 1:41 pm

:put [/interface ethernet get [/interface ethernet find default-name=ether1] mac-address ]
thx a lot bro
awesome
 
choks
just joined
Posts: 1
Joined: Mon Sep 18, 2023 4:37 pm

Re: Get Mac Address first interface

Wed Nov 08, 2023 10:24 pm

:put [/interface ethernet get 0 mac-address ]  
works too , but much shorter to type.

or
:put [/interface ethernet get <current interface name> mac-address ]  
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Get Mac Address first interface

Thu Nov 09, 2023 1:59 am

:put [/interface ethernet get 0 mac-address ]  
works too , but much shorter to type.
But it's also bullshit because numbers and ids shouldn't be used.
You could have saved yourself from necroposting with that shit.

The apparently correct one:
:put [/interface ethernet get [find where default-name=ether1] mac-address]

The apparently correct until someone not change the interface name
:put [/interface ethernet get ether1 mac-address]

The apparently correct shortest possible (until MikroTik do not add ambiguos values)
:put [/in et g [f default-name=ether1] ma]

The apparently correct short, but more readable (until MikroTik do not add ambiguos values)
:put [/int eth get [find default-name=ether1] mac]

But the only correct answer from the OP "Get Mac Address first interface" is:
:put [/int get ([find]->0) mac-address]
So literally is "put on the CLI what is obtained from Get the Mac Address from the first interface found"

Who is online

Users browsing this forum: marcelofares and 17 guests