Is it possible to use a network mask without abbreviation (CIDR) in a command (ip route add)?

Hello.

When building a static network route, can I use a network mask without abbreviation (CIDR) in the command?

example

/ip route add dst-address=31.13.24.0 netmask=255.255.248.0 gateway=<vpn-user_vpn_s0> comment="whatsapp"

my device

/ arm64 / hAP ax^3 / 7.20.6 (stable)

No. RouterOS only accepts the dst-address prefix in the add.re.ss.bits/prefix-length format (31.13.24.0/21 in your case).

Other than that, unless you are adding the route just temporarily, the format of the name of the gateway interface (the use of the < > characters) indicates that it is an ephemeral one, so once the connection breaks, the route will become unusable. If it needs to be permanently linked to that VPN client, some extra steps have to be taken.

1 Like

Why would you want to? The benefit of CIDR format is that you can only use legal suffixes, whereas the netmask allows illegal netmasks such as 255.255.0.255

1 Like

Thanks for advices.

I processed the list in AI.
I'm too lazy to calculate the mask's cidr myself.

After that, in terms of automating this case through bgp announcements.

Your mission, should you accept it, is to find in the middle column the desired netmask and read the corresponding CIDR beside it on the same line:

CIDR Netmask CIDR
/0 0.0.0.0 /0
/1 128.0.0.0 /1
/2 192.0.0.0 /2
/3 224.0.0.0 /3
/4 240.0.0.0 /4
/5 248.0.0.0 /5
/6 252.0.0.0 /6
/7 254.0.0.0 /7
/8 255.0.0.0 /8
/9 255.128.0.0 /9
/10 255.192.0.0 /10
/11 255.224.0.0 /11
/12 255.240.0.0 /12
/13 255.248.0.0 /13
/14 255.252.0.0 /14
/15 255.254.0.0 /15
/16 255.255.0.0 /16
/17 255.255.128.0 /17
/18 255.255.192.0 /18
/19 255.255.224.0 /19
/20 255.255.240.0 /20
/21 255.255.248.0 /21
/22 255.255.252.0 /22
/23 255.255.254.0 /23
/24 255.255.255.0 /24
/25 255.255.255.128 /25
/26 255.255.255.192 /26
/27 255.255.255.224 /27
/28 255.255.255.240 /28
/29 255.255.255.248 /29
/30 255.255.255.252 /30
/31 255.255.255.254 /31
/32 255.255.255.255 /32

no real need of AI, IMHO.

As in "real men don't need AI, they make their own mistakes"?

What I would do, but only if the list was changing every now and then so it would have to be re-imported, would be to use a RouterOS script for that. But in such case (a large list that is changing), an address list, mangle rules, and an extra routing table are the way to go, not hundreds of static routes.

Yep :slightly_smiling_face:, something like that, do you prefer to blame yourself for making a mistake or blame yourself for having delegated to the AI to make that same mistake?

Personally I would use a spreadsheet and a VLOOKUP before importing to do the conversion, but of course everyone will have their preferred tool/way.

well... my preference here is clear, let the thing take care of itself. So RouterOS script is the choice just because the router itself can download the source data and process them on its own whereas a spreadsheet needs the administrator to participate in that process. It has nothing to do with simplicity/complexity or elegance of the tool, just with its availability on the router.