I have a script here that displays the port on a switch on which a Mikrotik device is located.
But we have VLAN here, such as VLAN100, VLAN200, etc.
Can the script be optimized? Or what do you think about this?
Code: Select all
:foreach i in=[/interface bridge host find] do={
:local vid [/interface bridge host get $i vid]
:local port [/interface bridge host get $i interface]
:local mac [/interface bridge host get $i mac-address]
:local vendor "unkown"
:if (($vid != 1) && ($vid != 99) && ($vid < 100 || $vid > 2000) && !($port ~ "bridge" || $port ~ "sfp")) do={
:if ($mac ~ "00:0C:42" || $mac ~ "08:55:31" || $mac ~ "18:FD:74" || $mac ~ "2C:C8:1B" || $mac ~ "48:8F:5A" || $mac ~ "48:A9:8A" || $mac ~ "4C:5E:0C" || $mac ~ "64:D1:54" || $mac ~ "6C:3B:6B" || $mac ~ "74:4D:28" || $mac ~ "78:9A:18" || $mac ~ "B8:69:F4" || $mac ~ "C4:AD:34" || $mac ~ "CC:2D:E0" || $mac ~ "D4:CA:6D" || $mac ~ "DC:2C:6E" || $mac ~ "E4:8D:8C") do={
:set vendor "MikroTik"
}
:if ($vendor = "MikroTik") do={
:put ("MAC-Adresse: " . $mac . " is Vendor: " . $vendor . " und ist am Port: " . $port . " VID: " . $vid)
}
}
}