I’m trying to use community-list
to filter routes or modify certain communities, but it’s really hard to achieve using regexp
.
The help page didn’t include any examples for this, so I had to test it on my own, encountering numerous failures along the way. For example:
- Adding regexp items in Winbox fails:
- I can’t add new items via Winbox with
type=regexp
. - No matter what I enter in the “Regexp” box, from regex patterns tested successfully on regex101.com to empty string, RouterOS always returns “invalid regexp”.
- Adding regexp items behaves strangely:
- I can add new items via the console with
type=regexp
, but the content of “regexp” displays differently in Winbox versus the console (what the heck?). - After adding a regexp item via the console, I can modify the “regexp” content in Winbox without triggering the “invalid regexp” error.
- Inconsistent behavior when applying the list in filtering rules:
- The list works for matching routes but fails to delete communities.
- Here are the two community lists I configured:
`/routing filter community-list
add list=dn42_connection_info_regex regexp=“64511\:\d”
add list=dn42_connection_info communities=“64511:1,64511:2,64511:3,64511:4,64511:5,64511:6,64511:7,64511:8,64511:9,64511:10,64511:11,64511:12,64511:13,64511:14,64511:15,64511:16,64511:17,64511:18,64511:19,64511:20,64511:21,64511:22,64511:23,64511:24,64511:25,64511:26,64511:27,64511:28,64511:29,64511:30,64511:31,64511:32,64511:33,64511:34,64511:35”`
- Testing filtering rules:
(Note: In Winbox, the regexp is set to"64511\:[\d|[1-3][0-9]]"
.)
-
if (bgp-communities any-list dn42_connection_info_regex) { delete bgp-communities dn42_connection_info_regex; accept; }
→ Matches correctly, but deletion fails. -
if (bgp-communities any-list dn42_connection_info) { delete bgp-communities dn42_connection_info_regex; accept; }
→ Matches correctly, but deletion fails. -
if (bgp-communities any-list dn42_connection_info_regex) { delete bgp-communities dn42_connection_info; accept; }
→ Matches correctly, deletion succeeds. -
if (bgp-communities any-list dn42_connection_info) { delete bgp-communities dn42_connection_info; accept; }
→ Matches correctly, deletion succeeds.
Regexp is incredibly useful for configuration and offers great flexibility. I hope there will be more documentation and examples on how to properly configure it for route filtering.