Community discussions

MikroTik App
 
chumxeed
just joined
Topic Author
Posts: 2
Joined: Sun Jun 07, 2020 6:53 pm

Please anyone help me debug a script  [SOLVED]

Sat Sep 25, 2021 9:40 pm

I want a script to toggle my WAN Mac address in-order to obtain a new IP address so I try to create a script but it not working at all
please help identify what I'm doing it wrong. thank for all your kindness
below is my script.

:mac [/interface ethernet get [find where name="ether1"] mac-address]
:put $mac
:if ( $mac = 2C:C4:1B:A5:1F:E0 ) do={
/interface ethernet set [find where name="ether1"] mac-address=2C:C4:1B:A5:1F:E7
:log info "Change Mac Address to to Release IP Address"
} else={
/interface ethernet set [find where name="ether1"] mac-address=2C:C4:1B:A5:1F:E0
:log info "Change Mac Address Back to Original"
}
 
chumxeed
just joined
Topic Author
Posts: 2
Joined: Sun Jun 07, 2020 6:53 pm

Re: Please anyone help me debug a script

Sun Sep 26, 2021 4:00 pm

I managed to have it working some how.
the following is my script that is working as it should be

:global macAddress [/interface ethernet get [find where name="ether1"] mac-address]
:global OrigMac [/interface ethernet get [find where name="ether1"] orig-mac-address]
:if ($macAddress != $OrigMac) do={
:log info "Mac Address Changed Reset it Back to Original"
/interface ethernet set [find where name="ether1"] mac-address=$OrigMac
} else={
:log info "Change Mac Address to Obtain new IP Address"
/interface ethernet set [find where name="ether1"] mac-address=2C:C8:1B:AE:8F:E9
}

BTW the trick is global or local variable that make it work or not work in this case.

Who is online

Users browsing this forum: No registered users and 39 guests