script to change MAC address...

Let said my MAC address is: 4C:5E:0C:85:AF:E1, how can i write a script that when i copy and paste.
It will help me auto change the MAC address from 4C:5E:0C:85:AF:E1 to 4C:5E:0C:11:22:33.

i need to do so for backup and restore purpose, export may help on same model and version, but not other’s.

/interface ethernet set [find orig-mac-address=4C:5E:0C:85:AF:E1] mac-address=4C:5E:0C:11:22:33

(assuming that 4C:5E:0C:85:AF:E1 is your interface’s FACTORY mac address, as opposed to it having been configured later on)

i want to get original mac address with out reset mac address how can i do this :smiley: :smiley: :smiley:

/interface ethernet get [find default-name=ether1] orig-mac-address

Assuming you want to get the MAC address of the first Ethernet adapter (regardless of its current name). Change “ether1” to whatever the default name of your target device is (ether2, ether3, etc.).

not work on os 5.20

input does not match any value of value-name

I think i had misleading, let say some my new wireless card is from other vendor i need it to be Mikrotik mac address easy for my remote verification:

new card 1: 52:55:0C:85:AF:E0
new card 2: 52:55:0C:85:AF:E1
new card 3: 52:55:0C:85:AF:E2
new card 4: 52:55:0C:85:AF:E3
new card 5: 52:55:0C:85:AF:E4
new card 6: 52:55:0C:85:AF:E5
new card 7: 52:55:0C:85:AF:E6
new card 8: 52:55:0C:85:AF:E7
new card 9: 52:55:0C:85:AF:E8
new card 10: 52:55:0C:85:AF:E9

I need the script when i paste into the new terminal, it will copy the last 6 digit of the new card and same time, it will replace my first 6 digit with mikrotik mac address.

new card 1: From 52:55:0C:85:AF:E0 to 4C:5E:0C:85:AF:E0
new card 2: From 52:55:0C:85:AF:E1 to 4C:5E:0C:85:AF:E1
new card 3: From 52:55:0C:85:AF:E2 to 4C:5E:0C:85:AF:E2
new card 4: From 52:55:0C:85:AF:E3 to 4C:5E:0C:85:AF:E3
new card 5: From 52:55:0C:85:AF:E4 to 4C:5E:0C:85:AF:E4
new card 6: From 52:55:0C:85:AF:E5 to 4C:5E:0C:85:AF:E5
new card 7: From 52:55:0C:85:AF:E6 to 4C:5E:0C:85:AF:E6
new card 8: From 52:55:0C:85:AF:E7 to 4C:5E:0C:85:AF:E7
new card 9: From 52:55:0C:85:AF:E8 to 4C:5E:0C:85:AF:E8
new card 10: From 52:55:0C:85:AF:E9 to 4C:5E:0C:85:AF:E9

is like find xx, set… 4C:5E:0C:$??

#fill your first 6 digit mac
:global stmac “11:22:33”
#no need change
:global enmac
:foreach oldmac in=[/interface ethernet find] do={
:set enmac [:pick [/interface ethernet get $oldmac mac-address] 8 17]
/interface ethernet set $oldmac mac-address=($stmac.$enmac)
}

Hi, can share how the code work?
Hope to understand more on it…

By the way, I’m not sure when this command came along, but now there is a command to reset to actual HW address.

/int ethernet reset-mac-address X
(where X is the index of the interface to reset.)

If you want to just reset them ALL, then you can replace X with [find]

copy my code to add a scripts,and run this scripts

please help i cant reset mac address with api

my code not work

$a=$API->comm("/interface/ethernet/print");	
while($n<count($a)){
	$re=$a[$n];
$API->write("interface/ethernet/set",false);
$API->write("=.id=".$re['.id'],false);
$API->write("=mac-address=".$re['orig-mac-address']);

$n++;
}