Unknown Bridge port remove

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?

How did they get there?

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”.

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.

I need a scheduled task to eliminate without sysadmin interaction.

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]

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

Thank you very much.

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;
	}
}

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}\$"]