Community discussions

MikroTik App
 
giguard
newbie
Topic Author
Posts: 35
Joined: Mon Oct 01, 2018 7:10 pm

How to write dynamic command line?

Tue Oct 16, 2018 10:05 am

Hi,
See below for command I'm interested in.
/interface bridge
add admin-mac=AA:BB:CC:DD:EE:FF auto-mac=no name=mybridge
Assuming AA:BB:CC:DD:EE:FF is a MAC address of the ether1 and I'm planning to make ether1 as a master of mybridge.
I want to covert above command to look something like,
/interface bridge
add admin-mac=[ /interface ethernet print mac-address where name=ether1 ] auto-mac=no name=mybridge
Now I know above command does not work. But it should be very clear what I'm after here.
Is there a way to do this so I can have it permanently written inside my default config file and use it across many devices?
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: How to write dynamic command line?

Wed Oct 17, 2018 4:19 am

You was nearly there with your code.
/interface bridge
add admin-mac=[/interface ethernet get [find where name="ether1"] mac-address] auto-mac=no name=mybridge
 
giguard
newbie
Topic Author
Posts: 35
Joined: Mon Oct 01, 2018 7:10 pm

Re: How to write dynamic command line?

Wed Oct 17, 2018 5:26 am

Excellent. !!!

While we are on the topic, I woud like to know if I was to use auto-mac property would it effectively do the same thing?
Meaning, can I drop the admin-mac entirely and rely on ROS to do the right thing?
/interface bridge
add auto-mac=yes name=mybridge
I'm guessing that ROS will automagically pick up the MAC address of the very first interface that joins the bridge right? Or, is this not a guaranteed behaviour?
 
2frogs
Forum Veteran
Forum Veteran
Posts: 713
Joined: Fri Dec 03, 2010 1:38 am

Re: How to write dynamic command line?

Wed Oct 17, 2018 6:56 am

Using auto-mac, the MAC can change after a reboot. Not so great if you are using the MAC for static lease or for other hard coded settings.
 
User avatar
mkx
Forum Guru
Forum Guru
Posts: 11439
Joined: Thu Mar 03, 2016 10:23 pm

Re: How to write dynamic command line?

Wed Oct 17, 2018 5:54 pm

Using auto-mac the bridge MAC address can also change if you remove the "donnor" port from the bridge. Having bridge MAC address set statically could show even nastier side-effects in such case.
The best approach would be to set bridge MAC address to a completely different MAC address for which you're 105% sure it'll never show up in your network. Such as MAC address of a physically broken ethernet NIC that happens to lie in the back of your bottom drawer instead of being disposed off properly years ago.

Who is online

Users browsing this forum: No registered users and 48 guests