Community discussions

MikroTik App
 
amiltonjustino
just joined
Topic Author
Posts: 5
Joined: Sat Jul 28, 2018 1:59 am
Location: Florianópolis
Contact:

Unknown Bridge port remove

Thu Aug 22, 2019 5:20 pm

Hello everyone,

I am trying to make a script to remove the "unknown" interfaces added in bridges, something like this:
/interface bridge port remove where interface="unknown"

But the "where" can not be used after remove, only "number".

Does anyone have any ideas for automating the removal of these "unknown" interfaces?
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3292
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Unknown Bridge port remove

Thu Aug 22, 2019 7:16 pm

How did they get there?
 
amiltonjustino
just joined
Topic Author
Posts: 5
Joined: Sat Jul 28, 2018 1:59 am
Location: Florianópolis
Contact:

Re: Unknown Bridge port remove

Thu Aug 22, 2019 7:25 pm

Hi,
These were interfaces dynamically created by capsman, where remote APs were disconnected for some reason and when they came back capsman creates new interfaces and the old ones are "unknown".
 
pe1chl
Forum Guru
Forum Guru
Posts: 10196
Joined: Mon Jun 08, 2015 12:09 pm

Re: Unknown Bridge port remove

Thu Aug 22, 2019 7:32 pm

How did they get there?
There are lots of ways to get them there!
But of course the fact that you see interface 'unknown' does not mean it is really named 'unknown' so that match does not work.
No idea if it needs to be done with script, in the UI of course you can sort on name and then delete the entire block.
 
amiltonjustino
just joined
Topic Author
Posts: 5
Joined: Sat Jul 28, 2018 1:59 am
Location: Florianópolis
Contact:

Re: Unknown Bridge port remove

Fri Aug 23, 2019 8:27 pm

I need a scheduled task to eliminate without sysadmin interaction.
 
User avatar
SiB
Forum Guru
Forum Guru
Posts: 1888
Joined: Sun Jan 06, 2013 11:19 pm
Location: Poland

Re: Unknown Bridge port remove

Mon Aug 26, 2019 2:48 am

You must check few parameter in your case.
Remember that parameter=no and !parameter have differ result.
I add to bridge port a "virtual ethernet" interface and remove it to create a unknow device into bridge port.

In this scenario I found this way:
/interface bridge port print where status=inactive !dynamic !hw-offload
/interface bridge port remove [find status=inactive !dynamic !hw-offload]
 
amiltonjustino
just joined
Topic Author
Posts: 5
Joined: Sat Jul 28, 2018 1:59 am
Location: Florianópolis
Contact:

Re: Unknown Bridge port remove

Mon Aug 26, 2019 2:31 pm

Perfect.
Solved with "/interface bridge port remove [find status=inactive !dynamic !hw-offload]"

Thank you very much.
 
User avatar
merlinthemagic7
newbie
Posts: 47
Joined: Fri Sep 16, 2016 8:49 pm

Re: Unknown Bridge port remove

Mon Aug 30, 2021 12:16 am

One liner:
:local ifName ""; :foreach id in=[/interface bridge port find where role=[:nothing]] do={ :set ifName [/interface bridge port get $id interface]; :if ([/interface find where name=$ifName] = "" && [/interface list find where name=$ifName] = "") do= { /interface bridge port remove $id; } }
More generally:
:local ifName "";
:foreach id in=[/interface bridge port find where role=[:nothing]] do={
	:set ifName [/interface bridge port get $id interface];
	:if ([/interface find where name=$ifName] = "" && [/interface list find where name=$ifName] = "") do= {
		/interface bridge port remove $id;
	}
}
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Unknown Bridge port remove

Mon Aug 30, 2021 1:31 pm

Better write your script on this way,
/interface bridge port
:foreach id in=[find] do={
    :local ifName [get $id interface]
    :if (([:len [/interface find where name=$ifName]] = 0) && ([:len [/interface list find where name=$ifName]] = 0)) do={
        remove [find where .id=$id]
    }
}


But... why do all that?
Simply
/interface bridge port remove [find where interface~"^\\*[0-9a-fA-F]{1,8}\$"]
This delete the interface if is returned ex id (hexadecimal value from *1 to *fffffffe) instead of interface name or list name.

This is also valid if bridge are removed and interfaces remains orphans:
/interface bridge port remove [find where bridge~"^\\*[0-9a-fA-F]{1,8}\$"]

Who is online

Users browsing this forum: No registered users and 13 guests