help with IP Route Print command ?

hello

what would be the command line equivalent to showing routes that have BGP Communities ‘contains’ XXXX:XX ?

i.e. in /ip route print where bgp-communities ‘contain’ XXXX:XX

what is the symbol for ‘contains’ ?

Thanks.

The ~ operator takes regular expressions.
Here a quick example from my home router - can’t show communities here, so instead a filter to print all routes that have a gateway that starts with a capital A:

[felix@rb750g] > ip route print
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 #      DST-ADDRESS        PREF-SRC        GATEWAY            DISTANCE
 0 ADo  0.0.0.0/0                          10.255.255.253     110
 1   S  0.0.0.0/0                          10.255.255.253     200
 2 ADC  10.255.255.232/30  10.255.255.233  AP-management      0
 3 ADC  10.255.255.236/30  10.255.255.237  management         0
 4 ADC  10.255.255.240/30  10.255.255.241  433                0
 5 ADC  10.255.255.244/30  10.255.255.245  AP-printer         0
 6 ADC  10.255.255.248/29  10.255.255.254  ASA                0
 7 ADo  172.16.0.0/24                      10.255.255.253     110
 8 ADC  172.17.0.0/24      172.17.0.1      AP-hotspot         0
 9 ADC  172.31.255.255/32  172.31.255.255  loopback0          0
10 ADC  192.168.1.0/24     192.168.1.1     LAN                0
[felix@rb750g] > ip route print where gateway~"^A"
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme,
B - blackhole, U - unreachable, P - prohibit
 #      DST-ADDRESS        PREF-SRC        GATEWAY            DISTANCE
 2 ADC  10.255.255.232/30  10.255.255.233  AP-management      0
 5 ADC  10.255.255.244/30  10.255.255.245  AP-printer         0
 6 ADC  10.255.255.248/29  10.255.255.254  ASA                0
 8 ADC  172.17.0.0/24      172.17.0.1      AP-hotspot         0

Thanks.. using this command is rather taxing on the system.. I see CPU utilization shoot up when searching for routes with communities..

Is there any other options ? less taxing on the CPU ? ( we have full routing tables from 4 peers.. approx 1.4 mill routes). On the other hand /ip route print count only does not tax the system..


Thanks.

Not that I am aware of. A direct comparison (=) may be cheaper than a regular expression, but filtering through 1.4 mio routes on RouterOS is always going to tax the CPU. There’s no separation of management plane, control plane, and forwarding plane.

Printing the total count is indeed a lot cheaper since it does not require evaluating each route.